More speed please!

Roberto Zunino zunino at di.unipi.it
Fri Mar 16 15:06:07 EDT 2007


Simon Peyton-Jones wrote:
[snip]
 > Now you are proposing that
 >
 >         data Bar a = MkBar (!a -> a)
 >         MkBar f = :MkBar (\x. x `seq` f x)
 >
 > I suppose you can combine the two notations:
 >
 >         data Baz a = MkBaz !(!a -> a)
 >         MkBaz f = f `seq` :MkBaz (\x. x `seq` f x)
 >
 > Interesting.  Is that what you meant?  An undesirable consequence
 > would be that
 >         case (MkBar bot) of MkBar f -> f `seq` 0
 > would return 0, because the MkBar constructor puts a lambda inside.
 > This seems bad. Maybe you can only put a ! inside the function type if
 > you have a bang at the top (like MkBaz).

Another possible fix could be defining

        data Bar a = MkBar (!a -> a)

to mean

        MkBar f = :MkBar (f `seq` (\x -> x `seq` f x))

In that case,
        case (MkBar bot) of MkBar f -> f `seq` 0
would diverge.

Roberto.


More information about the Glasgow-haskell-users mailing list