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 WAA32565 for caml-red; Sun, 3 Sep 2000 22:21:59 +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 VAA13056 for ; Fri, 1 Sep 2000 21:17:02 +0200 (MET DST) Received: from mail.mimuw.edu.pl (pm37.warszawa.cvx.ppp.tpnet.pl [213.76.108.37]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e81JGdP18726 for ; Fri, 1 Sep 2000 21:16:50 +0200 (MET DST) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id VAA22212 for caml-list@inria.fr; Fri, 1 Sep 2000 21:12:27 +0200 X-Authentication-Warning: qrnik.knm.org.pl: news set sender to qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) using -f From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) Subject: Re: Language Design Date: 1 Sep 2000 19:12:24 GMT Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <3145774E67D8D111BE6E00C0DF418B662D78C0@nt.kal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: qrnik.knm.org.pl 967835544 22208 127.0.0.1 (1 Sep 2000 19:12:24 GMT) X-Complaints-To: news@qrnik.knm.org.pl NNTP-Posting-Date: 1 Sep 2000 19:12:24 GMT User-Agent: slrn/0.9.6.2 (Linux) To: caml-list@inria.fr Cc: Dave Berry Sender: weis@pauillac.inria.fr Fri, 1 Sep 2000 12:57:13 +0100, Dave Berry pisze: > Given a value in a monad, e.g. IO v, how can I remove v from the Monad? For Haskell's IO monad, you don't have a function of type IO v -> v. IO is carried up to main, the "action of the whole program". Other monads may or may not provide a similar function. > Surely this would be required to seamlessly integrate stateful and > functional code? In a pure language it is not possible to create a function which does I/O when applied. If an operation may do I/O, it is reflected in its type and usage. It may be considered a good thing, and is practically a must in a lazy language. In some Haskell implementations there is monad called ST (state transformer) which provides mutable references and arrays, and can be wrapped in a pure function. Not all stateful code requires IO. Actually in some implementations there is unsafePerformIO :: IO a -> a but it's, well, unsafe. It's sometimes very useful for real life problems. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK