EvEff
EvEff copied to clipboard
Add monad effects
Fixes #2
I'm happy to discuss any suggestions for improving this.
Also note that I've put my own name in the copyright field on line 4, I am not certain if that is the right thing to do.
Edit: And maybe we should have a more explicit constraint that the MEff should be the last one in the effect stack. Something like:
class Last h e where
lastContext :: Context e -> Context (h :* ())
instance Last h (h :* ()) where
lastContext = id
instance Last h e => Last h (h' :* e) where
lastContext ctx = lastContext (ctail ctx)
-- I've chosen $ because it means end of a line in regular expressions.
type h :$? e = Last h e
Thanks for the pull request! I will take a look during this weekend.
@xnning I think this pull request is a bit outdated. Wrapping Ctl
with IO
like I do in #7 is in my opinion a much better and probably much more performant way to implement IO
. The only problem perhaps is that the performance of non-IO code takes a small hit, but on the other hand it improves the correctness of code that uses the Local
effect (see #6).
There are some different designs. For example, you could wrap Ctl
with an arbitrary monad m
then code that doesn't use Local
or IO
can use Identity
for that m
and code that only wants a Local
effect could perhaps use ST
and code that don't use either can use Identity
. With Identity
there should be no overhead over the current, but then you cannot use Local
anymore.