<div dir="ltr"><div><div>To be honest I&#39;m not so sure about these &quot;effects&quot;... Simply the fact that the Member class needs -XOverlappingInstances means that we cannot have duplicate or polymorphic effects. It will arbitrarily pick the first match in the former and fail to compile in the latter case.<br>
<br>Furthermore I don&#39;t really understand the way open sums are implemented. These unions should be disjoint, but the way they&#39;re implemented in the paper they try to be &quot;true&quot; unions which cannot be done as that would need type equality (-XOverlappingInstances is a hack around this)<br>
</div><br>A correct disjoint open sum would behave well with duplicate and polymorphic types in the type list. For example we should be able to project the open sum equivalent of Either String String into the second String but we cannot with the implementation in the paper. This means we need to ~index~ the type list instead of picking the result type and &quot;trying for equality&quot; with each entry. Something like this: <a href="http://lpaste.net/92069">http://lpaste.net/92069</a><br>
<br></div><div>Of course this is very inconvenient and simply replaces the monad transformers&#39; lifts with a static index into the &quot;effect&quot; list.<br>In general I think there is no convenient way of stacking effects that is also type safe. At some point we have to disambiguate which effect we are trying to use one way or the other. The implementation in the paper simply picks a heuristic and chooses the first effect that seems to match and discards the others.<br>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 August 2013 12:15, Alberto G. Corona <span dir="ltr">&lt;<a href="mailto:agocorona@gmail.com" target="_blank">agocorona@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The paper is very interesting:</div><div><br></div><a href="http://www.cs.indiana.edu/~sabry/papers/exteff.pdf" target="_blank">http://www.cs.indiana.edu/~sabry/papers/exteff.pdf</a><br>
<div><br></div><div>It seems that the approach is mature enough and it is better in every way than monad transformers, while at the same time the syntax may become almost identical to MTL for many uses.</div>

<div><br></div><div>I only expect to see the library in Hackage with all the blessings, and with all the instances of the MTL classes in order to make the transition form monad transformers  to ExtEff as transparent as possible</div>


</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/8/22  <span dir="ltr">&lt;<a href="mailto:oleg@okmij.org" target="_blank">oleg@okmij.org</a>&gt;</span><div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
Perhaps effect libraries (there are several to choose from) could be a<br>
better answer to Fork effects than monad transformers. One lesson from<br>
the recent research in effects is that we should start thinking what<br>
effect we want to achieve rather than which monad transformer to<br>
use. Using ReaderT or StateT or something else is an implementation<br>
detail. Once we know what effect to achieve we can write a handler, or<br>
interpreter, to implement the desired operation on the World, obeying<br>
the desired equations. And we are done.<br>
<br>
For example, with ExtEff library with which I&#39;m more familiar, the<br>
Fork effect would take as an argument a computation that cannot throw<br>
any requests. That means that the parent has to provide interpreters<br>
for all child effects. It becomes trivially to implement:<br>
<div><br>
&gt; Another example would be a child that should not be able to throw errors as<br>
&gt; opposed to the parent thread.<br>
</div>It is possible to specify which errors will be allowed for the child<br>
thread (the ones that the parent will be willing to reflect and<br>
interpret). The rest of errors will be statically prohibited then.<br>
<div><br>
&gt; instance (Protocol p) =&gt; Forkable (WebSockets p) (ReaderT (Sink p) IO) where<br>
&gt;     fork (ReaderT f) = liftIO . forkIO . f =&lt;&lt; getSink<br>
<br>
</div>This is a good illustration of too much implementation detail. Why do we<br>
need to know of (Sink p) as a Reader layer? Would it be clearer to<br>
define an Effect of sending to the socket? Computation&#39;s type will<br>
make it patent the computation is sending to the socket.<br>
The parent thread, before forking, has to provide a handler for that<br>
effect (and the handler will probably need a socket).<br>
<br>
Defining a new class for each effect is possible but not needed at<br>
all. With monad transformers, a class per effect is meant to hide the<br>
ordering of transformer layers in a monad transformer stack. Effect<br>
libraries abstract over the implementation details out of the<br>
box. Crutches -- extra classes -- are unnecessary. We can start by<br>
writing handlers on a case-by-case basis. Generalization, if any,<br>
we&#39;ll be easier to see. From my experience, generalizing from concrete<br>
cases is easier than trying to write a (too) general code at the<br>
outset. Way too often, as I read and saw, code that is meant to be<br>
reusable ends up hardly usable.<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Alberto.
</font></span></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>