Safe Haskell | Safe |
---|
This module defines a number of functions that make it easy to get the functionality of MonadLib for user-defined newtypes.
- data Iso m n = Iso (forall a. m a -> n a) (forall a. n a -> m a)
- derive_fmap :: Functor m => Iso m n -> (a -> b) -> n a -> n b
- derive_pure :: Applicative m => Iso m n -> a -> n a
- derive_apply :: Applicative m => Iso m n -> n (a -> b) -> n a -> n b
- derive_empty :: Alternative m => Iso m n -> n a
- derive_or :: Alternative m => Iso m n -> n a -> n a -> n a
- derive_return :: Monad m => Iso m n -> a -> n a
- derive_bind :: Monad m => Iso m n -> n a -> (a -> n b) -> n b
- derive_fail :: Monad m => Iso m n -> String -> n a
- derive_mzero :: MonadPlus m => Iso m n -> n a
- derive_mplus :: MonadPlus m => Iso m n -> n a -> n a -> n a
- derive_mfix :: MonadFix m => Iso m n -> (a -> n a) -> n a
- derive_ask :: ReaderM m i => Iso m n -> n i
- derive_local :: RunReaderM m i => Iso m n -> i -> n a -> n a
- derive_put :: WriterM m i => Iso m n -> i -> n ()
- derive_collect :: RunWriterM m i => Iso m n -> n a -> n (a, i)
- derive_get :: StateM m i => Iso m n -> n i
- derive_set :: StateM m i => Iso m n -> i -> n ()
- derive_raise :: ExceptionM m i => Iso m n -> i -> n a
- derive_try :: RunExceptionM m i => Iso m n -> n a -> n (Either i a)
- derive_callWithCC :: ContM m => Iso m n -> ((a -> Label n) -> n a) -> n a
- derive_abort :: AbortM m i => Iso m n -> i -> n a
- derive_lift :: (MonadT t, Monad m) => Iso (t m) n -> m a -> n a
- derive_inBase :: BaseM m x => Iso m n -> x a -> n a
- derive_runM :: RunM m a r => Iso m n -> n a -> r
Documentation
An isomorphism between (usually) monads. Typically the constructor and selector of a newtype delcaration.
Iso (forall a. m a -> n a) (forall a. n a -> m a) |
derive_fmap :: Functor m => Iso m n -> (a -> b) -> n a -> n bSource
derive_pure :: Applicative m => Iso m n -> a -> n aSource
Derive the implementation of pure
from Applicative
.
derive_apply :: Applicative m => Iso m n -> n (a -> b) -> n a -> n bSource
Derive the implementation of <*>
from Applicative
.
derive_empty :: Alternative m => Iso m n -> n aSource
Derive the implementation of empty
from Alternative
.
derive_or :: Alternative m => Iso m n -> n a -> n a -> n aSource
Derive the implementation of <|>
from Alternative
.
derive_return :: Monad m => Iso m n -> a -> n aSource
derive_bind :: Monad m => Iso m n -> n a -> (a -> n b) -> n bSource
derive_fail :: Monad m => Iso m n -> String -> n aSource
derive_mzero :: MonadPlus m => Iso m n -> n aSource
derive_mplus :: MonadPlus m => Iso m n -> n a -> n a -> n aSource
derive_mfix :: MonadFix m => Iso m n -> (a -> n a) -> n aSource
derive_local :: RunReaderM m i => Iso m n -> i -> n a -> n aSource
Derive the implementation of local
from RunReaderM
.
derive_put :: WriterM m i => Iso m n -> i -> n ()Source
derive_collect :: RunWriterM m i => Iso m n -> n a -> n (a, i)Source
Derive the implementation of collect
from RunWriterM
.
derive_raise :: ExceptionM m i => Iso m n -> i -> n aSource
Derive the implementation of raise
from ExceptionM
.
derive_try :: RunExceptionM m i => Iso m n -> n a -> n (Either i a)Source
Derive the implementation of try
from RunExceptionM
.
derive_callWithCC :: ContM m => Iso m n -> ((a -> Label n) -> n a) -> n aSource
Derive the implementation of callWithCC
from ContM
.
derive_abort :: AbortM m i => Iso m n -> i -> n aSource
derive_lift :: (MonadT t, Monad m) => Iso (t m) n -> m a -> n aSource
derive_inBase :: BaseM m x => Iso m n -> x a -> n aSource