[Haskell-cafe] IO is a bad example for Monads [was: do]

Conal Elliott conal at conal.net
Sun Dec 9 12:31:13 EST 2007


> IO is important because you can't write any real program without using it.

Ouch!  I get awfully discouraged when I read statements like this one.  The
more people who believe it, the more true it becomes.  If you want to do
functional programming, instead of imperative programming in a functional
language, you can.  For instance, write real, interactive programs in FRP,
phooey, or TV.  And if you do, you'll get semantic simplicity, powerful &
simpler reasoning, safety and composability.

  - Conal

On Dec 8, 2007 1:26 AM, Lennart Augustsson <lennart at augustsson.net> wrote:

> I agree with Dan here.
>
> IO is important because you can't write any real program without using it.
> So why not teach enough of it to get people off the ground straight away?
>
> People who hang around long enough to do some more Haskell programming
> will run into the other monads sooner or later.  But IO is an unavoidable
> step to
> writing Haskell programs.
>
>
>
>
> On Dec 4, 2007 5:11 AM, Dan Piponi < dpiponi at gmail.com> wrote:
>
> > On Dec 3, 2007 6:36 PM, Ben Franksen < ben.franksen at online.de> wrote:
> > > then the special features of IO
> > > will remain associated with monads in general, leading to a whole
> > jumble of
> > > completely wrong ideas about them.
> >
> > As I only learnt about monads a couple of years ago, the process is
> > still fresh in my mind. I wasted quite a bit of time labouring under
> > the impression that monads were primarily about sequencing. But that
> > wasn't because I incorrectly generalised from IO. It was because
> > countless people out there explicitly said they were about sequencing.
> > I suspect that if courses started with the List monad there'd be
> > countless blogs telling people that monads are a way to eliminate
> > loops from your code like the way list comprehensions are used in
> > Python.
> >
> > > This is yet another problem with IO as the standard example for
> > monads: its
> > > effect base is huge and poorly structured.
> >
> > You don't teach *all* of IO to students in one go!
> >
> > > This again makes it difficult to
> > > see exactly which intuitions about IO can be generalized to arbitrary
> > > monads and which not.
> >
> > That's true of any monad. IO is unique. [] is unique. Cont is unique.
> > All of them can lead you down the garden path. You need to see
> > multiple monads, and it helps if you can sneak an example under a
> > student's nose so they can already reason about monads before they
> > even know what a monad is.
> >
> > > What is pointless about failure and how to handle it?
> >
> > It's pointless when you're still trying to make your first tweaks to
> > "Hello, World!" work.
> > --
> > Dan
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
> _______________________________________________
> 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/20071209/ced4803e/attachment.htm


More information about the Haskell-Cafe mailing list