diff --git a/docs/Module.md b/docs/Module.md index c2b49d3b..91ea8b48 100644 --- a/docs/Module.md +++ b/docs/Module.md @@ -2,789 +2,1824 @@ ## Module Control.Comonad.Env -### Types +#### `Env` - type Env e = EnvT e Identity +``` purescript +type Env e = EnvT e Identity +``` -### Values +#### `runEnv` - env :: forall e a. e -> a -> Env e a +``` purescript +runEnv :: forall e a. Env e a -> Tuple e a +``` - mapEnv :: forall e a b. (a -> b) -> Env e a -> Env e b - runEnv :: forall e a. Env e a -> Tuple e a +#### `withEnv` + +``` purescript +withEnv :: forall e1 e2 a. (e1 -> e2) -> Env e1 a -> Env e2 a +``` + + +#### `mapEnv` + +``` purescript +mapEnv :: forall e a b. (a -> b) -> Env e a -> Env e b +``` + + +#### `env` + +``` purescript +env :: forall e a. e -> a -> Env e a +``` - withEnv :: forall e1 e2 a. (e1 -> e2) -> Env e1 a -> Env e2 a ## Module Control.Comonad.Env.Class -### Type Classes +#### `ComonadEnv` + +``` purescript +class (Comonad w) <= ComonadEnv e w where + ask :: forall a. w a -> e + local :: forall a. (e -> e) -> w a -> w a +``` + - class (Comonad w) <= ComonadEnv e w where - ask :: forall a. w a -> e - local :: forall a. (e -> e) -> w a -> w a +#### `comonadEnvTuple` +``` purescript +instance comonadEnvTuple :: ComonadEnv e (Tuple e) +``` -### Type Class Instances - instance comonadEnvEnvT :: (Comonad w) => ComonadEnv e (EnvT e w) +#### `comonadEnvEnvT` - instance comonadEnvTuple :: ComonadEnv e (Tuple e) +``` purescript +instance comonadEnvEnvT :: (Comonad w) => ComonadEnv e (EnvT e w) +``` -### Values +#### `asks` + +``` purescript +asks :: forall e1 e2 w a. (ComonadEnv e1 w) => (e1 -> e2) -> w e1 -> e2 +``` - asks :: forall e1 e2 w a. (ComonadEnv e1 w) => (e1 -> e2) -> w e1 -> e2 ## Module Control.Comonad.Env.Trans -### Types +#### `EnvT` + +``` purescript +newtype EnvT e w a + = EnvT (Tuple e (w a)) +``` + - newtype EnvT e w a where - EnvT :: Tuple e (w a) -> EnvT e w a +#### `runEnvT` +``` purescript +runEnvT :: forall e w a. EnvT e w a -> Tuple e (w a) +``` -### Type Class Instances - instance comonadEnvT :: (Comonad w) => Comonad (EnvT e w) +#### `withEnvT` - instance comonadTransEnvT :: ComonadTrans (EnvT e) +``` purescript +withEnvT :: forall e1 e2 w a. (e1 -> e2) -> EnvT e1 w a -> EnvT e2 w a +``` - instance extendEnvT :: (Extend w) => Extend (EnvT e w) - instance functorEnvT :: (Functor w) => Functor (EnvT e w) +#### `mapEnvT` +``` purescript +mapEnvT :: forall e w1 w2 a b. (w1 a -> w2 b) -> EnvT e w1 a -> EnvT e w2 b +``` -### Values - mapEnvT :: forall e w1 w2 a b. (w1 a -> w2 b) -> EnvT e w1 a -> EnvT e w2 b +#### `functorEnvT` - runEnvT :: forall e w a. EnvT e w a -> Tuple e (w a) +``` purescript +instance functorEnvT :: (Functor w) => Functor (EnvT e w) +``` + + +#### `extendEnvT` + +``` purescript +instance extendEnvT :: (Extend w) => Extend (EnvT e w) +``` + + +#### `comonadEnvT` + +``` purescript +instance comonadEnvT :: (Comonad w) => Comonad (EnvT e w) +``` + + +#### `comonadTransEnvT` + +``` purescript +instance comonadTransEnvT :: ComonadTrans (EnvT e) +``` - withEnvT :: forall e1 e2 w a. (e1 -> e2) -> EnvT e1 w a -> EnvT e2 w a ## Module Control.Comonad.Store -### Types +#### `Store` + +``` purescript +type Store s a = StoreT s Identity a +``` + + +#### `runStore` - type Store s a = StoreT s Identity a +``` purescript +runStore :: forall s a. Store s a -> Tuple (s -> a) s +``` -### Values +#### `store` - runStore :: forall s a. Store s a -> Tuple (s -> a) s +``` purescript +store :: forall s a. (s -> a) -> s -> Store s a +``` - store :: forall s a. (s -> a) -> s -> Store s a ## Module Control.Comonad.Store.Class -### Type Classes +#### `ComonadStore` - class (Comonad w) <= ComonadStore s w where - pos :: forall a. w a -> s - peek :: forall a. s -> w a -> a +``` purescript +class (Comonad w) <= ComonadStore s w where + pos :: forall a. w a -> s + peek :: forall a. s -> w a -> a +``` -### Type Class Instances +#### `comonadStoreStoreT` - instance comonadStoreStoreT :: (Comonad w) => ComonadStore s (StoreT s w) +``` purescript +instance comonadStoreStoreT :: (Comonad w) => ComonadStore s (StoreT s w) +``` -### Values +#### `experiment` - experiment :: forall f a w s. (ComonadStore s w, Functor f) => (s -> f s) -> w a -> f a +``` purescript +experiment :: forall f a w s. (ComonadStore s w, Functor f) => (s -> f s) -> w a -> f a +``` - peeks :: forall s a w. (ComonadStore s w) => (s -> s) -> w a -> a - seek :: forall s a w. (ComonadStore s w, Extend w) => s -> w a -> w a +#### `peeks` + +``` purescript +peeks :: forall s a w. (ComonadStore s w) => (s -> s) -> w a -> a +``` + + +#### `seek` + +``` purescript +seek :: forall s a w. (ComonadStore s w, Extend w) => s -> w a -> w a +``` + + +#### `seeks` + +``` purescript +seeks :: forall s a w. (ComonadStore s w, Extend w) => (s -> s) -> w a -> w a +``` - seeks :: forall s a w. (ComonadStore s w, Extend w) => (s -> s) -> w a -> w a ## Module Control.Comonad.Store.Trans -### Types +#### `StoreT` + +``` purescript +newtype StoreT s w a + = StoreT (Tuple (w (s -> a)) s) +``` + + +#### `runStoreT` + +``` purescript +runStoreT :: forall s w a. StoreT s w a -> Tuple (w (s -> a)) s +``` + - newtype StoreT s w a where - StoreT :: Tuple (w (s -> a)) s -> StoreT s w a +#### `functorStoreT` +``` purescript +instance functorStoreT :: (Functor w) => Functor (StoreT s w) +``` -### Type Class Instances - instance comonadStoreT :: (Comonad w) => Comonad (StoreT s w) +#### `extendStoreT` - instance comonadTransStoreT :: ComonadTrans (StoreT s) +``` purescript +instance extendStoreT :: (Extend w) => Extend (StoreT s w) +``` - instance extendStoreT :: (Extend w) => Extend (StoreT s w) - instance functorStoreT :: (Functor w) => Functor (StoreT s w) +#### `comonadStoreT` +``` purescript +instance comonadStoreT :: (Comonad w) => Comonad (StoreT s w) +``` -### Values - runStoreT :: forall s w a. StoreT s w a -> Tuple (w (s -> a)) s +#### `comonadTransStoreT` + +``` purescript +instance comonadTransStoreT :: ComonadTrans (StoreT s) +``` + ## Module Control.Comonad.Traced -### Types +#### `Traced` + +``` purescript +type Traced m = TracedT m Identity +``` - type Traced m = TracedT m Identity +#### `runTraced` -### Values +``` purescript +runTraced :: forall m a. Traced m a -> m -> a +``` - runTraced :: forall m a. Traced m a -> m -> a - traced :: forall m a. (m -> a) -> Traced m a +#### `traced` + +``` purescript +traced :: forall m a. (m -> a) -> Traced m a +``` + ## Module Control.Comonad.Traced.Class -### Type Classes +#### `ComonadTraced` + +``` purescript +class (Comonad w) <= ComonadTraced t w where + track :: forall a. t -> w a -> a +``` + + +#### `comonadTracedTracedT` + +``` purescript +instance comonadTracedTracedT :: (Comonad w, Monoid t) => ComonadTraced t (TracedT t w) +``` + + +#### `tracks` - class (Comonad w) <= ComonadTraced t w where - track :: forall a. t -> w a -> a +``` purescript +tracks :: forall w a t. (Comonad w, ComonadTraced t w) => (a -> t) -> w a -> a +``` -### Type Class Instances +#### `listen` - instance comonadTracedTracedT :: (Comonad w, Monoid t) => ComonadTraced t (TracedT t w) +``` purescript +listen :: forall w a t. (Functor w) => TracedT t w a -> TracedT t w (Tuple a t) +``` -### Values +#### `listens` - censor :: forall w a t b. (Functor w) => (t -> t) -> TracedT t w a -> TracedT t w a +``` purescript +listens :: forall w a t b. (Functor w) => (t -> b) -> TracedT t w a -> TracedT t w (Tuple a b) +``` - listen :: forall w a t. (Functor w) => TracedT t w a -> TracedT t w (Tuple a t) - listens :: forall w a t b. (Functor w) => (t -> b) -> TracedT t w a -> TracedT t w (Tuple a b) +#### `censor` + +``` purescript +censor :: forall w a t b. (Functor w) => (t -> t) -> TracedT t w a -> TracedT t w a +``` - tracks :: forall w a t. (Comonad w, ComonadTraced t w) => (a -> t) -> w a -> a ## Module Control.Comonad.Traced.Trans -### Types +#### `TracedT` + +``` purescript +newtype TracedT t w a + = TracedT (w (t -> a)) +``` + + +#### `runTracedT` + +``` purescript +runTracedT :: forall w a t. TracedT t w a -> w (t -> a) +``` + - newtype TracedT t w a where - TracedT :: w (t -> a) -> TracedT t w a +#### `functorTracedT` +``` purescript +instance functorTracedT :: (Functor w) => Functor (TracedT t w) +``` -### Type Class Instances - instance comonadTracedT :: (Comonad w, Monoid t) => Comonad (TracedT t w) +#### `extendTracedT` - instance comonadTransTracedT :: (Monoid t) => ComonadTrans (TracedT t) +``` purescript +instance extendTracedT :: (Extend w, Semigroup t) => Extend (TracedT t w) +``` - instance extendTracedT :: (Extend w, Semigroup t) => Extend (TracedT t w) - instance functorTracedT :: (Functor w) => Functor (TracedT t w) +#### `comonadTracedT` +``` purescript +instance comonadTracedT :: (Comonad w, Monoid t) => Comonad (TracedT t w) +``` -### Values - runTracedT :: forall w a t. TracedT t w a -> w (t -> a) +#### `comonadTransTracedT` + +``` purescript +instance comonadTransTracedT :: (Monoid t) => ComonadTrans (TracedT t) +``` + ## Module Control.Comonad.Trans -### Type Classes +#### `ComonadTrans` + +``` purescript +class ComonadTrans f where + lower :: forall w a. (Comonad w) => f w a -> w a +``` - class ComonadTrans f where - lower :: forall w a. (Comonad w) => f w a -> w a ## Module Control.Monad.Cont.Class -### Type Classes +#### `MonadCont` + +``` purescript +class MonadCont m where + callCC :: forall a b. ((a -> m b) -> m a) -> m a +``` + + +#### `monadContContT` - class MonadCont m where - callCC :: forall a b. ((a -> m b) -> m a) -> m a +``` purescript +instance monadContContT :: (Monad m) => MonadCont (Cont.ContT r m) +``` -### Type Class Instances +#### `monadContErrorT` - instance monadContContT :: (Monad m) => MonadCont (Cont.ContT r m) +``` purescript +instance monadContErrorT :: (MonadCont m) => MonadCont (ErrorT e m) +``` - instance monadContErrorT :: (MonadCont m) => MonadCont (ErrorT e m) - instance monadContMaybeT :: (MonadCont m) => MonadCont (MaybeT m) +#### `monadContMaybeT` - instance monadContReaderT :: (MonadCont m) => MonadCont (ReaderT r m) +``` purescript +instance monadContMaybeT :: (MonadCont m) => MonadCont (MaybeT m) +``` - instance monadContStateT :: (MonadCont m) => MonadCont (StateT s m) - instance monadWriterT :: (Monoid w, MonadCont m) => MonadCont (WriterT w m) +#### `monadContReaderT` + +``` purescript +instance monadContReaderT :: (MonadCont m) => MonadCont (ReaderT r m) +``` + + +#### `monadContStateT` + +``` purescript +instance monadContStateT :: (MonadCont m) => MonadCont (StateT s m) +``` + + +#### `monadWriterT` + +``` purescript +instance monadWriterT :: (Monoid w, MonadCont m) => MonadCont (WriterT w m) +``` + ## Module Control.Monad.Cont.Trans -### Types +#### `ContT` + +``` purescript +newtype ContT r m a + = ContT ((a -> m r) -> m r) +``` + + +#### `runContT` - newtype ContT r m a where - ContT :: ((a -> m r) -> m r) -> ContT r m a +``` purescript +runContT :: forall r m a. ContT r m a -> (a -> m r) -> m r +``` -### Type Class Instances +#### `mapContT` - instance applicativeContT :: (Functor m, Monad m) => Applicative (ContT r m) +``` purescript +mapContT :: forall r m a. (m r -> m r) -> ContT r m a -> ContT r m a +``` - instance applyContT :: (Functor m, Monad m) => Apply (ContT r m) - instance bindContT :: (Monad m) => Bind (ContT r m) +#### `withContT` - instance functorContT :: (Monad m) => Functor (ContT r m) +``` purescript +withContT :: forall r m a b. ((b -> m r) -> a -> m r) -> ContT r m a -> ContT r m b +``` - instance monadContT :: (Monad m) => Monad (ContT r m) - instance monadTransContT :: MonadTrans (ContT r) +#### `callCC` +``` purescript +callCC :: forall r m a b. ((a -> ContT r m b) -> ContT r m a) -> ContT r m a +``` -### Values - callCC :: forall r m a b. ((a -> ContT r m b) -> ContT r m a) -> ContT r m a +#### `functorContT` - mapContT :: forall r m a. (m r -> m r) -> ContT r m a -> ContT r m a +``` purescript +instance functorContT :: (Monad m) => Functor (ContT r m) +``` - runContT :: forall r m a. ContT r m a -> (a -> m r) -> m r - withContT :: forall r m a b. ((b -> m r) -> a -> m r) -> ContT r m a -> ContT r m b +#### `applyContT` + +``` purescript +instance applyContT :: (Functor m, Monad m) => Apply (ContT r m) +``` + + +#### `applicativeContT` + +``` purescript +instance applicativeContT :: (Functor m, Monad m) => Applicative (ContT r m) +``` + + +#### `bindContT` + +``` purescript +instance bindContT :: (Monad m) => Bind (ContT r m) +``` + + +#### `monadContT` + +``` purescript +instance monadContT :: (Monad m) => Monad (ContT r m) +``` + + +#### `monadTransContT` + +``` purescript +instance monadTransContT :: MonadTrans (ContT r) +``` + ## Module Control.Monad.Error -### Type Classes +#### `Error` + +``` purescript +class Error a where + noMsg :: a + strMsg :: String -> a +``` - class Error a where - noMsg :: a - strMsg :: String -> a +#### `errorString` -### Type Class Instances +``` purescript +instance errorString :: Error String +``` - instance errorString :: Error String ## Module Control.Monad.Error.Class -### Type Classes +#### `MonadError` + +``` purescript +class MonadError e m where + throwError :: forall a. e -> m a + catchError :: forall a. m a -> (e -> m a) -> m a +``` + + +#### `monadErrorError` + +``` purescript +instance monadErrorError :: MonadError e (Either e) +``` + + +#### `monadErrorErrorT` + +``` purescript +instance monadErrorErrorT :: (Monad m) => MonadError e (ErrorT e m) +``` + - class MonadError e m where - throwError :: forall a. e -> m a - catchError :: forall a. m a -> (e -> m a) -> m a +#### `monadErrorMaybeT` +``` purescript +instance monadErrorMaybeT :: (Monad m, MonadError e m) => MonadError e (MaybeT m) +``` -### Type Class Instances - instance monadErrorError :: MonadError e (Either e) +#### `monadErrorReaderT` - instance monadErrorErrorT :: (Monad m) => MonadError e (ErrorT e m) +``` purescript +instance monadErrorReaderT :: (Monad m, MonadError e m) => MonadError e (ReaderT r m) +``` - instance monadErrorMaybeT :: (Monad m, MonadError e m) => MonadError e (MaybeT m) - instance monadErrorReaderT :: (Monad m, MonadError e m) => MonadError e (ReaderT r m) +#### `monadErrorWriterT` - instance monadErrorStateT :: (Monad m, MonadError e m) => MonadError e (StateT s m) +``` purescript +instance monadErrorWriterT :: (Monad m, Monoid w, MonadError e m) => MonadError e (WriterT w m) +``` + + +#### `monadErrorStateT` + +``` purescript +instance monadErrorStateT :: (Monad m, MonadError e m) => MonadError e (StateT s m) +``` - instance monadErrorWriterT :: (Monad m, Monoid w, MonadError e m) => MonadError e (WriterT w m) ## Module Control.Monad.Error.Trans -### Types +#### `ErrorT` + +``` purescript +newtype ErrorT e m a + = ErrorT (m (Either e a)) +``` + + +#### `runErrorT` + +``` purescript +runErrorT :: forall e m a. ErrorT e m a -> m (Either e a) +``` + + +#### `mapErrorT` + +``` purescript +mapErrorT :: forall e1 e2 m1 m2 a b. (m1 (Either e1 a) -> m2 (Either e2 b)) -> ErrorT e1 m1 a -> ErrorT e2 m2 b +``` + + +#### `functorErrorT` + +``` purescript +instance functorErrorT :: (Functor m) => Functor (ErrorT e m) +``` + + +#### `applyErrorT` + +``` purescript +instance applyErrorT :: (Apply m) => Apply (ErrorT e m) +``` + + +#### `applicativeErrorT` + +``` purescript +instance applicativeErrorT :: (Applicative m) => Applicative (ErrorT e m) +``` + + +#### `altErrorT` + +``` purescript +instance altErrorT :: (Monad m) => Alt (ErrorT e m) +``` + + +#### `plusErrorT` - newtype ErrorT e m a where - ErrorT :: m (Either e a) -> ErrorT e m a +``` purescript +instance plusErrorT :: (Monad m, Error e) => Plus (ErrorT e m) +``` -### Type Class Instances +#### `alternativeErrorT` - instance altErrorT :: (Monad m) => Alt (ErrorT e m) +``` purescript +instance alternativeErrorT :: (Monad m, Error e) => Alternative (ErrorT e m) +``` - instance alternativeErrorT :: (Monad m, Error e) => Alternative (ErrorT e m) - instance applicativeErrorT :: (Applicative m) => Applicative (ErrorT e m) +#### `bindErrorT` - instance applyErrorT :: (Apply m) => Apply (ErrorT e m) +``` purescript +instance bindErrorT :: (Monad m) => Bind (ErrorT e m) +``` - instance bindErrorT :: (Monad m) => Bind (ErrorT e m) - instance functorErrorT :: (Functor m) => Functor (ErrorT e m) +#### `monadErrorT` - instance monadErrorT :: (Monad m) => Monad (ErrorT e m) +``` purescript +instance monadErrorT :: (Monad m) => Monad (ErrorT e m) +``` - instance monadPlusErrorT :: (Monad m, Error e) => MonadPlus (ErrorT e m) - instance monadTransErrorT :: MonadTrans (ErrorT e) +#### `monadPlusErrorT` - instance plusErrorT :: (Monad m, Error e) => Plus (ErrorT e m) +``` purescript +instance monadPlusErrorT :: (Monad m, Error e) => MonadPlus (ErrorT e m) +``` -### Values +#### `monadTransErrorT` - liftCallCCError :: forall e m a b. (((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 +``` purescript +instance monadTransErrorT :: MonadTrans (ErrorT e) +``` - liftListenError :: forall e m a w. (Monad m) => (m (Either e a) -> m (Tuple (Either e a) w)) -> ErrorT e m a -> ErrorT e m (Tuple a w) - liftPassError :: forall e m a w. (Monad m) => (m (Tuple (Either e a) (w -> w)) -> m (Either e a)) -> ErrorT e m (Tuple a (w -> w)) -> ErrorT e m a +#### `liftListenError` - mapErrorT :: forall e1 e2 m1 m2 a b. (m1 (Either e1 a) -> m2 (Either e2 b)) -> ErrorT e1 m1 a -> ErrorT e2 m2 b +``` purescript +liftListenError :: forall e m a w. (Monad m) => (m (Either e a) -> m (Tuple (Either e a) w)) -> ErrorT e m a -> ErrorT e m (Tuple a w) +``` + + +#### `liftPassError` + +``` purescript +liftPassError :: forall e m a w. (Monad m) => (m (Tuple (Either e a) (w -> w)) -> m (Either e a)) -> ErrorT e m (Tuple a (w -> w)) -> ErrorT e m a +``` + + +#### `liftCallCCError` + +``` purescript +liftCallCCError :: forall e m a b. (((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 +``` - runErrorT :: forall e m a. ErrorT e m a -> m (Either e a) ## Module Control.Monad.Maybe.Trans -### Types +#### `MaybeT` + +``` purescript +newtype MaybeT m a + = MaybeT (m (Maybe a)) +``` + + +#### `functorMaybeT` + +``` purescript +instance functorMaybeT :: (Monad m) => Functor (MaybeT m) +``` + + +#### `applyMaybeT` + +``` purescript +instance applyMaybeT :: (Monad m) => Apply (MaybeT m) +``` + + +#### `applicativeMaybeT` + +``` purescript +instance applicativeMaybeT :: (Monad m) => Applicative (MaybeT m) +``` + + +#### `bindMaybeT` + +``` purescript +instance bindMaybeT :: (Monad m) => Bind (MaybeT m) +``` + + +#### `monadMaybeT` + +``` purescript +instance monadMaybeT :: (Monad m) => Monad (MaybeT m) +``` + - newtype MaybeT m a where - MaybeT :: m (Maybe a) -> MaybeT m a +#### `monadTransMaybeT` +``` purescript +instance monadTransMaybeT :: MonadTrans MaybeT +``` -### Type Class Instances - instance applicativeMaybeT :: (Monad m) => Applicative (MaybeT m) +#### `runMaybeT` - instance applyMaybeT :: (Monad m) => Apply (MaybeT m) +``` purescript +runMaybeT :: forall m a. MaybeT m a -> m (Maybe a) +``` - instance bindMaybeT :: (Monad m) => Bind (MaybeT m) - instance functorMaybeT :: (Monad m) => Functor (MaybeT m) +#### `mapMaybeT` - instance monadMaybeT :: (Monad m) => Monad (MaybeT m) +``` purescript +mapMaybeT :: forall m1 m2 a b. (m1 (Maybe a) -> m2 (Maybe b)) -> MaybeT m1 a -> MaybeT m2 b +``` - instance monadTransMaybeT :: MonadTrans MaybeT +#### `liftCatchMaybe` -### Values +``` purescript +liftCatchMaybe :: forall m e a. (m (Maybe a) -> (e -> m (Maybe a)) -> m (Maybe a)) -> MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a +``` - liftCallCCMaybe :: forall m a b. (((Maybe a -> m (Maybe b)) -> m (Maybe a)) -> m (Maybe a)) -> ((a -> MaybeT m b) -> MaybeT m a) -> MaybeT m a - liftCatchMaybe :: forall m e a. (m (Maybe a) -> (e -> m (Maybe a)) -> m (Maybe a)) -> MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a +#### `liftListenMaybe` - liftListenMaybe :: forall m a w. (Monad m) => (m (Maybe a) -> m (Tuple (Maybe a) w)) -> MaybeT m a -> MaybeT m (Tuple a w) +``` purescript +liftListenMaybe :: forall m a w. (Monad m) => (m (Maybe a) -> m (Tuple (Maybe a) w)) -> MaybeT m a -> MaybeT m (Tuple a w) +``` - liftPassMaybe :: forall m a w. (Monad m) => (m (Tuple (Maybe a) (w -> w)) -> m (Maybe a)) -> MaybeT m (Tuple a (w -> w)) -> MaybeT m a - mapMaybeT :: forall m1 m2 a b. (m1 (Maybe a) -> m2 (Maybe b)) -> MaybeT m1 a -> MaybeT m2 b +#### `liftPassMaybe` + +``` purescript +liftPassMaybe :: forall m a w. (Monad m) => (m (Tuple (Maybe a) (w -> w)) -> m (Maybe a)) -> MaybeT m (Tuple a (w -> w)) -> MaybeT m a +``` + + +#### `liftCallCCMaybe` + +``` purescript +liftCallCCMaybe :: forall m a b. (((Maybe a -> m (Maybe b)) -> m (Maybe a)) -> m (Maybe a)) -> ((a -> MaybeT m b) -> MaybeT m a) -> MaybeT m a +``` - runMaybeT :: forall m a. MaybeT m a -> m (Maybe a) ## Module Control.Monad.RWS -### Types +#### `RWS` + +``` purescript +type RWS r w s = RWST r w s Identity +``` + + +#### `rws` + +``` purescript +rws :: forall r w s a. (r -> s -> See s a w) -> RWS r w s a +``` + + +#### `runRWS` + +``` purescript +runRWS :: forall r w s a. RWS r w s a -> r -> s -> See s a w +``` + + +#### `evalRWS` + +``` purescript +evalRWS :: forall r w s a. RWS r w s a -> r -> s -> Tuple a w +``` + + +#### `execRWS` + +``` purescript +execRWS :: forall r w s a. RWS r w s a -> r -> s -> Tuple s w +``` + + +#### `mapRWS` + +``` purescript +mapRWS :: forall r w1 w2 s a1 a2. (See s a1 w1 -> See s a2 w2) -> RWS r w1 s a1 -> RWS r w2 s a2 +``` + + +#### `withRWS` + +``` purescript +withRWS :: forall r1 r2 w s a. (r2 -> s -> Tuple r1 s) -> RWS r1 w s a -> RWS r2 w s a +``` - type RWS r w s = RWST r w s Identity +#### `ask` -### Values +``` purescript +ask :: forall r w s m. (Applicative m, Monoid w) => RWST r w s m r +``` - ask :: forall r w s m. (Applicative m, Monoid w) => RWST r w s m r +Reader operations - censor :: forall r w s m a. (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a +#### `local` - evalRWS :: forall r w s a. RWS r w s a -> r -> s -> Tuple a w +``` purescript +local :: forall r w s m a. (r -> r) -> RWST r w s m a -> RWST r w s m a +``` - execRWS :: forall r w s a. RWS r w s a -> r -> s -> Tuple s w - get :: forall r w s m. (Applicative m, Monoid w) => RWST r w s m s +#### `reader` - gets :: forall r w s m a. (Applicative m, Monoid w) => (s -> a) -> RWST r w s m a +``` purescript +reader :: forall r w s m a. (Applicative m, Monoid w) => (r -> a) -> RWST r w s m a +``` - listen :: forall r w s m a. (Monad m) => RWST r w s m a -> RWST r w s m (Tuple a w) - listens :: forall r w s m a b. (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (Tuple a b) +#### `writer` - local :: forall r w s m a. (r -> r) -> RWST r w s m a -> RWST r w s m a +``` purescript +writer :: forall r w s m a. (Applicative m) => Tuple a w -> RWST r w s m a +``` - mapRWS :: forall r w1 w2 s a1 a2. (See s a1 w1 -> See s a2 w2) -> RWS r w1 s a1 -> RWS r w2 s a2 +Writer operations - modify :: forall r w s m. (Applicative m, Monoid w) => (s -> s) -> RWST r w s m Unit +#### `listen` - pass :: forall r w s m a. (Monad m) => RWST r w s m (Tuple a (w -> w)) -> RWST r w s m a +``` purescript +listen :: forall r w s m a. (Monad m) => RWST r w s m a -> RWST r w s m (Tuple a w) +``` - put :: forall r w s m. (Applicative m, Monoid w) => s -> RWST r w s m Unit - reader :: forall r w s m a. (Applicative m, Monoid w) => (r -> a) -> RWST r w s m a +#### `pass` - runRWS :: forall r w s a. RWS r w s a -> r -> s -> See s a w +``` purescript +pass :: forall r w s m a. (Monad m) => RWST r w s m (Tuple a (w -> w)) -> RWST r w s m a +``` - rws :: forall r w s a. (r -> s -> See s a w) -> RWS r w s a - state :: forall r w s m a. (Applicative m, Monoid w) => (s -> Tuple a s) -> RWST r w s m a +#### `tell` - tell :: forall r w s m. (Applicative m) => w -> RWST r w s m Unit +``` purescript +tell :: forall r w s m. (Applicative m) => w -> RWST r w s m Unit +``` - withRWS :: forall r1 r2 w s a. (r2 -> s -> Tuple r1 s) -> RWS r1 w s a -> RWS r2 w s a - writer :: forall r w s m a. (Applicative m) => Tuple a w -> RWST r w s m a +#### `listens` + +``` purescript +listens :: forall r w s m a b. (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (Tuple a b) +``` + + +#### `censor` + +``` purescript +censor :: forall r w s m a. (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a +``` + + +#### `state` + +``` purescript +state :: forall r w s m a. (Applicative m, Monoid w) => (s -> Tuple a s) -> RWST r w s m a +``` + +State operations + +#### `get` + +``` purescript +get :: forall r w s m. (Applicative m, Monoid w) => RWST r w s m s +``` + + +#### `gets` + +``` purescript +gets :: forall r w s m a. (Applicative m, Monoid w) => (s -> a) -> RWST r w s m a +``` + + +#### `put` + +``` purescript +put :: forall r w s m. (Applicative m, Monoid w) => s -> RWST r w s m Unit +``` + + +#### `modify` + +``` purescript +modify :: forall r w s m. (Applicative m, Monoid w) => (s -> s) -> RWST r w s m Unit +``` + ## Module Control.Monad.RWS.Class -### Type Classes +#### `MonadRWS` + +``` purescript +class (Monad m, Monoid w, MonadReader r m, MonadWriter w m, MonadState s m) <= MonadRWS r w s m where +``` + + +#### `monadRWSRWST` - class (Monad m, Monoid w, MonadReader r m, MonadWriter w m, MonadState s m) <= MonadRWS r w s m where +``` purescript +instance monadRWSRWST :: (Monad m, Monoid w) => MonadRWS r w s (RWST r w s m) +``` -### Type Class Instances +#### `monadRWSErrorT` - instance monadRWSErrorT :: (Monad m, Monoid w, MonadRWS r w s m, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (ErrorT e m) +``` purescript +instance monadRWSErrorT :: (Monad m, Monoid w, MonadRWS r w s m, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (ErrorT e m) +``` - instance monadRWSMaybeT :: (Monad m, Monoid w, MonadRWS r w s m, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (MaybeT m) - instance monadRWSRWST :: (Monad m, Monoid w) => MonadRWS r w s (RWST r w s m) +#### `monadRWSMaybeT` + +``` purescript +instance monadRWSMaybeT :: (Monad m, Monoid w, MonadRWS r w s m, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (MaybeT m) +``` + ## Module Control.Monad.RWS.Trans -### Types +#### `See` + +``` purescript +type See s a w = { log :: w, result :: a, state :: s } +``` + + +#### `mkSee` + +``` purescript +mkSee :: forall s a w. (Monoid w) => s -> a -> w -> See s a w +``` + + +#### `RWST` + +``` purescript +newtype RWST r w s m a + = RWST (r -> s -> m (See s a w)) +``` + + +#### `runRWST` + +``` purescript +runRWST :: forall r w s m a. RWST r w s m a -> r -> s -> m (See s a w) +``` + + +#### `evalRWST` + +``` purescript +evalRWST :: forall r w s m a. (Monad m) => RWST r w s m a -> r -> s -> m (Tuple a w) +``` + + +#### `execRWST` + +``` purescript +execRWST :: forall r w s m a. (Monad m) => RWST r w s m a -> r -> s -> m (Tuple s w) +``` + + +#### `mapRWST` + +``` purescript +mapRWST :: forall r w1 w2 s m1 m2 a1 a2. (m1 (See s a1 w1) -> m2 (See s a2 w2)) -> RWST r w1 s m1 a1 -> RWST r w2 s m2 a2 +``` + + +#### `withRWST` + +``` purescript +withRWST :: forall r1 r2 w s m a. (r2 -> s -> Tuple r1 s) -> RWST r1 w s m a -> RWST r2 w s m a +``` - newtype RWST r w s m a where - RWST :: (r -> s -> m (See s a w)) -> RWST r w s m a - type See s a w = { log :: w, result :: a, state :: s } +#### `functorRWST` +``` purescript +instance functorRWST :: (Functor m) => Functor (RWST r w s m) +``` -### Type Class Instances - instance applicativeRWST :: (Applicative m, Monoid w) => Applicative (RWST r w s m) +#### `applyRWST` - instance applyRWST :: (Apply m, Semigroup w) => Apply (RWST r w s m) +``` purescript +instance applyRWST :: (Bind m, Monoid w) => Apply (RWST r w s m) +``` - instance bindRWST :: (Bind m, Semigroup w) => Bind (RWST r w s m) - instance functorRWST :: (Functor m) => Functor (RWST r w s m) +#### `bindRWST` - instance monadRWST :: (Monad m, Monoid w) => Monad (RWST r w s m) +``` purescript +instance bindRWST :: (Bind m, Monoid w) => Bind (RWST r w s m) +``` - instance monadTransRWST :: (Monoid w) => MonadTrans (RWST r w s) +#### `applicativeRWST` -### Values +``` purescript +instance applicativeRWST :: (Monad m, Monoid w) => Applicative (RWST r w s m) +``` - evalRWST :: forall r w s m a. (Monad m) => RWST r w s m a -> r -> s -> m (Tuple a w) - execRWST :: forall r w s m a. (Monad m) => RWST r w s m a -> r -> s -> m (Tuple s w) +#### `monadRWST` - mapRWST :: forall r w1 w2 s m1 m2 a1 a2. (m1 (See s a1 w1) -> m2 (See s a2 w2)) -> RWST r w1 s m1 a1 -> RWST r w2 s m2 a2 +``` purescript +instance monadRWST :: (Monad m, Monoid w) => Monad (RWST r w s m) +``` - mkSee :: forall s a w. (Monoid w) => s -> a -> w -> See s a w - runRWST :: forall r w s m a. RWST r w s m a -> r -> s -> m (See s a w) +#### `monadTransRWST` + +``` purescript +instance monadTransRWST :: (Monoid w) => MonadTrans (RWST r w s) +``` - withRWST :: forall r1 r2 w s m a. (r2 -> s -> Tuple r1 s) -> RWST r1 w s m a -> RWST r2 w s m a ## Module Control.Monad.Reader -### Types +#### `Reader` + +``` purescript +type Reader r = ReaderT r Identity +``` + + +#### `runReader` + +``` purescript +runReader :: forall r a. Reader r a -> r -> a +``` + - type Reader r = ReaderT r Identity +#### `withReader` +``` purescript +withReader :: forall r1 r2 a b. (r2 -> r1) -> Reader r1 a -> Reader r2 a +``` -### Values - mapReader :: forall r a b. (a -> b) -> Reader r a -> Reader r b +#### `mapReader` - runReader :: forall r a. Reader r a -> r -> a +``` purescript +mapReader :: forall r a b. (a -> b) -> Reader r a -> Reader r b +``` - withReader :: forall r1 r2 a b. (r2 -> r1) -> Reader r1 a -> Reader r2 a ## Module Control.Monad.Reader.Class -### Type Classes +#### `MonadReader` + +``` purescript +class MonadReader r m where + ask :: m r + local :: forall a. (r -> r) -> m a -> m a +``` + + +#### `reader` + +``` purescript +reader :: forall r m a. (Monad m, MonadReader r m) => (r -> a) -> m a +``` + + +#### `monadReaderFun` - class MonadReader r m where - ask :: m r - local :: forall a. (r -> r) -> m a -> m a +``` purescript +instance monadReaderFun :: MonadReader r (Prim.Function r) +``` -### Type Class Instances +#### `monadReaderReaderT` - instance monadReaderErrorT :: (Monad m, MonadReader r m) => MonadReader r (ErrorT e m) +``` purescript +instance monadReaderReaderT :: (Monad m) => MonadReader r (ReaderT r m) +``` - instance monadReaderFun :: MonadReader r (Prim.Function r) - instance monadReaderMaybeT :: (Monad m, MonadReader r m) => MonadReader r (MaybeT m) +#### `monadReaderErrorT` - instance monadReaderRWST :: (Monad m, Monoid w) => MonadReader r (RWST r w s m) +``` purescript +instance monadReaderErrorT :: (Monad m, MonadReader r m) => MonadReader r (ErrorT e m) +``` - instance monadReaderReaderT :: (Monad m) => MonadReader r (ReaderT r m) - instance monadReaderStateT :: (Monad m, MonadReader r m) => MonadReader r (StateT s m) +#### `monadReaderMaybeT` - instance monadReaderWriterT :: (Monad m, Monoid w, MonadReader r m) => MonadReader r (WriterT w m) +``` purescript +instance monadReaderMaybeT :: (Monad m, MonadReader r m) => MonadReader r (MaybeT m) +``` -### Values +#### `monadReaderWriterT` + +``` purescript +instance monadReaderWriterT :: (Monad m, Monoid w, MonadReader r m) => MonadReader r (WriterT w m) +``` + + +#### `monadReaderStateT` + +``` purescript +instance monadReaderStateT :: (Monad m, MonadReader r m) => MonadReader r (StateT s m) +``` + + +#### `monadReaderRWST` + +``` purescript +instance monadReaderRWST :: (Monad m, Monoid w) => MonadReader r (RWST r w s m) +``` - reader :: forall r m a. (Monad m, MonadReader r m) => (r -> a) -> m a ## Module Control.Monad.Reader.Trans -### Types +#### `ReaderT` + +``` purescript +newtype ReaderT r m a + = ReaderT (r -> m a) +``` + + +#### `runReaderT` + +``` purescript +runReaderT :: forall r m a. ReaderT r m a -> r -> m a +``` - newtype ReaderT r m a where - ReaderT :: (r -> m a) -> ReaderT r m a +#### `withReaderT` -### Type Class Instances +``` purescript +withReaderT :: forall r1 r2 m a b. (r2 -> r1) -> ReaderT r1 m a -> ReaderT r2 m a +``` - instance altReaderT :: (Alt m) => Alt (ReaderT r m) - instance alternativeReaderT :: (Alternative m) => Alternative (ReaderT r m) +#### `mapReaderT` - instance applicativeReaderT :: (Applicative m) => Applicative (ReaderT r m) +``` purescript +mapReaderT :: forall r m1 m2 a b. (m1 a -> m2 b) -> ReaderT r m1 a -> ReaderT r m2 b +``` - instance applyReaderT :: (Applicative m) => Apply (ReaderT r m) - instance bindReaderT :: (Monad m) => Bind (ReaderT r m) +#### `liftReaderT` - instance functorReaderT :: (Functor m) => Functor (ReaderT r m) +``` purescript +liftReaderT :: forall r m a. m a -> ReaderT r m a +``` - instance monadPlusReaderT :: (MonadPlus m) => MonadPlus (ReaderT r m) - instance monadReaderT :: (Monad m) => Monad (ReaderT r m) +#### `functorReaderT` - instance monadTransReaderT :: MonadTrans (ReaderT r) +``` purescript +instance functorReaderT :: (Functor m) => Functor (ReaderT r m) +``` - instance plusReaderT :: (Plus m) => Plus (ReaderT r m) +#### `applyReaderT` -### Values +``` purescript +instance applyReaderT :: (Applicative m) => Apply (ReaderT r m) +``` - liftCallCCReader :: forall r m a b. (((a -> m b) -> m a) -> m a) -> ((a -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m a - liftCatchReader :: forall r m e a. (m a -> (e -> m a) -> m a) -> ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a +#### `applicativeReaderT` - liftReaderT :: forall r m a. m a -> ReaderT r m a +``` purescript +instance applicativeReaderT :: (Applicative m) => Applicative (ReaderT r m) +``` - mapReaderT :: forall r m1 m2 a b. (m1 a -> m2 b) -> ReaderT r m1 a -> ReaderT r m2 b - runReaderT :: forall r m a. ReaderT r m a -> r -> m a +#### `altReaderT` + +``` purescript +instance altReaderT :: (Alt m) => Alt (ReaderT r m) +``` + + +#### `plusReaderT` + +``` purescript +instance plusReaderT :: (Plus m) => Plus (ReaderT r m) +``` + + +#### `alternativeReaderT` + +``` purescript +instance alternativeReaderT :: (Alternative m) => Alternative (ReaderT r m) +``` + + +#### `bindReaderT` + +``` purescript +instance bindReaderT :: (Monad m) => Bind (ReaderT r m) +``` + + +#### `monadReaderT` + +``` purescript +instance monadReaderT :: (Monad m) => Monad (ReaderT r m) +``` + + +#### `monadPlusReaderT` + +``` purescript +instance monadPlusReaderT :: (MonadPlus m) => MonadPlus (ReaderT r m) +``` + + +#### `monadTransReaderT` + +``` purescript +instance monadTransReaderT :: MonadTrans (ReaderT r) +``` + + +#### `liftCatchReader` + +``` purescript +liftCatchReader :: forall r m e a. (m a -> (e -> m a) -> m a) -> ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a +``` + + +#### `liftCallCCReader` + +``` purescript +liftCallCCReader :: forall r m a b. (((a -> m b) -> m a) -> m a) -> ((a -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m a +``` - withReaderT :: forall r1 r2 m a b. (r2 -> r1) -> ReaderT r1 m a -> ReaderT r2 m a ## Module Control.Monad.State -### Types +#### `State` + +``` purescript +type State s = StateT s Identity +``` + + +#### `runState` + +``` purescript +runState :: forall s a. State s a -> s -> Tuple a s +``` - type State s = StateT s Identity +#### `evalState` -### Values +``` purescript +evalState :: forall s a. State s a -> s -> a +``` - evalState :: forall s a. State s a -> s -> a - execState :: forall s a. State s a -> s -> s +#### `execState` - mapState :: forall s a b. (Tuple a s -> Tuple b s) -> State s a -> State s b +``` purescript +execState :: forall s a. State s a -> s -> s +``` - runState :: forall s a. State s a -> s -> Tuple a s - withState :: forall s a. (s -> s) -> State s a -> State s a +#### `mapState` + +``` purescript +mapState :: forall s a b. (Tuple a s -> Tuple b s) -> State s a -> State s b +``` + + +#### `withState` + +``` purescript +withState :: forall s a. (s -> s) -> State s a -> State s a +``` + ## Module Control.Monad.State.Class -### Type Classes +#### `MonadState` + +``` purescript +class MonadState s m where + state :: forall a. (s -> Tuple a s) -> m a +``` + + +#### `get` + +``` purescript +get :: forall m s. (Monad m, MonadState s m) => m s +``` + + +#### `gets` + +``` purescript +gets :: forall s m a. (Monad m, MonadState s m) => (s -> a) -> m a +``` + + +#### `put` + +``` purescript +put :: forall m s. (Monad m, MonadState s m) => s -> m Unit +``` + + +#### `modify` - class MonadState s m where - state :: forall a. (s -> Tuple a s) -> m a +``` purescript +modify :: forall s m. (Monad m, MonadState s m) => (s -> s) -> m Unit +``` -### Type Class Instances +#### `monadStateStateT` - instance monadStateErrorT :: (Monad m, MonadState s m) => MonadState s (ErrorT e m) +``` purescript +instance monadStateStateT :: (Monad m) => MonadState s (StateT s m) +``` - instance monadStateMaybeT :: (Monad m, MonadState s m) => MonadState s (MaybeT m) - instance monadStateRWST :: (Monad m, Monoid w) => MonadState s (RWST r w s m) +#### `monadStateStateT1` - instance monadStateReaderT :: (Monad m, MonadState s m) => MonadState s (ReaderT r m) +``` purescript +instance monadStateStateT1 :: (Monad m, MonadState s m) => MonadState s (StateT s1 m) +``` - instance monadStateStateT :: (Monad m) => MonadState s (StateT s m) - instance monadStateStateT1 :: (Monad m, MonadState s m) => MonadState s (StateT s1 m) +#### `monadStateErrorT` - instance monadStateWriterT :: (Monad m, Monoid w, MonadState s m) => MonadState s (WriterT w m) +``` purescript +instance monadStateErrorT :: (Monad m, MonadState s m) => MonadState s (ErrorT e m) +``` -### Values +#### `monadStateMaybeT` - get :: forall m s. (Monad m, MonadState s m) => m s +``` purescript +instance monadStateMaybeT :: (Monad m, MonadState s m) => MonadState s (MaybeT m) +``` - gets :: forall s m a. (Monad m, MonadState s m) => (s -> a) -> m a - modify :: forall s m. (Monad m, MonadState s m) => (s -> s) -> m Unit +#### `monadStateReaderT` + +``` purescript +instance monadStateReaderT :: (Monad m, MonadState s m) => MonadState s (ReaderT r m) +``` + + +#### `monadStateWriterT` + +``` purescript +instance monadStateWriterT :: (Monad m, Monoid w, MonadState s m) => MonadState s (WriterT w m) +``` + + +#### `monadStateRWST` + +``` purescript +instance monadStateRWST :: (Monad m, Monoid w) => MonadState s (RWST r w s m) +``` - put :: forall m s. (Monad m, MonadState s m) => s -> m Unit ## Module Control.Monad.State.Trans -### Types +#### `StateT` + +``` purescript +newtype StateT s m a + = StateT (s -> m (Tuple a s)) +``` + + +#### `runStateT` + +``` purescript +runStateT :: forall s m a. StateT s m a -> s -> m (Tuple a s) +``` + + +#### `evalStateT` + +``` purescript +evalStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m a +``` + + +#### `execStateT` + +``` purescript +execStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m s +``` + + +#### `mapStateT` + +``` purescript +mapStateT :: forall s m1 m2 a b. (m1 (Tuple a s) -> m2 (Tuple b s)) -> StateT s m1 a -> StateT s m2 b +``` + + +#### `withStateT` + +``` purescript +withStateT :: forall s m a. (s -> s) -> StateT s m a -> StateT s m a +``` + - newtype StateT s m a where - StateT :: (s -> m (Tuple a s)) -> StateT s m a +#### `functorStateT` +``` purescript +instance functorStateT :: (Monad m) => Functor (StateT s m) +``` -### Type Class Instances - instance altStateT :: (Monad m, Alt m) => Alt (StateT s m) +#### `applyStateT` - instance alternativeStateT :: (Monad m, Alternative m) => Alternative (StateT s m) +``` purescript +instance applyStateT :: (Monad m) => Apply (StateT s m) +``` - instance applicativeStateT :: (Monad m) => Applicative (StateT s m) - instance applyStateT :: (Monad m) => Apply (StateT s m) +#### `applicativeStateT` - instance bindStateT :: (Monad m) => Bind (StateT s m) +``` purescript +instance applicativeStateT :: (Monad m) => Applicative (StateT s m) +``` - instance functorStateT :: (Monad m) => Functor (StateT s m) - instance lazy1StateT :: Lazy1 (StateT s m) +#### `altStateT` - instance monadPlusStateT :: (MonadPlus m) => MonadPlus (StateT s m) +``` purescript +instance altStateT :: (Monad m, Alt m) => Alt (StateT s m) +``` - instance monadStateT :: (Monad m) => Monad (StateT s m) - instance monadTransStateT :: MonadTrans (StateT s) +#### `plusStateT` - instance plusStateT :: (Monad m, Plus m) => Plus (StateT s m) +``` purescript +instance plusStateT :: (Monad m, Plus m) => Plus (StateT s m) +``` -### Values +#### `alternativeStateT` - evalStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m a +``` purescript +instance alternativeStateT :: (Monad m, Alternative m) => Alternative (StateT s m) +``` - execStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m s - liftCallCCState :: forall s m a b. (((Tuple a s -> m (Tuple b s)) -> m (Tuple a s)) -> m (Tuple a s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a +#### `bindStateT` - liftCallCCState' :: forall s m a b. (((Tuple a s -> m (Tuple b s)) -> m (Tuple a s)) -> m (Tuple a s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a +``` purescript +instance bindStateT :: (Monad m) => Bind (StateT s m) +``` - liftCatchState :: forall s m e a. (m (Tuple a s) -> (e -> m (Tuple a s)) -> m (Tuple a s)) -> StateT s m a -> (e -> StateT s m a) -> StateT s m a - liftListenState :: forall s m a w. (Monad m) => (m (Tuple a s) -> m (Tuple (Tuple a s) w)) -> StateT s m a -> StateT s m (Tuple a w) +#### `monadStateT` - liftPassState :: forall s m a b w. (Monad m) => (m (Tuple (Tuple a s) b) -> m (Tuple a s)) -> StateT s m (Tuple a b) -> StateT s m a +``` purescript +instance monadStateT :: (Monad m) => Monad (StateT s m) +``` - mapStateT :: forall s m1 m2 a b. (m1 (Tuple a s) -> m2 (Tuple b s)) -> StateT s m1 a -> StateT s m2 b - runStateT :: forall s m a. StateT s m a -> s -> m (Tuple a s) +#### `monadPlusStateT` + +``` purescript +instance monadPlusStateT :: (MonadPlus m) => MonadPlus (StateT s m) +``` + + +#### `monadTransStateT` + +``` purescript +instance monadTransStateT :: MonadTrans (StateT s) +``` + + +#### `lazy1StateT` + +``` purescript +instance lazy1StateT :: Lazy1 (StateT s m) +``` + + +#### `liftCatchState` + +``` purescript +liftCatchState :: forall s m e a. (m (Tuple a s) -> (e -> m (Tuple a s)) -> m (Tuple a s)) -> StateT s m a -> (e -> StateT s m a) -> StateT s m a +``` + + +#### `liftListenState` + +``` purescript +liftListenState :: forall s m a w. (Monad m) => (m (Tuple a s) -> m (Tuple (Tuple a s) w)) -> StateT s m a -> StateT s m (Tuple a w) +``` + + +#### `liftPassState` + +``` purescript +liftPassState :: forall s m a b w. (Monad m) => (m (Tuple (Tuple a s) b) -> m (Tuple a s)) -> StateT s m (Tuple a b) -> StateT s m a +``` + + +#### `liftCallCCState` + +``` purescript +liftCallCCState :: forall s m a b. (((Tuple a s -> m (Tuple b s)) -> m (Tuple a s)) -> m (Tuple a s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a +``` + + +#### `liftCallCCState'` + +``` purescript +liftCallCCState' :: forall s m a b. (((Tuple a s -> m (Tuple b s)) -> m (Tuple a s)) -> m (Tuple a s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a +``` - withStateT :: forall s m a. (s -> s) -> StateT s m a -> StateT s m a ## Module Control.Monad.Trans -### Type Classes +#### `MonadTrans` + +``` purescript +class MonadTrans t where + lift :: forall m a. (Monad m) => m a -> t m a +``` - class MonadTrans t where - lift :: forall m a. (Monad m) => m a -> t m a ## Module Control.Monad.Writer -### Types +#### `Writer` - type Writer w = WriterT w Identity +``` purescript +type Writer w = WriterT w Identity +``` -### Values +#### `runWriter` - execWriter :: forall w a. Writer w a -> w +``` purescript +runWriter :: forall w a. Writer w a -> Tuple a w +``` - mapWriter :: forall w1 w2 a b. (Tuple a w1 -> Tuple b w2) -> Writer w1 a -> Writer w2 b - runWriter :: forall w a. Writer w a -> Tuple a w +#### `execWriter` + +``` purescript +execWriter :: forall w a. Writer w a -> w +``` + + +#### `mapWriter` + +``` purescript +mapWriter :: forall w1 w2 a b. (Tuple a w1 -> Tuple b w2) -> Writer w1 a -> Writer w2 b +``` + ## Module Control.Monad.Writer.Class -### Type Classes +#### `MonadWriter` + +``` purescript +class MonadWriter w m where + writer :: forall a. Tuple a w -> m a + listen :: forall a. m a -> m (Tuple a w) + pass :: forall a. m (Tuple a (w -> w)) -> m a +``` + + +#### `tell` + +``` purescript +tell :: forall w m a. (Monoid w, Monad m, MonadWriter w m) => w -> m Unit +``` + + +#### `listens` + +``` purescript +listens :: forall w m a b. (Monoid w, Monad m, MonadWriter w m) => (w -> b) -> m a -> m (Tuple a b) +``` - class MonadWriter w m where - writer :: forall a. Tuple a w -> m a - listen :: forall a. m a -> m (Tuple a w) - pass :: forall a. m (Tuple a (w -> w)) -> m a +#### `censor` -### Type Class Instances +``` purescript +censor :: forall w m a. (Monoid w, Monad m, MonadWriter w m) => (w -> w) -> m a -> m a +``` - instance monadWriterErrorT :: (Monad m, MonadWriter w m) => MonadWriter w (ErrorT e m) - instance monadWriterMaybeT :: (Monad m, MonadWriter w m) => MonadWriter w (MaybeT m) +#### `monadWriterWriterT` - instance monadWriterRWST :: (Monad m, Monoid w) => MonadWriter w (RWST r w s m) +``` purescript +instance monadWriterWriterT :: (Monoid w, Monad m) => MonadWriter w (WriterT w m) +``` - instance monadWriterReaderT :: (Monad m, MonadWriter w m) => MonadWriter w (ReaderT r m) - instance monadWriterStateT :: (Monad m, MonadWriter w m) => MonadWriter w (StateT s m) +#### `monadWriterErrorT` - instance monadWriterWriterT :: (Monoid w, Monad m) => MonadWriter w (WriterT w m) +``` purescript +instance monadWriterErrorT :: (Monad m, MonadWriter w m) => MonadWriter w (ErrorT e m) +``` -### Values +#### `monadWriterMaybeT` - censor :: forall w m a. (Monoid w, Monad m, MonadWriter w m) => (w -> w) -> m a -> m a +``` purescript +instance monadWriterMaybeT :: (Monad m, MonadWriter w m) => MonadWriter w (MaybeT m) +``` - listens :: forall w m a b. (Monoid w, Monad m, MonadWriter w m) => (w -> b) -> m a -> m (Tuple a b) - tell :: forall w m a. (Monoid w, Monad m, MonadWriter w m) => w -> m Unit +#### `monadWriterStateT` + +``` purescript +instance monadWriterStateT :: (Monad m, MonadWriter w m) => MonadWriter w (StateT s m) +``` + + +#### `monadWriterReaderT` + +``` purescript +instance monadWriterReaderT :: (Monad m, MonadWriter w m) => MonadWriter w (ReaderT r m) +``` + + +#### `monadWriterRWST` + +``` purescript +instance monadWriterRWST :: (Monad m, Monoid w) => MonadWriter w (RWST r w s m) +``` + ## Module Control.Monad.Writer.Trans -### Types +#### `WriterT` + +``` purescript +newtype WriterT w m a + = WriterT (m (Tuple a w)) +``` + + +#### `runWriterT` + +``` purescript +runWriterT :: forall w m a. WriterT w m a -> m (Tuple a w) +``` + + +#### `execWriterT` + +``` purescript +execWriterT :: forall w m a. (Apply m) => WriterT w m a -> m w +``` + + +#### `mapWriterT` + +``` purescript +mapWriterT :: forall w1 w2 m1 m2 a b. (m1 (Tuple a w1) -> m2 (Tuple b w2)) -> WriterT w1 m1 a -> WriterT w2 m2 b +``` + + +#### `functorWriterT` + +``` purescript +instance functorWriterT :: (Functor m) => Functor (WriterT w m) +``` + + +#### `applyWriterT` + +``` purescript +instance applyWriterT :: (Monoid w, Apply m) => Apply (WriterT w m) +``` + + +#### `applicativeWriterT` + +``` purescript +instance applicativeWriterT :: (Monoid w, Applicative m) => Applicative (WriterT w m) +``` + + +#### `altWriterT` + +``` purescript +instance altWriterT :: (Monoid w, Alt m) => Alt (WriterT w m) +``` + + +#### `plusWriterT` + +``` purescript +instance plusWriterT :: (Monoid w, Plus m) => Plus (WriterT w m) +``` + - newtype WriterT w m a where - WriterT :: m (Tuple a w) -> WriterT w m a +#### `alternativeWriterT` +``` purescript +instance alternativeWriterT :: (Monoid w, Alternative m) => Alternative (WriterT w m) +``` -### Type Class Instances - instance altWriterT :: (Monoid w, Alt m) => Alt (WriterT w m) +#### `bindWriterT` - instance alternativeWriterT :: (Monoid w, Alternative m) => Alternative (WriterT w m) +``` purescript +instance bindWriterT :: (Monoid w, Monad m) => Bind (WriterT w m) +``` - instance applicativeWriterT :: (Monoid w, Applicative m) => Applicative (WriterT w m) - instance applyWriterT :: (Monoid w, Apply m) => Apply (WriterT w m) +#### `monadWriterT` - instance bindWriterT :: (Monoid w, Monad m) => Bind (WriterT w m) +``` purescript +instance monadWriterT :: (Monoid w, Monad m) => Monad (WriterT w m) +``` - instance functorWriterT :: (Functor m) => Functor (WriterT w m) - instance monadPlusWriterT :: (Monoid w, MonadPlus m) => MonadPlus (WriterT w m) +#### `monadPlusWriterT` - instance monadTransWriterT :: (Monoid w) => MonadTrans (WriterT w) +``` purescript +instance monadPlusWriterT :: (Monoid w, MonadPlus m) => MonadPlus (WriterT w m) +``` - instance monadWriterT :: (Monoid w, Monad m) => Monad (WriterT w m) - instance plusWriterT :: (Monoid w, Plus m) => Plus (WriterT w m) +#### `monadTransWriterT` +``` purescript +instance monadTransWriterT :: (Monoid w) => MonadTrans (WriterT w) +``` -### Values - execWriterT :: forall w m a. (Apply m) => WriterT w m a -> m w +#### `liftCatchWriter` - liftCallCCWriter :: forall w m a b. (Monoid w) => (((Tuple a w -> m (Tuple b w)) -> m (Tuple a w)) -> m (Tuple a w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m a +``` purescript +liftCatchWriter :: forall w m e a. (m (Tuple a w) -> (e -> m (Tuple a w)) -> m (Tuple a w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a +``` - liftCatchWriter :: forall w m e a. (m (Tuple a w) -> (e -> m (Tuple a w)) -> m (Tuple a w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a - mapWriterT :: forall w1 w2 m1 m2 a b. (m1 (Tuple a w1) -> m2 (Tuple b w2)) -> WriterT w1 m1 a -> WriterT w2 m2 b +#### `liftCallCCWriter` - runWriterT :: forall w m a. WriterT w m a -> m (Tuple a w) +``` purescript +liftCallCCWriter :: forall w m a b. (Monoid w) => (((Tuple a w -> m (Tuple b w)) -> m (Tuple a w)) -> m (Tuple a w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m a +``` \ No newline at end of file diff --git a/src/Control/Monad/RWS/Trans.purs b/src/Control/Monad/RWS/Trans.purs index 9bc25f82..2ee089f9 100644 --- a/src/Control/Monad/RWS/Trans.purs +++ b/src/Control/Monad/RWS/Trans.purs @@ -33,15 +33,19 @@ withRWST f m = RWST \r s -> uncurry (runRWST m) (f r s) instance functorRWST :: (Functor m) => Functor (RWST r w s m) where (<$>) f m = RWST \r s -> (\see -> see{result = f see.result}) <$> runRWST m r s -instance applyRWST :: (Apply m, Semigroup w) => Apply (RWST r w s m) where +instance applyRWST :: (Bind m, Monoid w) => Apply (RWST r w s m) where (<*>) f m = RWST \r s -> - (\{result = f, log = l} see -> see{result = f see.result, log = l <> see.log}) <$> runRWST f r s <*> runRWST m r s + runRWST f r s >>= \{state = s', result = f', log = w'} -> + runRWST m r s' <#> \{state = s'', result = a'', log = w''} -> + mkSee s'' (f' a'') (w' ++ w'') -instance bindRWST :: (Bind m, Semigroup w) => Bind (RWST r w s m) where - (>>=) m f = RWST \r s -> runRWST m r s >>= \{result = a, state = s', log = l} -> - (\see' -> see'{log = l <> see'.log}) <$> runRWST (f a) r s' +instance bindRWST :: (Bind m, Monoid w) => Bind (RWST r w s m) where + (>>=) m f = RWST \r s -> + runRWST m r s >>= \{result = a, state = s', log = l} -> + runRWST (f a) r s' <#> \see' -> + see'{log = l ++ see'.log} -instance applicativeRWST :: (Applicative m, Monoid w) => Applicative (RWST r w s m) where +instance applicativeRWST :: (Monad m, Monoid w) => Applicative (RWST r w s m) where pure a = RWST \_ s -> pure $ mkSee s a mempty instance monadRWST :: (Monad m, Monoid w) => Monad (RWST r w s m)