From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p08MlW7k011540 for ; Sat, 8 Jan 2011 23:47:32 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugEAH53KE1XaqLJgWdsb2JhbACkQxUBARYiJLoThUwEjio X-IronPort-AV: E=Sophos;i="4.60,295,1291590000"; d="scan'208";a="86334082" Received: from ka.mail.enyo.de ([87.106.162.201]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Jan 2011 23:47:27 +0100 Received: from [172.17.135.4] (helo=deneb.enyo.de) by ka.mail.enyo.de with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1PbhZF-0006C3-1l; Sat, 08 Jan 2011 23:47:25 +0100 Received: from fw by deneb.enyo.de with local (Exim 4.72) (envelope-from ) id 1PbhZE-0004Wh-Qw; Sat, 08 Jan 2011 23:47:24 +0100 From: Florian Weimer To: Elias Gabriel Amaral da Silva Cc: Dario Teixeira , caml-list@inria.fr References: <699537.6718.qm@web111509.mail.gq1.yahoo.com> <87vd20plpv.fsf@mid.deneb.enyo.de> Date: Sat, 08 Jan 2011 23:47:24 +0100 In-Reply-To: (Elias Gabriel Amaral da Silva's message of "Fri, 7 Jan 2011 21:26:56 -0300") Message-ID: <87ipxzhv2b.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p08MlW7k011540 Subject: Re: [Caml-list] Purity and lazyness * Elias Gabriel Amaral da Silva: >> As specified, Haskell is not a pure language because every pattern >> match can have side effects.  The Haskell community is split between >> those who think that this is a good thing, and those that consider it >> problematic.  (Obviously, there is a large pure subset, much more >> useful than Erlang's pure subset and covering almost the whole >> language; you just avoid lazy I/O and use unsafePerformIO only for >> correcting the type of functions imported through FFI.) > > Wait, a pattern match can have side effects? Can you provide some > example code? (do you mean, pattern match failure / exceptions / run > time errors?) It uses seq instead of pattern matches for clarity. But laziness means that you could hide the side effect in any pattern match whatsoever. > I'm new to Haskell, but in my understanding, it is said that Haskell > is pure because the whole Haskell code is just specification of > (types, .. and) values, and this specification is enjoy referential > transparency. A small part of the standard library pretends that some externally visible effects are not impure. Other programmers follow that style. In their code bases, you will occasionally see commits which add additional laziness to avoid blocking on network input (when the client will never send data because the protocol is half-duplex) or to avoid reading too much data from disk.