[Haskell-cafe] Re[2]: strict Haskell dialect

John Meacham john at repetae.net
Mon Feb 6 02:58:06 EST 2006


On Sun, Feb 05, 2006 at 05:18:55PM -0000, Brian Hulley wrote:
> I must admit I'm a bit confused as to why the strictness annotations in
> Haskell (and Clean) are only allowed in data declarations and not function
> declarations, since it seems a bit random to have to guess which args can
> be evaluated strictly at the call site although it of course gives
> flexibility (eg to use (+) strictly or lazily). The type system doesn't
> prevent someone from writing (>>) m0 $! m1 even though the author of (>>)
> may have been relying on m1 being lazily evaluated... (?)

It is because a data declaration is defining the form of the data, which
includes both its representation and the type of its constructors. the
strictness annotations affect its representation (or at least its
desugaring) but not its type. The strictness of the fields is not
reflected in the type. A function declaration is just declaring the type
of the function, where strictness is not reflected either just like in
data types.


another way you can think of it is that for

data Foo = Bar !Int !Char

the bangs arn't being assosiated with the Int and Char types, but rather
the Bar data constructor. However, the syntax is a little confusing in
that it makes the bangs look as though they were part of the types of
the constructor arguments.

        John

--
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list