From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id BFC04BB81 for ; Sat, 11 Dec 2004 19:13:36 +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 iBBIDZmm000351 for ; Sat, 11 Dec 2004 19:13:36 +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 TAA26960 for ; Sat, 11 Dec 2004 19:13:35 +0100 (MET) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBBIDYco000347 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 11 Dec 2004 19:13:35 +0100 Received: from fichte.ai.univie.ac.at (markus@localhost [127.0.0.1]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-7.1) with ESMTP id iBBIDD3M009975; Sat, 11 Dec 2004 19:13:13 +0100 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-7.1) id iBBIDD1N009974; Sat, 11 Dec 2004 19:13:13 +0100 Date: Sat, 11 Dec 2004 19:13:13 +0100 From: Markus Mottl To: Andrej Bauer Cc: caml-list , skaller@users.sourceforge.net Subject: Re: [Caml-list] environment idiom Message-ID: <20041211181313.GA9656@fichte.ai.univie.ac.at> Mail-Followup-To: Andrej Bauer , caml-list , skaller@users.sourceforge.net References: <9410EC84C0872141B27A2726613EF45D02A52E08@psmrdcex01.psm.pin.safeco.com> <41B97FD7.50309@andrej.com> <1102732237.2611.580.camel@pelican.wigram> <41BB04D8.60405@andrej.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41BB04D8.60405@andrej.com> User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce with ID 41BB38CF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41BB38CE.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; markus:01 mottl:01 markus:01 oefai:01 caml-list:01 andrej:01 wrote:01 monadic:01 implicitly:01 statically:01 monadic:01 runtime:01 oefai:01 ocaml:01 mottl:01 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 Sat, 11 Dec 2004, Andrej Bauer wrote: > But don't get me wrong. I definitely agree with John that having 10 > arguments to a functions sounds like too many, and something needs to be > done in such cases. It's just that in my web application (and I suspect > in most) I don't have 10 arguments all over the code, but more like 3 or > 4, which is ok. Certainly different types of programs require different > solutions. Another solution would be to use a state monad encapsulating the environment. It has operators for getting and setting states. Instead of passing all arguments from function to function "manually", you then just need to use the monadic bind operator, which does all that implicitly - and even purely functionally + in a statically type safe way! See my IMP-example for a monadic interpreter, which makes use of a state monad to pass around runtime environments: http://www.oefai.at/~markus/home/ocaml_sources.html Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at