| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Polysemy.Internal.TH.Effect
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 Polysemy, we can write the following:
data FileSystem m a where ReadFile ::FilePath-> FileSystemStringWriteFile ::FilePath->String-> FileSystem ()makeSem''FileSystem
This will automatically generate the following functions:
readFile ::MemberFileSystem r =>FilePath->SemrStringreadFile a =send(ReadFile a) writeFile ::MemberFileSystem r =>FilePath->String->Semr () writeFile a b =send(WriteFile a b)
Documentation
makeSem_ :: Name -> Q [Dec] Source #
Like makeSem, but does not provide type signatures. This can be used
to attach Haddock comments to individual arguments for each generated
function.
data Lang m a where
Output :: String -> Lang ()
makeSem_ ''Lang
-- | Output a string.
output :: Member Lang r
=> String -- ^ String to output.
-> Sem r () -- ^ No result.
Note that makeSem_ must be used before the explicit type signatures.
Since: 0.1.2.0