[Haskell-cafe] laziness blowup exercise

Thomas Hartman tphyahoo at gmail.com
Thu Jul 16 14:22:19 EDT 2009


I played with this a bit, and ok, it seems the difference between
iterate' and iterate'' is

h _ = 2


tit' = head . drop 1 . iterate' h $ undefined
tit'' = head . drop 1 . iterate'' h $ undefined

> (Bas wishes for a type system that can express the different
strictness properties of these functions...)

Is this being worked on? Could you give some example of type systems
that can express differences between functions of along dimension x?
Off the top of my head, I guess (?) with dependent types can tell the
difference between total and partial functions... partials won't even
compile, right? Are there others? Pointers appreciated.

> ...seems the most lazy strict iterate.

could you expand on what you mean by this?

2009/7/16 Bas van Dijk <v.dijk.bas at gmail.com>:
> On Wed, Jul 15, 2009 at 6:35 PM, Ryan Ingram<ryani.spam at gmail.com> wrote:
>> iterate' f x = x `seq` x : iterate' f (f x)
>> seems better; it doesn't evaluate list elements you don't visit.
>
> iterate'' f x = x : (iterate'' f $! f x)
>
> ...seems the most lazy strict iterate.
>
> (Bas wishes for a type system that can express the different
> strictness properties of these functions...)
>


More information about the Haskell-Cafe mailing list