[Haskell-cafe] Yet Another Forkable Class

Alberto G. Corona agocorona at gmail.com
Thu Aug 22 13:15:20 CEST 2013

The paper is very interesting:


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.

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

2013/8/22 <oleg at okmij.org>

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130822/191079e9/attachment.htm>

More information about the Haskell-Cafe mailing list