From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8ED72BB81 for ; Mon, 13 Dec 2004 09:56:58 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBD8uwTT001261 for ; Mon, 13 Dec 2004 09:56:58 +0100 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 JAA21833 for ; Mon, 13 Dec 2004 09:56:57 +0100 (MET) Received: from mail.physik.uni-muenchen.de (mail.physik.uni-muenchen.de [192.54.42.129]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBD8uvpf001255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 13 Dec 2004 09:56:57 +0100 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 1D76A20032; Mon, 13 Dec 2004 09:56:57 +0100 (CET) Received: from mail.physik.uni-muenchen.de ([127.0.0.1]) by localhost (mail.physik.uni-muenchen.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 23057-01-80; Mon, 13 Dec 2004 09:56:55 +0100 (CET) Received: from mailhost.cip.physik.uni-muenchen.de (kaiser.cip.physik.uni-muenchen.de [141.84.136.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 2A09520019; Mon, 13 Dec 2004 09:56:55 +0100 (CET) Received: from eiger.cip.physik.uni-muenchen.de (eiger.cip.physik.uni-muenchen.de [141.84.136.54]) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 1F96426E87; Mon, 13 Dec 2004 09:56:55 +0100 (CET) Received: by eiger.cip.physik.uni-muenchen.de (Postfix, from userid 3092) id 174553CBC; Mon, 13 Dec 2004 09:56:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by eiger.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 14F702D686; Mon, 13 Dec 2004 09:56:55 +0100 (CET) Date: Mon, 13 Dec 2004 09:56:55 +0100 (CET) From: Thomas Fischbacher To: Michael Walter Cc: caml-list Subject: Re: [Caml-list] environment idiom In-Reply-To: <877e9a1704121218456af9df9@mail.gmail.com> Message-ID: References: <9410EC84C0872141B27A2726613EF45D02A52E08@psmrdcex01.psm.pin.safeco.com> <20041211181313.GA9656@fichte.ai.univie.ac.at> <1102809398.2611.637.camel@pelican.wigram> <20041212023636.GA12724@force.stwing.upenn.edu> <1102829608.2768.77.camel@pelican.wigram> <877e9a170412121109ec02d44@mail.gmail.com> <1102898935.2768.88.camel@pelican.wigram> <877e9a17041212180365f76e4a@mail.gmail.com> <877e9a170412121805295e4704@mail.gmail.com> <877e9a170412121844b633bb8@mail.gmail.com> <877e9a1704121218456af9df9@mail.gmail.com> X-BOFH: Daemons did it MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: amavisd-new at physik.uni-muenchen.de X-Miltered: at nez-perce with ID 41BD595A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41BD5959.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 abstraction:01 algebra:01 haskell:01 cip:98 cip:98 lambda:01 lambda:01 idiom:01 imperative:01 imperative:01 unsafe:01 debian:02 physik:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Sun, 12 Dec 2004, Michael Walter wrote: > Again I believe we are talking about different kinds of "purity". > Thomas is obviously right in that the StateTransformer monad (modulo > unsafe conversions) is pure, you are obviously right in the > (different) point that _running_ an IO fragment has side effects. The key issue is: by not doing I/O, but talking about plans how to do I/O, you go to a higher level of abstraction that allows you to do magic with such plans which you just plainly miss if you only know the imperative ways. It's just like everyone knows how to add (i.e. arithmetics), but once you learned to talk about properties of addition (i.e. algebra), you have a much richer point of view that allows you to do quite miraculous things. Of course, it's possible to just forget about all that and fall back to transliterating imperative code to IO monad code, but it is just as well possible to find the sum of all the numbers from 1 to 1000 using the following piece of Maple code: > proc sum_n(k) > local result,i; > for i from 1 to k do result:=result+i: od: result; > end; > > sum_n(1000); One surely can do this, and many people work in such a way to solve such problems, as they are used to it, but considering the power that Maple offers you, this is nothing but gross abuse of the system. It's just the same with Haskell and the IO monad. -- regards, tf@cip.physik.uni-muenchen.de (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_ (if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)