<div dir="ltr">I would call the approach in quine a lensy-mtl style. It's ok as far as it goes, but since you are using concrete environment values it isn't great if you want to do testing of things like database code without having a "real" backend hooked up. The typical approach then is to create your own type-class and instances<div><br></div><div> class MyBackend where ...</div><div><br></div><div> instance (MonadReader r m, HasDb r) => MyBackend m where ...</div><div><br></div><div> instance (MonadState s m, HasTestState s) => MyBackend m where ...</div><div><br></div><div>Of course, now our problem is that our module with this abstraction depends on the module with the db and the test state. Unless we create orphan instances, which I prefer to avoid. This is one area where I like the Free monad approach more because the interpreter can be built and composed with other interpreters in completely separate modules or packages because they are just values.</div><div><br></div><div>Rich</div><div><br></div><div>PS for the record, I don't strongly prefer the mtl style or the free monad style, I think they each have good qualities and bad and which one I choose tends to depend on other factors.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 19, 2016 at 10:26 AM, Christopher Allen <span dir="ltr"><<a href="mailto:cma@bitemyapp.com" target="_blank">cma@bitemyapp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It's not really more direct. It's an unordered collection of effects<br>
you can use. IME it's a less efficient mtl-style, but YMMV.<br>
<br>
Taking an example from a PureScript tutorial:<br>
<br>
func :: Eff (console :: CONSOLE, random :: RANDOM) Unit<br>
<br>
Can just as easily be:<br>
<br>
func :: (MonadConsole m, MonadGimmeRandom m) => m ()<br>
<br>
(mangled name so it doesn't overlap with a real class)<br>
<br>
There are other differences, but they haven't amounted to much for me yet.<br>
<br>
Kmett's Quine has a good example of some homespun mtl-style:<br>
<a href="https://github.com/ekmett/quine" rel="noreferrer" target="_blank">https://github.com/ekmett/<wbr>quine</a><br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Oct 19, 2016 at 12:17 PM, Will Yager <<a href="mailto:will.yager@gmail.com">will.yager@gmail.com</a>> wrote:<br>
> Can anyone comment on the use of Purescript-style effect monads as compared to MTL and Free? While I have not used them in practice, they seem to express the "intent" of monad composition a bit more directly than the approaches we use in Haskell.<br>
><br>
> Cheers,<br>
> Will<br>
> ______________________________<wbr>_________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Chris Allen<br>
Currently working on <a href="http://haskellbook.com" rel="noreferrer" target="_blank">http://haskellbook.com</a><br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br></div>