derek.a.elkins: > On Fri, 2008-10-03 at 15:38 -0400, David Menendez wrote: > > On Fri, Oct 3, 2008 at 3:17 AM, Jason Dusek <[EMAIL PROTECTED]> wrote: > > > Perhaps I am lacking in imagination, but I still can't see the > > > value of one tuples. > > > > You can use them to defeat seq. > > > > undefined `seq` x == undefined > > OneTuple undefined `seq` x == x > > > > That might be useful if a polymorphic function is using seq to force > > evaluation, and you don't want it to. But I can't imagine that coming > > up much in practice. > > Think element strict polymorphic containers, e.g. > > data HeadStrictList a = Nil | Cons !a (HeadStrictList a) > > then > > type LazyList a = HeadStrictList (OneTuple a)
Used in practice to prevent strict state components in list fusion leaking into user's lazy code, data L a = L a -- lazy / lifted newtype S a = S a -- strict / unlifted class Unlifted a where instance Unlifted (L a) where expose (L _) s = s instance Unlifted (S a) where expose (S a) s = seq a s data Stream a = forall s. Unlifted s => Stream !(s -> Step a s) -- ^ a stepper function !s -- ^ an initial state So we can then ensure stream :: [a] -> Stream a stream xs0 = Stream next (L xs0) where next (L []) = Done next (L (x:xs)) = Yield x (L xs) Has the appropriate strictness properties. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe