Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Brown <caml-list@davidb.org>
To: "CAML Mailing list" <caml-list@inria.fr>
Subject: Re: A propos de monad/About monads
Date: Sat, 2 Oct 1999 11:10:06 -0700 (PDT)	[thread overview]
Message-ID: <14326.19070.393311.979061@opus.davidb.org> (raw)
In-Reply-To: <wd8n1u3v3c7.fsf@parate.irisa.fr>

David Mentr'e writes:

 > Monads are a way to encapsulate side-effects in functionnal
 > languages. Does anyboody have a more detailed explaination about how
 > monads really work ? What is the difference between the usual let and
 > the monad binding ?

Monads are primarily to encourage a lasy language (such as haskell) to 
evaluate side-effecting operations in a specific order.

In caml,

   let a = foo x y z in
   let b = bar g h i in
   blort a b

foo will be called before bar, and both will be called before blort.
So, if there are side effects in foo, and bar, and blort, we know what 
order these will happen in.

In a lazy language, foo will not be evaluated until blort needs to use 
its first argument.  Things could happen in blort before that.
Consequentially, some mechanism is needed to ensure an order.  Instead 
of "hiding" side-effecting operations wherever convenient, they are
encapsulated into a monad.  Other messages have given good references
to explanations.

Basically, instead of a function performing an operation, it returns a 
function that will perform that operation.  Monads provide a
convenient way to sequence these.  Also, the main program will return
a monad.  It is up to the runtime to then perform this operation
(basically outside of the scope of the language).

Dave Brown




  reply	other threads:[~1999-10-03 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-30 16:24 A propos de monad Stéphane Baubillier
1999-10-01  7:17 ` David Gross
1999-10-01  9:26 ` A propos de monad/About monads David Mentr'e
1999-10-02 18:10   ` David Brown [this message]
1999-10-04  8:40   ` Frank A. Christoph
1999-10-04 14:46     ` Frank A. Christoph
1999-10-04 21:20       ` Jan Skibinski
1999-10-04 18:55     ` John Prevost
1999-10-05  5:48       ` Frank A. Christoph

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=14326.19070.393311.979061@opus.davidb.org \
    --to=caml-list@davidb.org \
    --cc=caml-list@inria.fr \
    /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