[Haskell-cafe] Lazy lists with with call-by-value reduction strategy.
flicky frans
flickyfrans at gmail.com
Wed Feb 12 00:02:55 UTC 2014
>Do you know about the Church encoding?
Yes.
>1. Why do you pass (\_. x) instead of x to f? This looks like an attempt
>to delay evaluation of x, but by the time cons is applied, x must
>have been evaluated already due to CBV.
It's for constructing lists from the evaluated values. For lazy
purposes there is consC.
2. Why do you ask for a new f' but ignore the new z' (as compared to f
>and z)?
It's for the tail function, which is problematic in the standard
Church encoding. Here it is O(1). While folding, actual f passes over
the whole list.
>Also, your interpreter doesn't seem to finish in a reasonable time on
your own input.
It's very simple and unoptimized. And there is much arithmetic in the
code. It finishes, but if you don't want to wait, you can try "sum
(take (s (s z)) (cycle (take (s (s z)) (filter (leq (s z)) nats))))".
2014-02-12 2:31 GMT+03:00, Roman Cheplyaka <roma at ro-che.info>:
> Do you know about the Church encoding?
>
> I don't quite understand your encoding. Consider your cons function:
>
> cons = \x xs f z. f (\_. x) (\f' _. xs f' z);
>
> 1. Why do you pass (\_. x) instead of x to f? This looks like an attempt
> to delay evaluation of x, but by the time cons is applied, x must
> have been evaluated already due to CBV.
>
> 2. Why do you ask for a new f' but ignore the new z' (as compared to f
> and z)?
>
> Also, your interpreter doesn't seem to finish in a reasonable time on
> your own input.
>
> Roman
>
> * flicky frans <flickyfrans at gmail.com> [2014-02-12 00:46:47+0300]
>> Hello. I am currently writing lists with lazy semantics in the pure
>> lambda-calculus with call-by-value reduction strategy.
>> Here is an example: http://pastebin.com/SvQ5hCSD
>> Here is a simple interpetator: http://pastebin.com/mejCWqpu
>> Am I reinventing the wheel? Are there some sources, from where i can
>> learn more about lazy evaluation in the strict languages?
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list