monadLib-3.10.3: A collection of monad transformers.
Safe HaskellSafe
LanguageHaskell2010

MonadLib.Derive

Description

This module defines a number of functions that make it easy to get the functionality of MonadLib for user-defined newtypes.

Synopsis

Documentation

data Iso (m :: Type -> Type) (n :: Type -> Type) Source #

An isomorphism between (usually) monads. Typically the constructor and selector of a newtype delcaration.

Constructors

Iso (forall a. m a -> n a) (forall a. n a -> m a) 

derive_fmap :: forall (m :: Type -> Type) n a b. Functor m => Iso m n -> (a -> b) -> n a -> n b Source #

Derive the implementation of fmap from Functor.

derive_pure :: forall (m :: Type -> Type) n a. Applicative m => Iso m n -> a -> n a Source #

Derive the implementation of pure from Applicative.

derive_apply :: forall (m :: Type -> Type) n a b. Applicative m => Iso m n -> n (a -> b) -> n a -> n b Source #

Derive the implementation of <*> from Applicative.

derive_empty :: forall (m :: Type -> Type) n a. Alternative m => Iso m n -> n a Source #

Derive the implementation of empty from Alternative.

derive_or :: forall (m :: Type -> Type) n a. Alternative m => Iso m n -> n a -> n a -> n a Source #

Derive the implementation of <|> from Alternative.

derive_return :: forall (m :: Type -> Type) n a. Monad m => Iso m n -> a -> n a Source #

Derive the implementation of return from Monad.

derive_bind :: forall (m :: Type -> Type) n a b. Monad m => Iso m n -> n a -> (a -> n b) -> n b Source #

Derive the implementation of >>= from Monad.

derive_fail :: forall (m :: Type -> Type) n a. MonadFail m => Iso m n -> String -> n a Source #

derive_mzero :: forall (m :: Type -> Type) n a. MonadPlus m => Iso m n -> n a Source #

Derive the implementation of mzero from MonadPlus.

derive_mplus :: forall (m :: Type -> Type) n a. MonadPlus m => Iso m n -> n a -> n a -> n a Source #

Derive the implementation of mplus from MonadPlus.

derive_mfix :: forall (m :: Type -> Type) n a. MonadFix m => Iso m n -> (a -> n a) -> n a Source #

Derive the implementation of mfix from MonadFix.

derive_ask :: forall (m :: Type -> Type) i n. ReaderM m i => Iso m n -> n i Source #

Derive the implementation of ask from ReaderM.

derive_local :: forall (m :: Type -> Type) i n a. RunReaderM m i => Iso m n -> i -> n a -> n a Source #

Derive the implementation of local from RunReaderM.

derive_put :: forall (m :: Type -> Type) i n. WriterM m i => Iso m n -> i -> n () Source #

Derive the implementation of put from WriterM.

derive_collect :: forall (m :: Type -> Type) i n a. RunWriterM m i => Iso m n -> n a -> n (a, i) Source #

Derive the implementation of collect from RunWriterM.

derive_get :: forall (m :: Type -> Type) i n. StateM m i => Iso m n -> n i Source #

Derive the implementation of get from StateM.

derive_set :: forall (m :: Type -> Type) i n. StateM m i => Iso m n -> i -> n () Source #

Derive the implementation of set from StateM.

derive_raise :: forall (m :: Type -> Type) i n a. ExceptionM m i => Iso m n -> i -> n a Source #

Derive the implementation of raise from ExceptionM.

derive_try :: forall (m :: Type -> Type) i n a. RunExceptionM m i => Iso m n -> n a -> n (Either i a) Source #

Derive the implementation of try from RunExceptionM.

derive_callWithCC :: forall (m :: Type -> Type) n a. ContM m => Iso m n -> ((a -> Label n) -> n a) -> n a Source #

Derive the implementation of callWithCC from ContM.

derive_abort :: forall (m :: Type -> Type) i n a. AbortM m i => Iso m n -> i -> n a Source #

derive_lift :: forall (t :: (Type -> Type) -> Type -> Type) m n a. (MonadT t, Monad m) => Iso (t m) n -> m a -> n a Source #

Derive the implementation of lift from MonadT.

derive_inBase :: forall (m :: Type -> Type) x n a. BaseM m x => Iso m n -> x a -> n a Source #

Derive the implementation of inBase from BaseM.

derive_runM :: forall (m :: Type -> Type) a r n. RunM m a r => Iso m n -> n a -> r Source #

Derive the implementation of the runM function from RunM.