From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA08849 for caml-redistribution; Sun, 3 Oct 1999 16:16:10 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA15652 for ; Sat, 2 Oct 1999 20:10:12 +0200 (MET DST) Received: from opus.davidb.org (adsl-216-103-8-60.dsl.sndg02.pacbell.net [216.103.8.60]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA07431 for ; Sat, 2 Oct 1999 20:10:11 +0200 (MET DST) Received: (from davidb@localhost) by opus.davidb.org (8.9.3/8.9.3/Debian/GNU) id LAA27381; Sat, 2 Oct 1999 11:10:08 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14326.19070.393311.979061@opus.davidb.org> Date: Sat, 2 Oct 1999 11:10:06 -0700 (PDT) To: "CAML Mailing list" Subject: Re: A propos de monad/About monads In-Reply-To: References: <002201bf0b60$36fbc9a0$490ad227@aladin> X-Mailer: VM 6.71 under 21.1 (patch 6) "Big Bend" XEmacs Lucid From: David Brown Sender: weis 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