From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id E7EAFBBAF for ; Tue, 22 Jul 2008 12:56:22 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj0FAKBZhUiYToBmYWdsb2JhbACSPRcECRgFnTw X-IronPort-AV: E=Sophos;i="4.31,230,1215381600"; d="scan'208";a="13346299" Received: from mailgate1.iss.soton.ac.uk ([152.78.128.102]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Jul 2008 12:56:22 +0200 Received: from [152.78.96.56] (alpha.kk.soton.ac.uk [152.78.96.56]) (authenticated bits=0) by mailgate1.iss.soton.ac.uk (8.13.8/8.13.4) with ESMTP id m6MAu5kU025313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Jul 2008 11:56:05 +0100 Message-ID: <4885BCC5.6080802@soton.ac.uk> Date: Tue, 22 Jul 2008 11:56:05 +0100 From: "Dr. Thomas Fischbacher" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2 X-Accept-Language: en MIME-Version: 1.0 To: Paolo Donadeo Cc: caml-list caml-list Subject: Re: [Caml-list] Disappointment References: <4b5157c30807211428r19ef9865n6a65e81ac2f5fe31@mail.gmail.com> In-Reply-To: <4b5157c30807211428r19ef9865n6a65e81ac2f5fe31@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-3.0 (mailgate1.iss.soton.ac.uk [152.78.128.102]); Tue, 22 Jul 2008 11:56:10 +0100 (BST) X-ISS-MailScanner-Information: Please contact Serviceline@soton.ac.uk for more information X-ISS-MailScanner: Found to be clean X-ISS-MailScanner-SpamCheck: X-Spam: no; 0.00; monads:01 monads:01 monadic:01 corresponds:01 haskell's:01 monadic:01 conceptually:01 computations:01 vaguely:01 haskell:01 aroused:98 utilizes:98 wrote:01 arnaud:01 abstract:01 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