freer-effects icon indicating copy to clipboard operation
freer-effects copied to clipboard

TemplateHaskell for convenience funtions

Open xkollar opened this issue 8 years ago • 2 comments

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.

xkollar avatar Feb 21 '17 22:02 xkollar

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, ...).

xkollar avatar Mar 14 '17 10:03 xkollar

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

isovector avatar Mar 15 '17 04:03 isovector