<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>It seems that there are several advantages to the Purescript approach. </div><div><br></div><div>For example, this </div><div><br></div><div><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><code class="sourceCode haskell" style="line-height: 16.200000762939453px; white-space: normal; background-color: rgba(255, 255, 255, 0);"><font face="UICTFontTextStyleBody">catchException
<span class="ot">  ::</span> forall a e
   <span class="fu">.</span> (<span class="dt" style="font-weight: bold;">Error</span> <span class="ot">-></span> <span class="dt" style="font-weight: bold;">Eff</span> e a)
  <span class="ot">-></span> <span class="dt" style="font-weight: bold;">Eff</span> (<span class="ot">err ::</span> <span class="dt" style="font-weight: bold;">EXCEPTION</span> <span class="fu">|</span> e) a
  <span class="ot">-></span> <span class="dt" style="font-weight: bold;">Eff</span> e a</font></code></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0); font-family: UICTFontTextStyleBody;"> would be unwieldy to express using typeclasses, requiring at least three constraints. I also find this style easier to read than constraints, as it requires no mental substitution. E.g. if I see </span></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><span style="font-family: UICTFontTextStyleBody; white-space: normal; background-color: rgba(255, 255, 255, 0);">(Foo m, Bar m, Bar n) => Baz -> <stuff ...> -> m a</span></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">When I get to the end of the type, I have to go back to the beginning to figure out what m is. I can't read left-to-right. This happens a lot with constraint-based monad composition. </span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">Another advantage is that the Purescipt example uses a concrete type, which is often easier to reason about than "ad-hoc" typeclass abstractions like MonadRandom. However, it looks like you still get the flexibility of ad-hoc typeclasses, because you get to pick any function that discharges the effect type in the given effect monad. </span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">Like I said, I have not used it, but these are what I've noticed from topical observation. </span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">Apologies for the formatting; copying that code example appears to have confused the iOS mail app. </span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">Cheers,</span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;">Will</span></font></pre><pre class="sourceCode haskell" style="overflow: auto; line-height: 16.200000762939453px; padding: 20px;"><font face="UICTFontTextStyleBody"><span style="white-space: normal;"><br></span></font></pre></div><div><br>On Oct 19, 2016, at 12:26, Christopher Allen <<a href="mailto:cma@bitemyapp.com">cma@bitemyapp.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span>It's not really more direct. It's an unordered collection of effects</span><br><span>you can use. IME it's a less efficient mtl-style, but YMMV.</span><br><span></span><br><span>Taking an example from a PureScript tutorial:</span><br><span></span><br><span>func :: Eff (console :: CONSOLE, random :: RANDOM) Unit</span><br><span></span><br><span>Can just as easily be:</span><br><span></span><br><span>func :: (MonadConsole m, MonadGimmeRandom m) => m ()</span><br><span></span><br><span>(mangled name so it doesn't overlap with a real class)</span><br><span></span><br><span>There are other differences, but they haven't amounted to much for me yet.</span><br><span></span><br><span>Kmett's Quine has a good example of some homespun mtl-style:</span><br><span><a href="https://github.com/ekmett/quine">https://github.com/ekmett/quine</a></span><br><span></span><br><span>On Wed, Oct 19, 2016 at 12:17 PM, Will Yager <<a href="mailto:will.yager@gmail.com">will.yager@gmail.com</a>> wrote:</span><br><blockquote type="cite"><span>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.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Cheers,</span><br></blockquote><blockquote type="cite"><span>Will</span><br></blockquote><blockquote type="cite"><span>_______________________________________________</span><br></blockquote><blockquote type="cite"><span>Haskell-Cafe mailing list</span><br></blockquote><blockquote type="cite"><span>To (un)subscribe, modify options or view archives go to:</span><br></blockquote><blockquote type="cite"><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a></span><br></blockquote><blockquote type="cite"><span>Only members subscribed via the mailman list are allowed to post.</span><br></blockquote><span></span><br><span></span><br><span></span><br><span>-- </span><br><span>Chris Allen</span><br><span>Currently working on <a href="http://haskellbook.com">http://haskellbook.com</a></span><br></div></blockquote></body></html>