[Haskell-cafe] On finding the right exposition... (Monads)

Brandon Allbery allbery.b at gmail.com
Fri Sep 17 20:47:09 UTC 2021


I suspect a lot of people were pleased that they'd finally gotten rid of
lazy Result -> Request.

On Fri, Sep 17, 2021 at 4:34 PM Joachim Durchholz <jo at durchholz.org> wrote:

> Am 17.09.21 um 21:47 schrieb Viktor Dukhovni:
> > Personally [verbal sequential], I find strained analogies unhelpful
> > and distracting, so no desk clerks shuffling forms for me.
> >
> > I internalised Haskell monads, by implementing the Functor, Applicative
> > and Monad instances for Reader and State a few times from scratch.  Once
> > those were solid, ReaderT and StateT and their MonadTrans instances.
> >
> > Unsurpsingly, I have a mental model built around sequencing of internal
> > state updates while passing data from one state to use in choosing the
> > next state transition.
>
> I have been finding the Monad expositions misleading - that idea that
> monads are for sequencing or transitions or mutable state always felt
> wrong to me, since the monad laws don't talk about any of these things
> at all.
>
> And as far as I could understand the concept, monads are not about
> state, they're about "composing a linear sequence of functions". The
> functions' types need not be the same (that would degenerate into the
> concept of associativity), but the result type of one function must be
> the parameter type of the next.
> The monad can do whatever it likes with the functions - typically, wrap
> them in some other function and construct a function composition; there
> isn't much else you can do with them, though you're not doing much
> justice to the Maybe monad if you see it as a pipeline.
> Ah... right... and of course the pseudo associativity. I.e. it doesn't
> matter what parts of the total sequence you construct first.
>
> Of course, state transitions are a fine application of this concept.
> Or anything else where you see a function as a computation step and you
> want to run these steps in sequence.
> It's just that there are more kinds of monads.
> Except if you see Maybe as "do these operations in sequence until you
> hit the first that returns None, then abort". It depends on seeing
> functions as executable things though, and that's not really what
> Haskell is trying to be (or was trying to be 20 years ago, maybe
> everybody is now happy that Haskel finally can express imperative stuff
> via monads... no idea what people think)
>
> Regards,
> Jo
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.



-- 
brandon s allbery kf8nh
allbery.b at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210917/1034edbc/attachment.html>


More information about the Haskell-Cafe mailing list