From: Zheng Li <li@pps.jussieu.fr>
To: caml-list@inria.fr
Subject: Re: Help me find this pdf
Date: Fri, 19 Oct 2007 10:55:09 +0200 [thread overview]
Message-ID: <873aw7wkk2.fsf@pps.jussieu.fr> (raw)
In-Reply-To: <ff9e5f$q24$1@ger.gmane.org>
Bárður Árantsson <spam@scientician.net> 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
> <bardurREMOVE@THISscientician.net>
>
> 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
next prev parent reply other threads:[~2007-10-19 8:52 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-18 9:52 Tom
2007-10-18 10:33 ` [Caml-list] " skaller
2007-10-18 11:01 ` Andreas Rossberg
2007-10-18 12:25 ` Jon Harrop
2007-10-18 12:40 ` Arnaud Spiwack
2007-10-18 13:17 ` Jon Harrop
2007-10-18 15:15 ` Till Varoquaux
2007-10-18 12:46 ` Jacques Garrigue
2007-10-18 13:57 ` Jon Harrop
2007-10-18 14:22 ` Brian Hurt
2007-10-18 14:52 ` Robert Fischer
2007-10-18 15:04 ` Eric Cooper
2007-10-18 17:18 ` Jon Harrop
2007-10-19 1:16 ` skaller
2007-10-19 5:09 ` Bárður Árantsson
2007-10-19 5:23 ` [Caml-list] " Erik de Castro Lopo
2007-10-19 5:46 ` Bárður Árantsson
2007-10-19 12:25 ` [Caml-list] " Christophe Raffalli
2007-10-19 12:47 ` Luc Maranget
2007-10-20 14:26 ` Christophe Raffalli
2007-10-19 14:48 ` Robert Fischer
2007-10-19 21:43 ` Andreas Rossberg
2007-10-19 21:51 ` Robert Fischer
2007-10-20 13:10 ` Andreas Rossberg
2007-10-19 23:10 ` Jon Harrop
2007-10-20 1:13 ` skaller
2007-10-20 6:36 ` Tom
2007-10-21 11:17 ` skaller
2007-10-19 8:55 ` Zheng Li [this message]
2007-10-19 22:27 ` Jon Harrop
2007-10-19 13:00 ` [Caml-list] " Brian Hurt
2007-10-19 13:49 ` Loup Vaillant
2007-10-19 14:41 ` Zheng Li
2007-10-19 23:09 ` [Caml-list] " Jon Harrop
2007-10-18 20:07 ` Tom
2007-10-19 0:59 ` skaller
2007-10-18 20:48 ` Lauri Alanko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873aw7wkk2.fsf@pps.jussieu.fr \
--to=li@pps.jussieu.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox