<div dir="ltr">The mtl technique subsumes the free monad technique. if you have a term:<div><br></div><div>getCurrentTime :: MonadClock m => m UTCTime<br><br>Then you can *use* that function as anything that satisfies the constraint. Given an `IO` instance, that can just get the current time: `getCurrentTime :: IO UTCTime`. Given a mock instance, that can be `getCurrentTime :: MockClock UTCTime`. Given an instance on Free, you'd have `getCurrentTime :: Free CurrentTimeF UTCTime`<br><br>I generally find it more pleasant to write functions in mtl style. If you're after more concrete guarantees on the DSL you're building and see yourself doing a lot of introspection and optimization, then a Free monad approach fits the bill.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Matt Parsons</div></div></div></div>
<br><div class="gmail_quote">On Fri, Oct 14, 2016 at 11:35 AM, Damian Nadales <span dir="ltr"><<a href="mailto:damian.nadales@gmail.com" target="_blank">damian.nadales@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I was looking into free monads for designing a DSL for describing<br>
scenarios of the form:<br>
  scenario = do<br>
    aId <- createA<br>
    b0Id <- createB id<br>
    b1Id <- createB id<br>
    link b0 b1<br>
<br>
In our company we use a graph database, and currently we're setting up<br>
the test data using raw queries O.O So I wanted to come up with a<br>
better abstraction, and also enable us to do property based testing<br>
(by testing on random scenarios like the one above).<br>
<br>
Anyway, I ran into this presentation:<br>
    <a href="http://www.slideshare.net/jdegoes/mtl-versus-free" rel="noreferrer" target="_blank">http://www.slideshare.net/<wbr>jdegoes/mtl-versus-free</a><br>
    <a href="http://degoes.net/articles/modern-fp-part-2" rel="noreferrer" target="_blank">http://degoes.net/articles/<wbr>modern-fp-part-2</a><br>
<br>
In which monad transformers and free monads are compared. Do you have<br>
any experience using any of these approaches. If so would you mind<br>
sharing? ;)<br>
<br>
Thanks!<br>
Damian<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.</blockquote></div><br></div>