haskell prelude

Brian Goetz brian.goetz at oracle.com
Fri Jun 22 07:33:35 PDT 2012


In the new streams library, laziness can be handled by writing iterators 
(yes, I know they're yucky) and treating them as stream sources.  So it 
is fairly easy to create a stream source for infinite sequences, 
transform with filter/map/flatMap, and consume the bits you want as if 
they were iterators.

On 6/21/2012 9:33 AM, Luc Duponcheel wrote:
> Some time ago Sven Eric Panitz posted an experimental haskell prelude
> library to this group (one of his goals being to work with "infinite
> iterables" (right?))
>
>
> So I tried out something similar to
>
> public class Test{
>    final private static Function2<Integer, Integer, Iterable<Integer>>  fibs =
>      (Integer z, Integer y) ->  cons(z, cons(y, fibs.eval(y, z + y)));
>    public static void main(String[] args){
>      System.out.println(take(5, fibs.eval(1, 1)));
>    }
> }
>
> but this results in a stack overflow
>
> So my question to Sven (and others (?)) is:
> is there an elegant similar way to define fibs without this issue?
>
>
> thx
>
> Luc
>


More information about the lambda-dev mailing list