freer-effects
freer-effects copied to clipboard
TemplateHaskell for convenience funtions
Let us have a look at the example code.
data Console s where
PutStrLn :: String -> Console ()
GetLine :: Console String
putStrLn :: Member Console r => String -> Eff r ()
putStrLn = send . PutStrLn
getLine :: Member Console r => Eff r String
getLine = send GetLine
It seems like putStrLn
and getLine
is very boilerplaty and could be generated by TH.
Note to self: create two functions:
- one that also generates type signatures;
- one that does not generate type signatures.
Reasoning behind this:
- Version that generate type signatures is useful for quick development and applications (without it
-Wall
fails if you do not supply type signature yourself). - Version without type signatures is there to force/enable you to write type signature. This allows you to add haddock comments to these functions and make code simpler to work with using standard *nix tools (grep, sed, ...).
I have a (very) WIP proof of concept of this here: https://github.com/IxpertaSolutions/freer-effects/compare/master...TaktInc:feature/th?expand=1
should have it done by the end of the week