Portability | MTPCs, FDs, Rank2 |
---|---|

Stability | experimental |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Inferred |

- type Action m s a = forall f r. Effective m r f => (a -> f a) -> s -> f s
- act :: Monad m => (s -> m a) -> Action m s a
- acts :: Action m (m a) a
- perform :: Monad m => Acting m a s t a b -> s -> m a
- performs :: Monad m => Acting m e s t a b -> (a -> e) -> s -> m e
- liftAct :: (MonadTrans trans, Monad m) => Acting m a s t a b -> Action (trans m) s a
- (^!) :: Monad m => s -> Acting m a s t a b -> m a
- type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f s
- type Acting m r s t a b = (a -> Effect m r b) -> s -> Effect m r t

# Composable Actions

act :: Monad m => (s -> m a) -> Action m s aSource

Construct an `Action`

from a monadic side-effect

`>>>`

["helloworld","helloworld!","hello!world","hello!world!"]`["hello","world"]^!folded.act (\x -> [x,x ++ "!"])`

performs :: Monad m => Acting m e s t a b -> (a -> e) -> s -> m eSource

Perform an `Action`

and modify the result.

(^!) :: Monad m => s -> Acting m a s t a b -> m aSource

Perform an `Action`

`>>>`

hello world`["hello","world"]^!folded.act putStrLn`

# Folds with Effects

type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f sSource

A `MonadicFold`

is a `Fold`

enriched with access to a `Monad`

for side-effects.

Every `Fold`

can be used as a `MonadicFold`

, that simply ignores the access to the `Monad`

.

You can compose a `MonadicFold`

with another `MonadicFold`

using (`.`

) from the `Prelude`

.