Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] lazy lists
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jun Mukai <mukai@a...>
Subject: Re: [Caml-list] lazy lists
Hi, Rich

> What you probably want are Streams (in camlp4).  This thread is
> interesting:

It is true that Stream is lazy evaluated, but Stream is not functional
at all. We cannot use Streams as same as lists in Haskell. For example,
--
# let s = [< '1 >];;
val s : int Stream.t = <abstr>
# let f = parser
  | [< 'n >] -> n
  | [< >] -> raise Not_found;;
val f : 'a Stream.t -> 'a = <fun>
# f s;;
- : int = 1
# f s;;
Exception: Not_found.
--

This code confuses many users (such like me).


BTW, I wrote a lazy list implementation in pure OCaml. It uses lazy
mechanism of OCaml and has some useful functions like haskell.
If you are interested in, see 
http://www.jmuk.org/prog/lazyList.tar.gz

The implementation is so naive that its performance will be low. And
it has no camlp4 extentions.
Feel free to use, but without any warranty.

Best Regards,
--
Jun Mukai