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.2 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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 5EC71BC69 for ; Fri, 19 Oct 2007 10:52:58 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAA8NGEfAXQInh2dsb2JhbACOTwIBCAop X-IronPort-AV: E=Sophos;i="4.21,299,1188770400"; d="scan'208";a="3336087" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Oct 2007 10:52:58 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9J8qvee024000 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 19 Oct 2007 10:52:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAA8NGEdQW+UCh2dsb2JhbACOTwIBCAop X-IronPort-AV: E=Sophos;i="4.21,299,1188770400"; d="scan'208";a="3336085" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Oct 2007 10:52:57 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IinbD-0004le-5r for caml-list@inria.fr; Fri, 19 Oct 2007 08:52:55 +0000 Received: from ivr94-8-88-162-26-239.fbx.proxad.net ([88.162.26.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Oct 2007 08:52:55 +0000 Received: from li by ivr94-8-88-162-26-239.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Oct 2007 08:52:55 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: Help me find this pdf Date: Fri, 19 Oct 2007 10:55:09 +0200 Message-ID: <873aw7wkk2.fsf@pps.jussieu.fr> 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-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ivr94-8-88-162-26-239.fbx.proxad.net User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:57KAxYSeou9mWbUjbAey6rj6kKY= Sender: news X-Miltered: at concorde with ID 47187069.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; haskell:01 non-empty:01 non-empty:01 endline:01 endline:01 haskell:01 recursive:01 camlp:01 ocaml:01 cheers:01 pps:01 pps:01 jussieu:01 jussieu:01 writes:01 Bįršur Įrantsson writes: > 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 Isn't it just a matter of explicit and implicit? let x = [<'(print_endline "evaluate x"; "hello")>] let y = [<'(print_endline "evaluate y"; "hello")>] let main () = let l = [x;y] in match l with | h::_ -> print_endline "Non-empty list"; print_endline (Stream.next h) | _ -> print_endline "Empty list" Also look at the SDFlow [1] I released a few days ago. It's lazy, combinatorial and non-strict (but deterministic). If you really want a lazy list in the exact haskell style, I have no problem to provide a SDList later (given more time), the only missing pieces from SDFlow to also be considered as lazy lists are: - destructive -> nondestructive (dozens of lines) - relax recursive value restriction (a camlp4 script) [1] http://www.pps.jussieu.fr/~li/software/index.html#sdflow > 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' -- Zheng Li http://www.pps.jussieu.fr/~li