| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Control.Monad.Freer.TH
Description
This module provides Template Haskell functions for automatically generating
effect operation functions (that is, functions that use send) from a given
effect algebra. For example, using the FileSystem effect from the example in
the module documentation for Control.Monad.Freer, we can write the following:
data FileSystem r where ReadFile ::FilePath-> FileSystemStringWriteFile ::FilePath->String-> FileSystem ()makeEffect''FileSystem
This will automatically generate the following functions:
readFile ::MemberFileSystem effs =>FilePath->EffeffsStringreadFile a =send(ReadFile a) writeFile ::MemberFileSystem effs =>FilePath->String->Effeffs () writeFile a b =send(WriteFile a b)
Synopsis
- makeEffect :: Name -> Q [Dec]
- makeEffect_ :: Name -> Q [Dec]
Documentation
makeEffect :: Name -> Q [Dec] Source #
If T is a GADT representing an effect algebra, as described in the module
 documentation for Control.Monad.Freer, $( automatically
 generates a function that uses makeEffect ''T)send with each operation. For more
 information, see the module documentation for Control.Monad.Freer.TH.
makeEffect_ :: Name -> Q [Dec] Source #
Like makeEffect, but does not provide type signatures. This can be used
 to attach Haddock comments to individual arguments for each generated
 function.
data Lang x where
  Output :: String -> Lang ()
makeEffect_ ''Lang
-- | Output a string.
output :: Member Lang effs
       => String    -- ^ String to output.
       -> Eff effs ()  -- ^ No result.
Note that makeEffect_ must be used before the explicit type signatures.