/usr/share/doc/libghc-transformers-doc/html/transformers.txt is in libghc-transformers-doc 0.3.0.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Concrete functor and monad transformers
--
-- A portable library of functor and monad transformers, inspired by the
-- paper "Functional Programming with Overloading and Higher-Order
-- Polymorphism", by Mark P Jones, in <i>Advanced School of Functional
-- Programming</i>, 1995
-- (<a>http://web.cecs.pdx.edu/~mpj/pubs/springschool.html</a>).
--
-- This package contains:
--
-- <ul>
-- <li>the monad transformer class (in
-- <a>Control.Monad.Trans.Class</a>)</li>
-- <li>concrete functor and monad transformers, each with associated
-- operations and functions to lift operations associated with other
-- transformers.</li>
-- </ul>
--
-- It can be used on its own in portable Haskell code, or with the monad
-- classes in the <tt>mtl</tt> or <tt>monads-tf</tt> packages, which
-- automatically lift operations introduced by monad transformers through
-- other transformers.
@package transformers
@version 0.3.0.0
-- | Products, lifted to functors.
module Data.Functor.Product
-- | Lifted product of functors.
data Product f g a
Pair :: (f a) -> (g a) -> Product f g a
instance (MonadFix f, MonadFix g) => MonadFix (Product f g)
instance (MonadPlus f, MonadPlus g) => MonadPlus (Product f g)
instance (Monad f, Monad g) => Monad (Product f g)
instance (Alternative f, Alternative g) => Alternative (Product f g)
instance (Applicative f, Applicative g) => Applicative (Product f g)
instance (Traversable f, Traversable g) => Traversable (Product f g)
instance (Foldable f, Foldable g) => Foldable (Product f g)
instance (Functor f, Functor g) => Functor (Product f g)
-- | Composition of functors.
module Data.Functor.Compose
-- | Right-to-left composition of functors. The composition of applicative
-- functors is always applicative, but the composition of monads is not
-- always a monad.
newtype Compose f g a
Compose :: f (g a) -> Compose f g a
getCompose :: Compose f g a -> f (g a)
instance (Alternative f, Applicative g) => Alternative (Compose f g)
instance (Applicative f, Applicative g) => Applicative (Compose f g)
instance (Traversable f, Traversable g) => Traversable (Compose f g)
instance (Foldable f, Foldable g) => Foldable (Compose f g)
instance (Functor f, Functor g) => Functor (Compose f g)
-- | The identity functor and monad.
--
-- This trivial type constructor serves two purposes:
--
-- <ul>
-- <li>It can be used with functions parameterized by functor or monad
-- classes.</li>
-- <li>It can be used as a base monad to which a series of monad
-- transformers may be applied to construct a composite monad. Most monad
-- transformer modules include the special case of applying the
-- transformer to <a>Identity</a>. For example, <tt>State s</tt> is an
-- abbreviation for <tt>StateT s <a>Identity</a></tt>.</li>
-- </ul>
module Data.Functor.Identity
-- | Identity functor and monad.
newtype Identity a
Identity :: a -> Identity a
runIdentity :: Identity a -> a
instance MonadFix Identity
instance Monad Identity
instance Applicative Identity
instance Traversable Identity
instance Foldable Identity
instance Functor Identity
-- | Classes for monad transformers.
--
-- A monad transformer makes a new monad out of an existing monad, such
-- that computations of the old monad may be embedded in the new one. To
-- construct a monad with a desired set of features, one typically starts
-- with a base monad, such as <tt>Identity</tt>, <tt>[]</tt> or
-- <a>IO</a>, and applies a sequence of monad transformers.
--
-- Most monad transformer modules include the special case of applying
-- the transformer to <tt>Identity</tt>. For example, <tt>State s</tt> is
-- an abbreviation for <tt>StateT s Identity</tt>.
--
-- Each monad transformer also comes with an operation
-- <tt>run</tt><i>XXX</i> to unwrap the transformer, exposing a
-- computation of the inner monad.
module Control.Monad.Trans.Class
-- | The class of monad transformers. Instances should satisfy the
-- following laws, which state that <a>lift</a> is a transformer of
-- monads:
--
-- <ul>
-- <li><pre><a>lift</a> . <a>return</a> = <a>return</a></pre></li>
-- <li><pre><a>lift</a> (m >>= f) = <a>lift</a> m >>=
-- (<a>lift</a> . f)</pre></li>
-- </ul>
class MonadTrans t
lift :: (MonadTrans t, Monad m) => m a -> t m a
-- | Class of monads based on <tt>IO</tt>.
module Control.Monad.IO.Class
-- | Monads in which <a>IO</a> computations may be embedded. Any monad
-- built by applying a sequence of monad transformers to the <a>IO</a>
-- monad will be an instance of this class.
--
-- Instances should satisfy the following laws, which state that
-- <a>liftIO</a> is a transformer of monads:
--
-- <ul>
-- <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
-- <li><pre><a>liftIO</a> (m >>= f) = <a>liftIO</a> m >>=
-- (<a>liftIO</a> . f)</pre></li>
-- </ul>
class Monad m => MonadIO m
liftIO :: MonadIO m => IO a -> m a
instance MonadIO IO
-- | Continuation monads.
module Control.Monad.Trans.Cont
-- | Continuation monad. <tt>Cont r a</tt> is a CPS computation that
-- produces an intermediate result of type <tt>a</tt> within a CPS
-- computation whose final result type is <tt>r</tt>.
--
-- The <tt>return</tt> function simply creates a continuation which
-- passes the value on.
--
-- The <tt>>>=</tt> operator adds the bound function into the
-- continuation chain.
type Cont r = ContT r Identity
-- | Construct a continuation-passing computation from a function. (The
-- inverse of <a>runCont</a>.)
cont :: ((a -> r) -> r) -> Cont r a
-- | Runs a CPS computation, returns its result after applying the final
-- continuation to it. (The inverse of <a>cont</a>.)
runCont :: Cont r a -> (a -> r) -> r
-- | Apply a function to transform the result of a continuation-passing
-- computation.
--
-- <ul>
-- <li><pre><a>runCont</a> (<a>mapCont</a> f m) = f . <a>runCont</a>
-- m</pre></li>
-- </ul>
mapCont :: (r -> r) -> Cont r a -> Cont r a
-- | Apply a function to transform the continuation passed to a CPS
-- computation.
--
-- <ul>
-- <li><pre><a>runCont</a> (<a>withCont</a> f m) = <a>runCont</a> m .
-- f</pre></li>
-- </ul>
withCont :: ((b -> r) -> (a -> r)) -> Cont r a -> Cont r b
-- | The continuation monad transformer. Can be used to add continuation
-- handling to other monads.
newtype ContT r m a
ContT :: ((a -> m r) -> m r) -> ContT r m a
runContT :: ContT r m a -> (a -> m r) -> m r
-- | Apply a function to transform the result of a continuation-passing
-- computation.
--
-- <ul>
-- <li><pre><a>runContT</a> (<a>mapContT</a> f m) = f . <a>runContT</a>
-- m</pre></li>
-- </ul>
mapContT :: (m r -> m r) -> ContT r m a -> ContT r m a
-- | Apply a function to transform the continuation passed to a CPS
-- computation.
--
-- <ul>
-- <li><pre><a>runContT</a> (<a>withContT</a> f m) = <a>runContT</a> m .
-- f</pre></li>
-- </ul>
withContT :: ((b -> m r) -> (a -> m r)) -> ContT r m a -> ContT r m b
-- | <tt>callCC</tt> (call-with-current-continuation) calls its argument
-- function, passing it the current continuation. It provides an escape
-- continuation mechanism for use with continuation monads. Escape
-- continuations one allow to abort the current computation and return a
-- value immediately. They achieve a similar effect to <a>throwError</a>
-- and <a>catchError</a> within an <a>ErrorT</a> monad. The advantage of
-- this function over calling <a>return</a> is that it makes the
-- continuation explicit, allowing more flexibility and better control.
--
-- The standard idiom used with <tt>callCC</tt> is to provide a
-- lambda-expression to name the continuation. Then calling the named
-- continuation anywhere within its scope will escape from the
-- computation, even if it is many layers deep within nested
-- computations.
callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a
-- | <tt><a>liftLocal</a> ask local</tt> yields a <tt>local</tt> function
-- for <tt><a>ContT</a> r m</tt>.
liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a
instance MonadIO m => MonadIO (ContT r m)
instance MonadTrans (ContT r)
instance Monad (ContT r m)
instance Applicative (ContT r m)
instance Functor (ContT r m)
-- | This monad transformer adds the ability to fail or throw exceptions to
-- a monad.
--
-- A sequence of actions succeeds, producing a value, only if all the
-- actions in the sequence are successful. If one fails with an error,
-- the rest of the sequence is skipped and the composite action fails
-- with that error.
--
-- If the value of the error is not required, the variant in
-- <a>Control.Monad.Trans.Maybe</a> may be used instead.
module Control.Monad.Trans.Error
-- | An exception to be thrown.
--
-- Minimal complete definition: <a>noMsg</a> or <a>strMsg</a>.
class Error a where noMsg = strMsg "" strMsg _ = noMsg
noMsg :: Error a => a
strMsg :: Error a => String -> a
-- | Workaround so that we can have a Haskell 98 instance <tt><a>Error</a>
-- <a>String</a></tt>.
class ErrorList a
listMsg :: ErrorList a => String -> [a]
-- | The error monad transformer. It can be used to add error handling to
-- other monads.
--
-- The <tt>ErrorT</tt> Monad structure is parameterized over two things:
--
-- <ul>
-- <li>e - The error type.</li>
-- <li>m - The inner monad.</li>
-- </ul>
--
-- The <a>return</a> function yields a successful computation, while
-- <tt>>>=</tt> sequences two subcomputations, failing on the first
-- error.
newtype ErrorT e m a
ErrorT :: m (Either e a) -> ErrorT e m a
runErrorT :: ErrorT e m a -> m (Either e a)
-- | Map the unwrapped computation using the given function.
--
-- <ul>
-- <li><pre><a>runErrorT</a> (<a>mapErrorT</a> f m) = f (<a>runErrorT</a>
-- m)</pre></li>
-- </ul>
mapErrorT :: (m (Either e a) -> n (Either e' b)) -> ErrorT e m a -> ErrorT e' n b
-- | Signal an error value <tt>e</tt>.
--
-- <ul>
-- <li><pre><a>runErrorT</a> (<a>throwError</a> e) = <a>return</a>
-- (<a>Left</a> e)</pre></li>
-- <li><pre><a>throwError</a> e >>= m = <a>throwError</a>
-- e</pre></li>
-- </ul>
throwError :: (Monad m, Error e) => e -> ErrorT e m a
-- | Handle an error.
--
-- <ul>
-- <li><pre><a>catchError</a> h (<a>lift</a> m) = <a>lift</a>
-- m</pre></li>
-- <li><pre><a>catchError</a> h (<a>throwError</a> e) = h e</pre></li>
-- </ul>
catchError :: (Monad m, Error e) => ErrorT e m a -> (e -> ErrorT e m a) -> ErrorT e m a
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (((Either e a -> m (Either e b)) -> m (Either e a)) -> m (Either e a)) -> ((a -> ErrorT e m b) -> ErrorT e m a) -> ErrorT e m a
-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: Monad m => (m (Either e a) -> m (Either e a, w)) -> ErrorT e m a -> ErrorT e m (a, w)
-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: Monad m => (m (Either e a, w -> w) -> m (Either e a)) -> ErrorT e m (a, w -> w) -> ErrorT e m a
instance (Error e, MonadIO m) => MonadIO (ErrorT e m)
instance Error e => MonadTrans (ErrorT e)
instance (MonadFix m, Error e) => MonadFix (ErrorT e m)
instance (Monad m, Error e) => MonadPlus (ErrorT e m)
instance (Monad m, Error e) => Monad (ErrorT e m)
instance (Functor m, Monad m, Error e) => Alternative (ErrorT e m)
instance (Functor m, Monad m) => Applicative (ErrorT e m)
instance Traversable f => Traversable (ErrorT e f)
instance Foldable f => Foldable (ErrorT e f)
instance Functor m => Functor (ErrorT e m)
instance Error e => MonadPlus (Either e)
instance Error e => Alternative (Either e)
instance ErrorList Char
instance ErrorList a => Error [a]
instance Error IOException
instance MonadPlus IO
-- | The identity monad transformer.
--
-- This is useful for functions parameterized by a monad transformer.
module Control.Monad.Trans.Identity
-- | The trivial monad transformer, which maps a monad to an equivalent
-- monad.
newtype IdentityT m a
IdentityT :: m a -> IdentityT m a
runIdentityT :: IdentityT m a -> m a
-- | Lift a unary operation to the new monad.
mapIdentityT :: (m a -> n b) -> IdentityT m a -> IdentityT n b
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m a -> (e -> m a) -> m a) -> IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (((a -> m b) -> m a) -> m a) -> ((a -> IdentityT m b) -> IdentityT m a) -> IdentityT m a
instance MonadTrans IdentityT
instance MonadIO m => MonadIO (IdentityT m)
instance MonadFix m => MonadFix (IdentityT m)
instance MonadPlus m => MonadPlus (IdentityT m)
instance Monad m => Monad (IdentityT m)
instance Alternative m => Alternative (IdentityT m)
instance Applicative m => Applicative (IdentityT m)
instance Traversable f => Traversable (IdentityT f)
instance Foldable f => Foldable (IdentityT f)
instance Functor m => Functor (IdentityT m)
-- | The ListT monad transformer, adding backtracking to a given monad,
-- which must be commutative.
module Control.Monad.Trans.List
-- | Parameterizable list monad, with an inner monad.
--
-- <i>Note:</i> this does not yield a monad unless the argument monad is
-- commutative.
newtype ListT m a
ListT :: m [a] -> ListT m a
runListT :: ListT m a -> m [a]
-- | Map between <a>ListT</a> computations.
--
-- <ul>
-- <li><pre><a>runListT</a> (<a>mapListT</a> f m) = f (<a>runListT</a>
-- m)</pre></li>
-- </ul>
mapListT :: (m [a] -> n [b]) -> ListT m a -> ListT n b
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: ((([a] -> m [b]) -> m [a]) -> m [a]) -> ((a -> ListT m b) -> ListT m a) -> ListT m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m [a] -> (e -> m [a]) -> m [a]) -> ListT m a -> (e -> ListT m a) -> ListT m a
instance MonadIO m => MonadIO (ListT m)
instance MonadTrans ListT
instance Monad m => MonadPlus (ListT m)
instance Monad m => Monad (ListT m)
instance Applicative m => Alternative (ListT m)
instance Applicative m => Applicative (ListT m)
instance Traversable f => Traversable (ListT f)
instance Foldable f => Foldable (ListT f)
instance Functor m => Functor (ListT m)
-- | The <a>MaybeT</a> monad transformer adds the ability to fail to a
-- monad.
--
-- A sequence of actions succeeds, producing a value, only if all the
-- actions in the sequence are successful. If one fails, the rest of the
-- sequence is skipped and the composite action fails.
--
-- For a variant allowing a range of error values, see
-- <a>Control.Monad.Trans.Error</a>.
module Control.Monad.Trans.Maybe
-- | The parameterizable maybe monad, obtained by composing an arbitrary
-- monad with the <a>Maybe</a> monad.
--
-- Computations are actions that may produce a value or fail.
--
-- The <a>return</a> function yields a successful computation, while
-- <tt>>>=</tt> sequences two subcomputations, failing on the first
-- error.
newtype MaybeT m a
MaybeT :: m (Maybe a) -> MaybeT m a
runMaybeT :: MaybeT m a -> m (Maybe a)
-- | Transform the computation inside a <tt>MaybeT</tt>.
--
-- <ul>
-- <li><pre><a>runMaybeT</a> (<a>mapMaybeT</a> f m) = f (<a>runMaybeT</a>
-- m)</pre></li>
-- </ul>
mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (((Maybe a -> m (Maybe b)) -> m (Maybe a)) -> m (Maybe a)) -> ((a -> MaybeT m b) -> MaybeT m a) -> MaybeT m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (Maybe a) -> (e -> m (Maybe a)) -> m (Maybe a)) -> MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a
-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: Monad m => (m (Maybe a) -> m (Maybe a, w)) -> MaybeT m a -> MaybeT m (a, w)
-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: Monad m => (m (Maybe a, w -> w) -> m (Maybe a)) -> MaybeT m (a, w -> w) -> MaybeT m a
instance MonadIO m => MonadIO (MaybeT m)
instance MonadTrans MaybeT
instance MonadFix m => MonadFix (MaybeT m)
instance Monad m => MonadPlus (MaybeT m)
instance Monad m => Monad (MaybeT m)
instance (Functor m, Monad m) => Alternative (MaybeT m)
instance (Functor m, Monad m) => Applicative (MaybeT m)
instance Traversable f => Traversable (MaybeT f)
instance Foldable f => Foldable (MaybeT f)
instance Functor m => Functor (MaybeT m)
-- | Declaration of the <a>ReaderT</a> monad transformer, which adds a
-- static environment to a given monad.
--
-- If the computation is to modify the stored information, use
-- <a>Control.Monad.Trans.State</a> instead.
module Control.Monad.Trans.Reader
-- | The parameterizable reader monad.
--
-- Computations are functions of a shared environment.
--
-- The <a>return</a> function ignores the environment, while
-- <tt>>>=</tt> passes the inherited environment to both
-- subcomputations.
type Reader r = ReaderT r Identity
-- | Constructor for computations in the reader monad (equivalent to
-- <a>asks</a>).
reader :: Monad m => (r -> a) -> ReaderT r m a
-- | Runs a <tt>Reader</tt> and extracts the final value from it. (The
-- inverse of <a>reader</a>.)
runReader :: Reader r a -> r -> a
-- | Transform the value returned by a <tt>Reader</tt>.
--
-- <ul>
-- <li><pre><a>runReader</a> (<a>mapReader</a> f m) = f .
-- <a>runReader</a> m</pre></li>
-- </ul>
mapReader :: (a -> b) -> Reader r a -> Reader r b
-- | Execute a computation in a modified environment (a specialization of
-- <a>withReaderT</a>).
--
-- <ul>
-- <li><pre><a>runReader</a> (<a>withReader</a> f m) = <a>runReader</a> m
-- . f</pre></li>
-- </ul>
withReader :: (r' -> r) -> Reader r a -> Reader r' a
-- | The reader monad transformer, which adds a read-only environment to
-- the given monad.
--
-- The <a>return</a> function ignores the environment, while
-- <tt>>>=</tt> passes the inherited environment to both
-- subcomputations.
newtype ReaderT r m a
ReaderT :: (r -> m a) -> ReaderT r m a
-- | The underlying computation, as a function of the environment.
runReaderT :: ReaderT r m a -> r -> m a
-- | Transform the computation inside a <tt>ReaderT</tt>.
--
-- <ul>
-- <li><pre><a>runReaderT</a> (<a>mapReaderT</a> f m) = f .
-- <a>runReaderT</a> m</pre></li>
-- </ul>
mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b
-- | Execute a computation in a modified environment (a more general
-- version of <a>local</a>).
--
-- <ul>
-- <li><pre><a>runReaderT</a> (<a>withReaderT</a> f m) =
-- <a>runReaderT</a> m . f</pre></li>
-- </ul>
withReaderT :: (r' -> r) -> ReaderT r m a -> ReaderT r' m a
-- | Fetch the value of the environment.
ask :: Monad m => ReaderT r m r
-- | Execute a computation in a modified environment (a specialization of
-- <a>withReaderT</a>).
--
-- <ul>
-- <li><pre><a>runReaderT</a> (<a>local</a> f m) = <a>runReaderT</a> m .
-- f</pre></li>
-- </ul>
local :: Monad m => (r -> r) -> ReaderT r m a -> ReaderT r m a
-- | Retrieve a function of the current environment.
--
-- <ul>
-- <li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
-- </ul>
asks :: Monad m => (r -> a) -> ReaderT r m a
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (((a -> m b) -> m a) -> m a) -> ((a -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m a -> (e -> m a) -> m a) -> ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a
instance MonadIO m => MonadIO (ReaderT r m)
instance MonadTrans (ReaderT r)
instance MonadFix m => MonadFix (ReaderT r m)
instance MonadPlus m => MonadPlus (ReaderT r m)
instance Monad m => Monad (ReaderT r m)
instance Alternative m => Alternative (ReaderT r m)
instance Applicative m => Applicative (ReaderT r m)
instance Functor m => Functor (ReaderT r m)
-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
-- and <tt>StateT</tt>. This version is lazy; for a strict version, see
-- <a>Control.Monad.Trans.RWS.Strict</a>, which has the same interface.
module Control.Monad.Trans.RWS.Lazy
-- | A monad containing an environment of type <tt>r</tt>, output of type
-- <tt>w</tt> and an updatable state of type <tt>s</tt>.
type RWS r w s = RWST r w s Identity
-- | Construct an RWS computation from a function. (The inverse of
-- <a>runRWS</a>.)
rws :: (r -> s -> (a, s, w)) -> RWS r w s a
-- | Unwrap an RWS computation as a function. (The inverse of <a>rws</a>.)
runRWS :: RWS r w s a -> r -> s -> (a, s, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final value and output, discarding the final state.
evalRWS :: RWS r w s a -> r -> s -> (a, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final state and output, discarding the final value.
execRWS :: RWS r w s a -> r -> s -> (s, w)
-- | Map the return value, final state and output of a computation using
-- the given function.
--
-- <ul>
-- <li><pre><a>runRWS</a> (<a>mapRWS</a> f m) r s = f (<a>runRWS</a> m r
-- s)</pre></li>
-- </ul>
mapRWS :: ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b
-- | <tt><a>withRWS</a> f m</tt> executes action <tt>m</tt> with an initial
-- environment and state modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>runRWS</a> (<a>withRWS</a> f m) r s = <a>uncurry</a>
-- (<a>runRWS</a> m) (f r s)</pre></li>
-- </ul>
withRWS :: (r' -> s -> (r, s)) -> RWS r w s a -> RWS r' w s a
-- | A monad transformer adding reading an environment of type <tt>r</tt>,
-- collecting an output of type <tt>w</tt> and updating a state of type
-- <tt>s</tt> to an inner monad <tt>m</tt>.
newtype RWST r w s m a
RWST :: (r -> s -> m (a, s, w)) -> RWST r w s m a
runRWST :: RWST r w s m a -> r -> s -> m (a, s, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final value and output, discarding the final state.
evalRWST :: Monad m => RWST r w s m a -> r -> s -> m (a, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final state and output, discarding the final value.
execRWST :: Monad m => RWST r w s m a -> r -> s -> m (s, w)
-- | Map the inner computation using the given function.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>mapRWST</a> f m) r s = f (<a>runRWST</a> m
-- r s)</pre></li>
-- </ul>
mapRWST :: (m (a, s, w) -> n (b, s, w')) -> RWST r w s m a -> RWST r w' s n b
-- | <tt><a>withRWST</a> f m</tt> executes action <tt>m</tt> with an
-- initial environment and state modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>withRWST</a> f m) r s = <a>uncurry</a>
-- (<a>runRWST</a> m) (f r s)</pre></li>
-- </ul>
withRWST :: (r' -> s -> (r, s)) -> RWST r w s m a -> RWST r' w s m a
-- | Constructor for computations in the reader monad (equivalent to
-- <a>asks</a>).
reader :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
-- | Fetch the value of the environment.
ask :: (Monoid w, Monad m) => RWST r w s m r
-- | Execute a computation in a modified environment
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>local</a> f m) r s = <a>runRWST</a> m (f
-- r) s</pre></li>
-- </ul>
local :: (Monoid w, Monad m) => (r -> r) -> RWST r w s m a -> RWST r w s m a
-- | Retrieve a function of the current environment.
--
-- <ul>
-- <li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
-- </ul>
asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
-- | Construct a writer computation from a (result, output) pair.
writer :: Monad m => (a, w) -> RWST r w s m a
-- | <tt><a>tell</a> w</tt> is an action that produces the output
-- <tt>w</tt>.
tell :: (Monoid w, Monad m) => w -> RWST r w s m ()
-- | <tt><a>listen</a> m</tt> is an action that executes the action
-- <tt>m</tt> and adds its output to the value of the computation.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>listen</a> m) r s = <a>liftM</a> (\(a, w)
-- -> ((a, w), w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
listen :: (Monoid w, Monad m) => RWST r w s m a -> RWST r w s m (a, w)
-- | <tt><a>listens</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
-- the value of the computation.
--
-- <ul>
-- <li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
-- m)</pre></li>
-- <li><pre><a>runRWST</a> (<a>listens</a> f m) r s = <a>liftM</a> (\(a,
-- w) -> ((a, f w), w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
listens :: (Monoid w, Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)
-- | <tt><a>pass</a> m</tt> is an action that executes the action
-- <tt>m</tt>, which returns a value and a function, and returns the
-- value, applying the function to the output.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>pass</a> m) r s = <a>liftM</a> (\((a, f),
-- w) -> (a, f w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
pass :: (Monoid w, Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a
-- | <tt><a>censor</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
-- the return value unchanged.
--
-- <ul>
-- <li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\x ->
-- (x,f)) m)</pre></li>
-- <li><pre><a>runRWST</a> (<a>censor</a> f m) r s = <a>liftM</a> (\(a,
-- w) -> (a, f w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
censor :: (Monoid w, Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a
-- | Construct a state monad computation from a state transformer function.
state :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a
-- | Fetch the current value of the state within the monad.
get :: (Monoid w, Monad m) => RWST r w s m s
-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monoid w, Monad m) => s -> RWST r w s m ()
-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
-- result of applying <tt>f</tt> to the current state.
--
-- <ul>
-- <li><pre><a>modify</a> f = <a>get</a> >>= (<a>put</a> .
-- f)</pre></li>
-- </ul>
modify :: (Monoid w, Monad m) => (s -> s) -> RWST r w s m ()
-- | Get a specific component of the state, using a projection function
-- supplied.
--
-- <ul>
-- <li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
-- </ul>
gets :: (Monoid w, Monad m) => (s -> a) -> RWST r w s m a
-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
-- version rolls back to the original state on entering the continuation.
liftCallCC :: Monoid w => ((((a, s, w) -> m (b, s, w)) -> m (a, s, w)) -> m (a, s, w)) -> ((a -> RWST r w s m b) -> RWST r w s m a) -> RWST r w s m a
-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
-- version uses the current state on entering the continuation.
liftCallCC' :: Monoid w => ((((a, s, w) -> m (b, s, w)) -> m (a, s, w)) -> m (a, s, w)) -> ((a -> RWST r w s m b) -> RWST r w s m a) -> RWST r w s m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, s, w) -> (e -> m (a, s, w)) -> m (a, s, w)) -> RWST l w s m a -> (e -> RWST l w s m a) -> RWST l w s m a
instance (Monoid w, MonadIO m) => MonadIO (RWST r w s m)
instance Monoid w => MonadTrans (RWST r w s)
instance (Monoid w, MonadFix m) => MonadFix (RWST r w s m)
instance (Monoid w, MonadPlus m) => MonadPlus (RWST r w s m)
instance (Monoid w, Monad m) => Monad (RWST r w s m)
instance (Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)
instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m)
instance Functor m => Functor (RWST r w s m)
-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
-- and <tt>StateT</tt>. This version is lazy; for a strict version, see
-- <a>Control.Monad.Trans.RWS.Strict</a>, which has the same interface.
module Control.Monad.Trans.RWS
-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
-- and <tt>StateT</tt>. This version is strict; for a lazy version, see
-- <a>Control.Monad.Trans.RWS.Lazy</a>, which has the same interface.
module Control.Monad.Trans.RWS.Strict
-- | A monad containing an environment of type <tt>r</tt>, output of type
-- <tt>w</tt> and an updatable state of type <tt>s</tt>.
type RWS r w s = RWST r w s Identity
-- | Construct an RWS computation from a function. (The inverse of
-- <a>runRWS</a>.)
rws :: (r -> s -> (a, s, w)) -> RWS r w s a
-- | Unwrap an RWS computation as a function. (The inverse of <a>rws</a>.)
runRWS :: RWS r w s a -> r -> s -> (a, s, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final value and output, discarding the final state.
evalRWS :: RWS r w s a -> r -> s -> (a, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final state and output, discarding the final value.
execRWS :: RWS r w s a -> r -> s -> (s, w)
-- | Map the return value, final state and output of a computation using
-- the given function.
--
-- <ul>
-- <li><pre><a>runRWS</a> (<a>mapRWS</a> f m) r s = f (<a>runRWS</a> m r
-- s)</pre></li>
-- </ul>
mapRWS :: ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b
-- | <tt><a>withRWS</a> f m</tt> executes action <tt>m</tt> with an initial
-- environment and state modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>runRWS</a> (<a>withRWS</a> f m) r s = <a>uncurry</a>
-- (<a>runRWS</a> m) (f r s)</pre></li>
-- </ul>
withRWS :: (r' -> s -> (r, s)) -> RWS r w s a -> RWS r' w s a
-- | A monad transformer adding reading an environment of type <tt>r</tt>,
-- collecting an output of type <tt>w</tt> and updating a state of type
-- <tt>s</tt> to an inner monad <tt>m</tt>.
newtype RWST r w s m a
RWST :: (r -> s -> m (a, s, w)) -> RWST r w s m a
runRWST :: RWST r w s m a -> r -> s -> m (a, s, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final value and output, discarding the final state.
evalRWST :: Monad m => RWST r w s m a -> r -> s -> m (a, w)
-- | Evaluate a computation with the given initial state and environment,
-- returning the final state and output, discarding the final value.
execRWST :: Monad m => RWST r w s m a -> r -> s -> m (s, w)
-- | Map the inner computation using the given function.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>mapRWST</a> f m) r s = f (<a>runRWST</a> m
-- r s)</pre></li>
-- </ul>
mapRWST :: (m (a, s, w) -> n (b, s, w')) -> RWST r w s m a -> RWST r w' s n b
-- | <tt><a>withRWST</a> f m</tt> executes action <tt>m</tt> with an
-- initial environment and state modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>withRWST</a> f m) r s = <a>uncurry</a>
-- (<a>runRWST</a> m) (f r s)</pre></li>
-- </ul>
withRWST :: (r' -> s -> (r, s)) -> RWST r w s m a -> RWST r' w s m a
-- | Constructor for computations in the reader monad (equivalent to
-- <a>asks</a>).
reader :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
-- | Fetch the value of the environment.
ask :: (Monoid w, Monad m) => RWST r w s m r
-- | Execute a computation in a modified environment
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>local</a> f m) r s = <a>runRWST</a> m (f
-- r) s</pre></li>
-- </ul>
local :: (Monoid w, Monad m) => (r -> r) -> RWST r w s m a -> RWST r w s m a
-- | Retrieve a function of the current environment.
--
-- <ul>
-- <li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
-- </ul>
asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
-- | Construct a writer computation from a (result, output) pair.
writer :: Monad m => (a, w) -> RWST r w s m a
-- | <tt><a>tell</a> w</tt> is an action that produces the output
-- <tt>w</tt>.
tell :: (Monoid w, Monad m) => w -> RWST r w s m ()
-- | <tt><a>listen</a> m</tt> is an action that executes the action
-- <tt>m</tt> and adds its output to the value of the computation.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>listen</a> m) r s = <a>liftM</a> (\(a, w)
-- -> ((a, w), w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
listen :: (Monoid w, Monad m) => RWST r w s m a -> RWST r w s m (a, w)
-- | <tt><a>listens</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
-- the value of the computation.
--
-- <ul>
-- <li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
-- m)</pre></li>
-- <li><pre><a>runRWST</a> (<a>listens</a> f m) r s = <a>liftM</a> (\(a,
-- w) -> ((a, f w), w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
listens :: (Monoid w, Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)
-- | <tt><a>pass</a> m</tt> is an action that executes the action
-- <tt>m</tt>, which returns a value and a function, and returns the
-- value, applying the function to the output.
--
-- <ul>
-- <li><pre><a>runRWST</a> (<a>pass</a> m) r s = <a>liftM</a> (\((a, f),
-- w) -> (a, f w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
pass :: (Monoid w, Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a
-- | <tt><a>censor</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
-- the return value unchanged.
--
-- <ul>
-- <li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\x ->
-- (x,f)) m)</pre></li>
-- <li><pre><a>runRWST</a> (<a>censor</a> f m) r s = <a>liftM</a> (\(a,
-- w) -> (a, f w)) (<a>runRWST</a> m r s)</pre></li>
-- </ul>
censor :: (Monoid w, Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a
-- | Construct a state monad computation from a state transformer function.
state :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a
-- | Fetch the current value of the state within the monad.
get :: (Monoid w, Monad m) => RWST r w s m s
-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monoid w, Monad m) => s -> RWST r w s m ()
-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
-- result of applying <tt>f</tt> to the current state.
--
-- <ul>
-- <li><pre><a>modify</a> f = <a>get</a> >>= (<a>put</a> .
-- f)</pre></li>
-- </ul>
modify :: (Monoid w, Monad m) => (s -> s) -> RWST r w s m ()
-- | Get a specific component of the state, using a projection function
-- supplied.
--
-- <ul>
-- <li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
-- </ul>
gets :: (Monoid w, Monad m) => (s -> a) -> RWST r w s m a
-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
-- version rolls back to the original state on entering the continuation.
liftCallCC :: Monoid w => ((((a, s, w) -> m (b, s, w)) -> m (a, s, w)) -> m (a, s, w)) -> ((a -> RWST r w s m b) -> RWST r w s m a) -> RWST r w s m a
-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
-- version uses the current state on entering the continuation.
liftCallCC' :: Monoid w => ((((a, s, w) -> m (b, s, w)) -> m (a, s, w)) -> m (a, s, w)) -> ((a -> RWST r w s m b) -> RWST r w s m a) -> RWST r w s m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, s, w) -> (e -> m (a, s, w)) -> m (a, s, w)) -> RWST l w s m a -> (e -> RWST l w s m a) -> RWST l w s m a
instance (Monoid w, MonadIO m) => MonadIO (RWST r w s m)
instance Monoid w => MonadTrans (RWST r w s)
instance (Monoid w, MonadFix m) => MonadFix (RWST r w s m)
instance (Monoid w, MonadPlus m) => MonadPlus (RWST r w s m)
instance (Monoid w, Monad m) => Monad (RWST r w s m)
instance (Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)
instance (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m)
instance Functor m => Functor (RWST r w s m)
-- | Lazy state monads, passing an updatable state through a computation.
-- See below for examples.
--
-- In this version, sequencing of computations is lazy. For a strict
-- version, see <a>Control.Monad.Trans.State.Strict</a>, which has the
-- same interface.
--
-- Some computations may not require the full power of state
-- transformers:
--
-- <ul>
-- <li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
-- <li>To accumulate a value without using it on the way, see
-- <a>Control.Monad.Trans.Writer</a>.</li>
-- </ul>
module Control.Monad.Trans.State.Lazy
-- | A state monad parameterized by the type <tt>s</tt> of the state to
-- carry.
--
-- The <a>return</a> function leaves the state unchanged, while
-- <tt>>>=</tt> uses the final state of the first computation as
-- the initial state of the second.
type State s = StateT s Identity
-- | Construct a state monad computation from a function. (The inverse of
-- <a>runState</a>.)
state :: Monad m => (s -> (a, s)) -> StateT s m a
-- | Unwrap a state monad computation as a function. (The inverse of
-- <a>state</a>.)
runState :: State s a -> s -> (a, s)
-- | Evaluate a state computation with the given initial state and return
-- the final value, discarding the final state.
--
-- <ul>
-- <li><pre><a>evalState</a> m s = <a>fst</a> (<a>runState</a> m
-- s)</pre></li>
-- </ul>
evalState :: State s a -> s -> a
-- | Evaluate a state computation with the given initial state and return
-- the final state, discarding the final value.
--
-- <ul>
-- <li><pre><a>execState</a> m s = <a>snd</a> (<a>runState</a> m
-- s)</pre></li>
-- </ul>
execState :: State s a -> s -> s
-- | Map both the return value and final state of a computation using the
-- given function.
--
-- <ul>
-- <li><pre><a>runState</a> (<a>mapState</a> f m) = f . <a>runState</a>
-- m</pre></li>
-- </ul>
mapState :: ((a, s) -> (b, s)) -> State s a -> State s b
-- | <tt><a>withState</a> f m</tt> executes action <tt>m</tt> on a state
-- modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>withState</a> f m = <a>modify</a> f >> m</pre></li>
-- </ul>
withState :: (s -> s) -> State s a -> State s a
-- | A state transformer monad parameterized by:
--
-- <ul>
-- <li><tt>s</tt> - The state.</li>
-- <li><tt>m</tt> - The inner monad.</li>
-- </ul>
--
-- The <a>return</a> function leaves the state unchanged, while
-- <tt>>>=</tt> uses the final state of the first computation as
-- the initial state of the second.
newtype StateT s m a
StateT :: (s -> m (a, s)) -> StateT s m a
runStateT :: StateT s m a -> s -> m (a, s)
-- | Evaluate a state computation with the given initial state and return
-- the final value, discarding the final state.
--
-- <ul>
-- <li><pre><a>evalStateT</a> m s = <a>liftM</a> <a>fst</a>
-- (<a>runStateT</a> m s)</pre></li>
-- </ul>
evalStateT :: Monad m => StateT s m a -> s -> m a
-- | Evaluate a state computation with the given initial state and return
-- the final state, discarding the final value.
--
-- <ul>
-- <li><pre><a>execStateT</a> m s = <a>liftM</a> <a>snd</a>
-- (<a>runStateT</a> m s)</pre></li>
-- </ul>
execStateT :: Monad m => StateT s m a -> s -> m s
-- | Map both the return value and final state of a computation using the
-- given function.
--
-- <ul>
-- <li><pre><a>runStateT</a> (<a>mapStateT</a> f m) = f .
-- <a>runStateT</a> m</pre></li>
-- </ul>
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
-- | <tt><a>withStateT</a> f m</tt> executes action <tt>m</tt> on a state
-- modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>withStateT</a> f m = <a>modify</a> f >> m</pre></li>
-- </ul>
withStateT :: (s -> s) -> StateT s m a -> StateT s m a
-- | Fetch the current value of the state within the monad.
get :: Monad m => StateT s m s
-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: Monad m => s -> StateT s m ()
-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
-- result of applying <tt>f</tt> to the current state.
--
-- <ul>
-- <li><pre><a>modify</a> f = <a>get</a> >>= (<a>put</a> .
-- f)</pre></li>
-- </ul>
modify :: Monad m => (s -> s) -> StateT s m ()
-- | Get a specific component of the state, using a projection function
-- supplied.
--
-- <ul>
-- <li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
-- </ul>
gets :: Monad m => (s -> a) -> StateT s m a
-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
-- version rolls back to the original state on entering the continuation.
liftCallCC :: ((((a, s) -> m (b, s)) -> m (a, s)) -> m (a, s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a
-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
-- version uses the current state on entering the continuation. It does
-- not satisfy the laws of a monad transformer.
liftCallCC' :: ((((a, s) -> m (b, s)) -> m (a, s)) -> m (a, s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, s) -> (e -> m (a, s)) -> m (a, s)) -> StateT s m a -> (e -> StateT s m a) -> StateT s m a
-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: Monad m => (m (a, s) -> m ((a, s), w)) -> StateT s m a -> StateT s m (a, w)
-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: Monad m => (m ((a, s), b) -> m (a, s)) -> StateT s m (a, b) -> StateT s m a
instance MonadIO m => MonadIO (StateT s m)
instance MonadTrans (StateT s)
instance MonadFix m => MonadFix (StateT s m)
instance MonadPlus m => MonadPlus (StateT s m)
instance Monad m => Monad (StateT s m)
instance (Functor m, MonadPlus m) => Alternative (StateT s m)
instance (Functor m, Monad m) => Applicative (StateT s m)
instance Functor m => Functor (StateT s m)
-- | State monads, passing an updatable state through a computation.
--
-- Some computations may not require the full power of state
-- transformers:
--
-- <ul>
-- <li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
-- <li>To accumulate a value without using it on the way, see
-- <a>Control.Monad.Trans.Writer</a>.</li>
-- </ul>
--
-- This version is lazy; for a strict version, see
-- <a>Control.Monad.Trans.State.Strict</a>, which has the same interface.
module Control.Monad.Trans.State
-- | Strict state monads, passing an updatable state through a computation.
-- See below for examples.
--
-- In this version, sequencing of computations is strict. For a lazy
-- version, see <a>Control.Monad.Trans.State.Lazy</a>, which has the same
-- interface.
--
-- Some computations may not require the full power of state
-- transformers:
--
-- <ul>
-- <li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
-- <li>To accumulate a value without using it on the way, see
-- <a>Control.Monad.Trans.Writer</a>.</li>
-- </ul>
module Control.Monad.Trans.State.Strict
-- | A state monad parameterized by the type <tt>s</tt> of the state to
-- carry.
--
-- The <a>return</a> function leaves the state unchanged, while
-- <tt>>>=</tt> uses the final state of the first computation as
-- the initial state of the second.
type State s = StateT s Identity
-- | Construct a state monad computation from a function. (The inverse of
-- <a>runState</a>.)
state :: Monad m => (s -> (a, s)) -> StateT s m a
-- | Unwrap a state monad computation as a function. (The inverse of
-- <a>state</a>.)
runState :: State s a -> s -> (a, s)
-- | Evaluate a state computation with the given initial state and return
-- the final value, discarding the final state.
--
-- <ul>
-- <li><pre><a>evalState</a> m s = <a>fst</a> (<a>runState</a> m
-- s)</pre></li>
-- </ul>
evalState :: State s a -> s -> a
-- | Evaluate a state computation with the given initial state and return
-- the final state, discarding the final value.
--
-- <ul>
-- <li><pre><a>execState</a> m s = <a>snd</a> (<a>runState</a> m
-- s)</pre></li>
-- </ul>
execState :: State s a -> s -> s
-- | Map both the return value and final state of a computation using the
-- given function.
--
-- <ul>
-- <li><pre><a>runState</a> (<a>mapState</a> f m) = f . <a>runState</a>
-- m</pre></li>
-- </ul>
mapState :: ((a, s) -> (b, s)) -> State s a -> State s b
-- | <tt><a>withState</a> f m</tt> executes action <tt>m</tt> on a state
-- modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>withState</a> f m = <a>modify</a> f >> m</pre></li>
-- </ul>
withState :: (s -> s) -> State s a -> State s a
-- | A state transformer monad parameterized by:
--
-- <ul>
-- <li><tt>s</tt> - The state.</li>
-- <li><tt>m</tt> - The inner monad.</li>
-- </ul>
--
-- The <a>return</a> function leaves the state unchanged, while
-- <tt>>>=</tt> uses the final state of the first computation as
-- the initial state of the second.
newtype StateT s m a
StateT :: (s -> m (a, s)) -> StateT s m a
runStateT :: StateT s m a -> s -> m (a, s)
-- | Evaluate a state computation with the given initial state and return
-- the final value, discarding the final state.
--
-- <ul>
-- <li><pre><a>evalStateT</a> m s = <a>liftM</a> <a>fst</a>
-- (<a>runStateT</a> m s)</pre></li>
-- </ul>
evalStateT :: Monad m => StateT s m a -> s -> m a
-- | Evaluate a state computation with the given initial state and return
-- the final state, discarding the final value.
--
-- <ul>
-- <li><pre><a>execStateT</a> m s = <a>liftM</a> <a>snd</a>
-- (<a>runStateT</a> m s)</pre></li>
-- </ul>
execStateT :: Monad m => StateT s m a -> s -> m s
-- | Map both the return value and final state of a computation using the
-- given function.
--
-- <ul>
-- <li><pre><a>runStateT</a> (<a>mapStateT</a> f m) = f .
-- <a>runStateT</a> m</pre></li>
-- </ul>
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
-- | <tt><a>withStateT</a> f m</tt> executes action <tt>m</tt> on a state
-- modified by applying <tt>f</tt>.
--
-- <ul>
-- <li><pre><a>withStateT</a> f m = <a>modify</a> f >> m</pre></li>
-- </ul>
withStateT :: (s -> s) -> StateT s m a -> StateT s m a
-- | Fetch the current value of the state within the monad.
get :: Monad m => StateT s m s
-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: Monad m => s -> StateT s m ()
-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
-- result of applying <tt>f</tt> to the current state.
--
-- <ul>
-- <li><pre><a>modify</a> f = <a>get</a> >>= (<a>put</a> .
-- f)</pre></li>
-- </ul>
modify :: Monad m => (s -> s) -> StateT s m ()
-- | Get a specific component of the state, using a projection function
-- supplied.
--
-- <ul>
-- <li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
-- </ul>
gets :: Monad m => (s -> a) -> StateT s m a
-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
-- version rolls back to the original state on entering the continuation.
liftCallCC :: ((((a, s) -> m (b, s)) -> m (a, s)) -> m (a, s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a
-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
-- version uses the current state on entering the continuation. It does
-- not satisfy the laws of a monad transformer.
liftCallCC' :: ((((a, s) -> m (b, s)) -> m (a, s)) -> m (a, s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, s) -> (e -> m (a, s)) -> m (a, s)) -> StateT s m a -> (e -> StateT s m a) -> StateT s m a
-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: Monad m => (m (a, s) -> m ((a, s), w)) -> StateT s m a -> StateT s m (a, w)
-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: Monad m => (m ((a, s), b) -> m (a, s)) -> StateT s m (a, b) -> StateT s m a
instance MonadIO m => MonadIO (StateT s m)
instance MonadTrans (StateT s)
instance MonadFix m => MonadFix (StateT s m)
instance MonadPlus m => MonadPlus (StateT s m)
instance Monad m => Monad (StateT s m)
instance (Functor m, MonadPlus m) => Alternative (StateT s m)
instance (Functor m, Monad m) => Applicative (StateT s m)
instance Functor m => Functor (StateT s m)
-- | The lazy <a>WriterT</a> monad transformer, which adds collection of
-- outputs (such as a count or string output) to a given monad.
--
-- This version builds its output lazily; for a strict version, see
-- <a>Control.Monad.Trans.Writer.Strict</a>, which has the same
-- interface.
--
-- This monad transformer provides only limited access to the output
-- during the computation. For more general access, use
-- <a>Control.Monad.Trans.State</a> instead.
module Control.Monad.Trans.Writer.Lazy
-- | A writer monad parameterized by the type <tt>w</tt> of output to
-- accumulate.
--
-- The <a>return</a> function produces the output <a>mempty</a>, while
-- <tt>>>=</tt> combines the outputs of the subcomputations using
-- <a>mappend</a>.
type Writer w = WriterT w Identity
-- | Construct a writer computation from a (result, output) pair. (The
-- inverse of <a>runWriter</a>.)
writer :: Monad m => (a, w) -> WriterT w m a
-- | Unwrap a writer computation as a (result, output) pair. (The inverse
-- of <a>writer</a>.)
runWriter :: Writer w a -> (a, w)
-- | Extract the output from a writer computation.
--
-- <ul>
-- <li><pre><a>execWriter</a> m = <a>snd</a> (<a>runWriter</a>
-- m)</pre></li>
-- </ul>
execWriter :: Writer w a -> w
-- | Map both the return value and output of a computation using the given
-- function.
--
-- <ul>
-- <li><pre><a>runWriter</a> (<a>mapWriter</a> f m) = f (<a>runWriter</a>
-- m)</pre></li>
-- </ul>
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b
-- | A writer monad parameterized by:
--
-- <ul>
-- <li><tt>w</tt> - the output to accumulate.</li>
-- <li><tt>m</tt> - The inner monad.</li>
-- </ul>
--
-- The <a>return</a> function produces the output <a>mempty</a>, while
-- <tt>>>=</tt> combines the outputs of the subcomputations using
-- <a>mappend</a>.
newtype WriterT w m a
WriterT :: m (a, w) -> WriterT w m a
runWriterT :: WriterT w m a -> m (a, w)
-- | Extract the output from a writer computation.
--
-- <ul>
-- <li><pre><a>execWriterT</a> m = <a>liftM</a> <a>snd</a>
-- (<a>runWriterT</a> m)</pre></li>
-- </ul>
execWriterT :: Monad m => WriterT w m a -> m w
-- | Map both the return value and output of a computation using the given
-- function.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>mapWriterT</a> f m) = f
-- (<a>runWriterT</a> m)</pre></li>
-- </ul>
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
-- | <tt><a>tell</a> w</tt> is an action that produces the output
-- <tt>w</tt>.
tell :: (Monoid w, Monad m) => w -> WriterT w m ()
-- | <tt><a>listen</a> m</tt> is an action that executes the action
-- <tt>m</tt> and adds its output to the value of the computation.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>listen</a> m) = <a>liftM</a> (\(a, w)
-- -> ((a, w), w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
listen :: (Monoid w, Monad m) => WriterT w m a -> WriterT w m (a, w)
-- | <tt><a>listens</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
-- the value of the computation.
--
-- <ul>
-- <li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
-- m)</pre></li>
-- <li><pre><a>runWriterT</a> (<a>listens</a> f m) = <a>liftM</a> (\(a,
-- w) -> ((a, f w), w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
listens :: (Monoid w, Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)
-- | <tt><a>pass</a> m</tt> is an action that executes the action
-- <tt>m</tt>, which returns a value and a function, and returns the
-- value, applying the function to the output.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>pass</a> m) = <a>liftM</a> (\((a, f),
-- w) -> (a, f w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
pass :: (Monoid w, Monad m) => WriterT w m (a, w -> w) -> WriterT w m a
-- | <tt><a>censor</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
-- the return value unchanged.
--
-- <ul>
-- <li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\x ->
-- (x,f)) m)</pre></li>
-- <li><pre><a>runWriterT</a> (<a>censor</a> f m) = <a>liftM</a> (\(a, w)
-- -> (a, f w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
censor :: (Monoid w, Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: Monoid w => ((((a, w) -> m (b, w)) -> m (a, w)) -> m (a, w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, w) -> (e -> m (a, w)) -> m (a, w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a
instance Traversable f => Traversable (WriterT w f)
instance Foldable f => Foldable (WriterT w f)
instance (Monoid w, MonadIO m) => MonadIO (WriterT w m)
instance Monoid w => MonadTrans (WriterT w)
instance (Monoid w, MonadFix m) => MonadFix (WriterT w m)
instance (Monoid w, MonadPlus m) => MonadPlus (WriterT w m)
instance (Monoid w, Monad m) => Monad (WriterT w m)
instance (Monoid w, Alternative m) => Alternative (WriterT w m)
instance (Monoid w, Applicative m) => Applicative (WriterT w m)
instance Functor m => Functor (WriterT w m)
-- | The WriterT monad transformer. This version is lazy; for a strict
-- version, see <a>Control.Monad.Trans.Writer.Strict</a>, which has the
-- same interface.
module Control.Monad.Trans.Writer
-- | The strict <a>WriterT</a> monad transformer, which adds collection of
-- outputs (such as a count or string output) to a given monad.
--
-- This version builds its output strictly; for a lazy version, see
-- <a>Control.Monad.Trans.Writer.Lazy</a>, which has the same interface.
--
-- This monad transformer provides only limited access to the output
-- during the computation. For more general access, use
-- <a>Control.Monad.Trans.State</a> instead.
module Control.Monad.Trans.Writer.Strict
-- | A writer monad parameterized by the type <tt>w</tt> of output to
-- accumulate.
--
-- The <a>return</a> function produces the output <a>mempty</a>, while
-- <tt>>>=</tt> combines the outputs of the subcomputations using
-- <a>mappend</a>.
type Writer w = WriterT w Identity
-- | Construct a writer computation from a (result, output) pair. (The
-- inverse of <a>runWriter</a>.)
writer :: Monad m => (a, w) -> WriterT w m a
-- | Unwrap a writer computation as a (result, output) pair. (The inverse
-- of <a>writer</a>.)
runWriter :: Writer w a -> (a, w)
-- | Extract the output from a writer computation.
--
-- <ul>
-- <li><pre><a>execWriter</a> m = <a>snd</a> (<a>runWriter</a>
-- m)</pre></li>
-- </ul>
execWriter :: Writer w a -> w
-- | Map both the return value and output of a computation using the given
-- function.
--
-- <ul>
-- <li><pre><a>runWriter</a> (<a>mapWriter</a> f m) = f (<a>runWriter</a>
-- m)</pre></li>
-- </ul>
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b
-- | A writer monad parameterized by:
--
-- <ul>
-- <li><tt>w</tt> - the output to accumulate.</li>
-- <li><tt>m</tt> - The inner monad.</li>
-- </ul>
--
-- The <a>return</a> function produces the output <a>mempty</a>, while
-- <tt>>>=</tt> combines the outputs of the subcomputations using
-- <a>mappend</a>.
newtype WriterT w m a
WriterT :: m (a, w) -> WriterT w m a
runWriterT :: WriterT w m a -> m (a, w)
-- | Extract the output from a writer computation.
--
-- <ul>
-- <li><pre><a>execWriterT</a> m = <a>liftM</a> <a>snd</a>
-- (<a>runWriterT</a> m)</pre></li>
-- </ul>
execWriterT :: Monad m => WriterT w m a -> m w
-- | Map both the return value and output of a computation using the given
-- function.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>mapWriterT</a> f m) = f
-- (<a>runWriterT</a> m)</pre></li>
-- </ul>
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
-- | <tt><a>tell</a> w</tt> is an action that produces the output
-- <tt>w</tt>.
tell :: (Monoid w, Monad m) => w -> WriterT w m ()
-- | <tt><a>listen</a> m</tt> is an action that executes the action
-- <tt>m</tt> and adds its output to the value of the computation.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>listen</a> m) = <a>liftM</a> (\(a, w)
-- -> ((a, w), w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
listen :: (Monoid w, Monad m) => WriterT w m a -> WriterT w m (a, w)
-- | <tt><a>listens</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
-- the value of the computation.
--
-- <ul>
-- <li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
-- m)</pre></li>
-- <li><pre><a>runWriterT</a> (<a>listens</a> f m) = <a>liftM</a> (\(a,
-- w) -> ((a, f w), w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
listens :: (Monoid w, Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)
-- | <tt><a>pass</a> m</tt> is an action that executes the action
-- <tt>m</tt>, which returns a value and a function, and returns the
-- value, applying the function to the output.
--
-- <ul>
-- <li><pre><a>runWriterT</a> (<a>pass</a> m) = <a>liftM</a> (\((a, f),
-- w) -> (a, f w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
pass :: (Monoid w, Monad m) => WriterT w m (a, w -> w) -> WriterT w m a
-- | <tt><a>censor</a> f m</tt> is an action that executes the action
-- <tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
-- the return value unchanged.
--
-- <ul>
-- <li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\x ->
-- (x,f)) m)</pre></li>
-- <li><pre><a>runWriterT</a> (<a>censor</a> f m) = <a>liftM</a> (\(a, w)
-- -> (a, f w)) (<a>runWriterT</a> m)</pre></li>
-- </ul>
censor :: (Monoid w, Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a
-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: Monoid w => ((((a, w) -> m (b, w)) -> m (a, w)) -> m (a, w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m a
-- | Lift a <tt>catchError</tt> operation to the new monad.
liftCatch :: (m (a, w) -> (e -> m (a, w)) -> m (a, w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a
instance (Monoid w, MonadIO m) => MonadIO (WriterT w m)
instance Monoid w => MonadTrans (WriterT w)
instance (Monoid w, MonadFix m) => MonadFix (WriterT w m)
instance (Monoid w, MonadPlus m) => MonadPlus (WriterT w m)
instance (Monoid w, Monad m) => Monad (WriterT w m)
instance (Monoid w, Alternative m) => Alternative (WriterT w m)
instance (Monoid w, Applicative m) => Applicative (WriterT w m)
instance Traversable f => Traversable (WriterT w f)
instance Foldable f => Foldable (WriterT w f)
instance Functor m => Functor (WriterT w m)
-- | The constant functor.
module Data.Functor.Constant
-- | Constant functor.
newtype Constant a b
Constant :: a -> Constant a b
getConstant :: Constant a b -> a
instance Monoid a => Applicative (Constant a)
instance Traversable (Constant a)
instance Foldable (Constant a)
instance Functor (Constant a)
-- | Adding a new kind of pure computation to an applicative functor.
module Control.Applicative.Lift
-- | Applicative functor formed by adding pure computations to a given
-- applicative functor.
data Lift f a
Pure :: a -> Lift f a
Other :: (f a) -> Lift f a
-- | Projection to the other functor.
unLift :: Applicative f => Lift f a -> f a
-- | An applicative functor that collects a monoid (e.g. lists) of errors.
-- A sequence of computations fails if any of its components do, but
-- unlike monads made with <tt>ErrorT</tt> from
-- <a>Control.Monad.Trans.Error</a>, these computations continue after an
-- error, collecting all the errors.
type Errors e = Lift (Constant e)
-- | Report an error.
failure :: Monoid e => e -> Errors e a
instance Alternative f => Alternative (Lift f)
instance Applicative f => Applicative (Lift f)
instance Traversable f => Traversable (Lift f)
instance Foldable f => Foldable (Lift f)
instance Functor f => Functor (Lift f)
-- | Making functors with an <a>Applicative</a> instance that performs
-- actions in the reverse order.
module Control.Applicative.Backwards
-- | The same functor, but with an <a>Applicative</a> instance that
-- performs actions in the reverse order.
newtype Backwards f a
Backwards :: f a -> Backwards f a
forwards :: Backwards f a -> f a
instance Traversable f => Traversable (Backwards f)
instance Foldable f => Foldable (Backwards f)
instance Alternative f => Alternative (Backwards f)
instance Applicative f => Applicative (Backwards f)
instance Functor f => Functor (Backwards f)
-- | Making functors whose elements are notionally in the reverse order
-- from the original functor.
module Data.Functor.Reverse
-- | The same functor, but with <a>Foldable</a> and <a>Traversable</a>
-- instances that process the elements in the reverse order.
newtype Reverse f a
Reverse :: f a -> Reverse f a
getReverse :: Reverse f a -> f a
instance Traversable f => Traversable (Reverse f)
instance Foldable f => Foldable (Reverse f)
instance Alternative f => Alternative (Reverse f)
instance Applicative f => Applicative (Reverse f)
instance Functor f => Functor (Reverse f)
|