-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Automatically generate layered monads -- -- Automatically generate layered monads @package MonadLab @version 0.0.1 module MonadLab.CommonTypes -- | The Layer data type. A monad is constructed from a list of layers. -- Each layer adds a corresponding set of non-proper morphisms (npms) for -- use in the monad. The non-proper morphisms can be thought of as the -- interface of the monad or primitives in the constructed monad -- "language". data Layer -- | The Io layer. Adds an npm for IO operations. Io :: Layer -- | The List layer. Adds an npm for expressing nondeterministic -- computation. List :: Layer -- | The Error (or Exception) layer. Adds npms for exception -- throwing/handling. ErrorT :: ErrorName -> TypeQ -> Layer -- | The State layer. Adds npms for the manipulation of a mutable state. StateT :: StateName -> TypeQ -> Layer -- | The Environment layer. Adds npms for reading/pre-setting an immutable -- environment. EnvT :: EnvName -> TypeQ -> Layer -- | The Writer layer. Adds npms for the production/manipulation of -- sequenced output. WriterT :: WriterName -> TypeQ -> Layer -- | The Continuation layer. f no List layer is included in the li , then -- the corresponding Layer transformers are composed Adds an npm for -- accessing current continuation to facilate continuation passing style -- programming. ContT :: TypeQ -> Layer type ErrorName = String type StateName = String type EnvName = String type WriterName = String data LayerType IoLayerType :: LayerType ListLayerType :: LayerType StateLayerType :: LayerType EnvLayerType :: LayerType ErrorLayerType :: LayerType WriterLayerType :: LayerType ContLayerType :: LayerType layerType :: Layer -> LayerType hasLayerType :: LayerType -> Layer -> Bool -- | The monad type. Each component contains abstract syntax of the Haskell -- code to implement the monad. Components are (code for the data type, -- code for the return, code for the bind, code for the non-proper -- morphisms, code for the monad lifting) type Monad = (MonadTypeCon, ReturnExpQ, BindExpQ, [LayerNPM], LiftExpQ) -- | The name of monad type constructor identifier type MonadName = String -- | The monad type constructor type. type MonadTypeCon = TypeQ -> TypeQ -- | Code for a monad return type ReturnExpQ = ExpQ -- | Code for a monad bind type BindExpQ = ExpQ -- | Code for a monad lifting type LiftExpQ = ExpQ -- | Code for a monad join type JoinExpQ = ExpQ -- | Code for a monad run (evaluation) type RunExpQ = ExpQ -- | Code for a monad non-proper morphism type NonProperMorphismExpQ = ExpQ -- | Monad transformer data type type MonadTransformer = Monad -> Monad -- | Data type to hold a layer's non-proper morphisms type LayerNPM = (Layer, [NonProperMorphismExpQ]) -- | Type constructor accessor getTypeCon :: Monad -> MonadTypeCon -- | Return accessor getReturn :: Monad -> ReturnExpQ -- | Bind accessor getBind :: Monad -> BindExpQ -- | Layers accessor getLayerNPMs :: Monad -> [LayerNPM] -- | Base monad lifting accessor getBaseLift :: Monad -> LiftExpQ -- | Join accessor getJoin :: Monad -> JoinExpQ int :: TypeQ -- | Short hand for [t| Int |], [t| Bool |], and [t| String |] bool :: TypeQ string :: TypeQ -- | Definition of composition function for use in TH expressions composition :: ExpQ -- | Convenience function for expressing type t -> t' in TH arrow :: TypeQ -> TypeQ -> TypeQ instance Eq LayerType module MonadLab.MonadLab mkMonad :: MonadName -> [Layer] -> Q [Dec] -- | The Layer data type. A monad is constructed from a list of layers. -- Each layer adds a corresponding set of non-proper morphisms (npms) for -- use in the monad. The non-proper morphisms can be thought of as the -- interface of the monad or primitives in the constructed monad -- "language". data Layer -- | The Io layer. Adds an npm for IO operations. Io :: Layer -- | The List layer. Adds an npm for expressing nondeterministic -- computation. List :: Layer -- | The Error (or Exception) layer. Adds npms for exception -- throwing/handling. ErrorT :: ErrorName -> TypeQ -> Layer -- | The State layer. Adds npms for the manipulation of a mutable state. StateT :: StateName -> TypeQ -> Layer -- | The Environment layer. Adds npms for reading/pre-setting an immutable -- environment. EnvT :: EnvName -> TypeQ -> Layer -- | The Writer layer. Adds npms for the production/manipulation of -- sequenced output. WriterT :: WriterName -> TypeQ -> Layer -- | The Continuation layer. f no List layer is included in the li , then -- the corresponding Layer transformers are composed Adds an npm for -- accessing current continuation to facilate continuation passing style -- programming. ContT :: TypeQ -> Layer errorTRec :: String -> String -> Layer stateTRec :: String -> String -> Layer envTRec :: String -> String -> Layer writerTRec :: String -> String -> Layer contTRec :: String -> Layer module MonadLab.MLabParser mlabParser :: String -> (MonadName, [Layer])