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.5 required=5.0 tests=AWL,MAILTO_TO_REMOVE,SPF_FAIL 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 D226FBC69 for ; Fri, 19 Oct 2007 07:09:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAMvYF0fAXQInh2dsb2JhbACOUAIBCAopgSc X-IronPort-AV: E=Sophos;i="4.21,298,1188770400"; d="scan'208";a="3341904" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 19 Oct 2007 07:09:24 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9J59ISi015576 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 19 Oct 2007 07:09:24 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAELZF0dQW+UCh2dsb2JhbACOUAIBCAopgSc X-IronPort-AV: E=Sophos;i="4.21,298,1188770400"; d="scan'208";a="4834053" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail3-smtp-sop.national.inria.fr with ESMTP; 19 Oct 2007 07:09:21 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Iik6j-0006qw-O8 for caml-list@inria.fr; Fri, 19 Oct 2007 05:09:13 +0000 Received: from 0x57353b08.boanxx19.adsl-dhcp.tele.dk ([87.53.59.8]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Oct 2007 05:09:13 +0000 Received: from spam by 0x57353b08.boanxx19.adsl-dhcp.tele.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Oct 2007 05:09:13 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: =?ISO-8859-15?Q?B=E1r=F0ur_=C1rantsson?= Subject: Re: Help me find this pdf Date: Fri, 19 Oct 2007 07:09:02 +0200 Message-ID: References: <200710181457.58077.jon@ffconsultancy.com> <47176C28.1090509@janestcapital.com> <200710181818.31430.jon@ffconsultancy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 0x57353b08.boanxx19.adsl-dhcp.tele.dk User-Agent: Thunderbird 2.0.0.6 (X11/20071002) In-Reply-To: <200710181818.31430.jon@ffconsultancy.com> Sender: news X-Miltered: at concorde with ID 47183BFE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; haskell:01 non-empty:01 non-empty:01 haskell:01 ocaml:01 cheers:01 wrote:01 wrote:01 lazy:02 lazy:02 explicitly:02 data:02 match:02 match:02 languages:03 Jon Harrop wrote: > On Thursday 18 October 2007 15:22:32 Brian Hurt wrote: >> You have to explicitly force the lazy value first- > > If you force all lazy values before the pattern match then you are doing eager > evaluation, not lazy. Moreover, you must also generate an auxiliary data > structure to store the forced values in order to pattern match over them. > >> but other than it being explicit, > > And not lazy. > >> this is no different from other languages that implicitly force the value >> for you. > [--snip-- lots of examples --snip--] What you're saying is basically that lazy pattern matching should only force as much of the value under examination as is actually necessary to decide if there's a match. Do I have that right? If so, then Haskell does exactly this. Here's a small example: import Debug.Trace x = trace "Evaluated x" "Hello" y = trace "Evaluated y" "World" main :: IO () main = do let l = [x, y] case l of (a:_) -> do putStrLn "Non-empty list" putStrLn a _ -> putStrLn "Empty list" This outputs Non-empty list Evaluated x Hello Note that if you don't add that "putStrLn a" there, Haskell won't even force x! You're definitely right that doing anything of this sort is currently quite painful in OCaml. Cheers, -- Bardur Arantsson It hovered above the ground, much in the way that bricks don't. Douglas Adams, 'Hitchiker's Guide to the Galaxy'