caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Dr. Thomas Fischbacher" <t.fischbacher@soton.ac.uk>
To: Paolo Donadeo <p.donadeo@gmail.com>
Cc: caml-list caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Disappointment
Date: Tue, 22 Jul 2008 11:56:05 +0100	[thread overview]
Message-ID: <4885BCC5.6080802@soton.ac.uk> (raw)
In-Reply-To: <4b5157c30807211428r19ef9865n6a65e81ac2f5fe31@mail.gmail.com>


Paolo,

> I'm disappointed with myself and my incredibly low IQ. Late this
> evening I decided -- and this is the third time -- to be enlightened
> by the concept of monad.
 >
> I like functional programming, but monads [1] must be too little to be
> grabbed by my mind. This time the interest in monads was aroused by
> the interesting article of David Teller, Arnaud Spiwack and Till
> Varoquaux [2] about the error monad, but for using the library they
> wrote I need at least some knowledge about monads and the do-notation.

Concerning the I/O monad, maybe a useful approach to think about
a member of a monadic type is to regard it as a "plan to do something".

A plan is - essentially - a data structure, i.e. a mathematical value.
There are well defined operations on plans, but there are only very
few of them. Basically, when you have a plan A do do something and a
plan B to do something, you can use those to make a plan to first do A
and then do B. Also, if you have a plan A to produce X, and, for some X,
you can find a plan B that utilizes X, you can assemble a combined plan
that says: "Use plan A to get X and then do that plan B which
corresponds to this X". After all, as plans have a chronological aspect
to them, essentially all you eventually really can do in terms of
operations on plans is to do one after the other.

So, speaking e.g. about Haskell's monadic I/O, you don't really have a
concept of "printing something", but you do have a concept of
"operations on plans that contain printing instructions". Now, in
a lazy language, such a plan can be constructed lazily, conceptually
infinietly wide and deep, and hence capture all computations. And then,
there is a special "magic wand", which says: "If you give me a plan,
I'll execute it for you". That's it.

> I tried with some tutorials found around, but I still cannot catch the
> point: what the hell is a monad?
> 
> I ask you all: can anyone make me a practical example, something
> involving strings, files, the network, an image or sound processing
> algorithm, something vaguely real? Not abstract mathematical
> structures, beautiful algebraic properties and general statements,
> please: the net is full of such tutorials, especially Haskell fan
> sites ;-)

Computer scientists like to obfuscate dead simple ideas with complicated
looking mathematics to deter commonsense-oriented people from making
embarassing observations, such as that computer science was
unable to see something that actually is pretty much obvious -
for ages... ;-)

-- 
best regards,
Thomas Fischbacher
t.fischbacher@soton.ac.uk



  parent reply	other threads:[~2008-07-22 10:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-21 21:28 Disappointment Paolo Donadeo
2008-07-21 21:42 ` [Caml-list] Disappointment Till Crueger
2008-07-22  3:41   ` Fabrice Marchant
2008-07-22  6:50 ` Gabriel Kerneis
2008-07-22 10:56 ` Dr. Thomas Fischbacher [this message]
2008-07-22 13:27   ` Axel Poigné
2008-07-22 15:17     ` Andrej Bauer
2008-07-22 15:21       ` Axel Poigné
2008-07-22 12:57 ` Nicolas Pouillard
2008-07-22 13:16   ` Dario Teixeira
2008-07-22 16:11   ` Christophe TROESTLER
2008-07-22 21:55   ` Paolo Donadeo
2008-07-22 16:10 ` Warren Harris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4885BCC5.6080802@soton.ac.uk \
    --to=t.fischbacher@soton.ac.uk \
    --cc=caml-list@yquem.inria.fr \
    --cc=p.donadeo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).