Strictness annotations

John Meacham john at repetae.net
Tue Oct 21 01:10:38 EDT 2003


On Mon, Oct 20, 2003 at 10:23:00PM -0400, Derek Elkins wrote:
> I've wondered for a while why Haskell 98 didn't provide strictness
> annotations for functions a la Clean and no implementations provide it
> as an extension (actually I don't know about NHC, but I'm pretty sure
> neither GHC nor Hugs do).  Clean's solution seems easier to read and
> write and seems like it would be trivial (though possibly tedious) to
> implement.

I can't speak for why they weren't included in Haskell 98, but on
occasion I have wanted something like

f :: Int -> !Int -> Int
f x y = foo

which would translate to:

f :: Int -> Int -> Int
f _ y | seq y False = undefined
f x y = foo

although I am not sure how useful it would actually be.

another thing which might be handy is ' !' completely analogous to $!,
with the exact same precedence as normal functional application (think
space-bang, just like dollar-bang)

foo x !(y + z) 

will have the effect of evaluating the second argument before passing it
to foo. of course this would conflict with array indexing without some
lexing magic...

        John

-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john at foo.net
---------------------------------------------------------------------------


More information about the Haskell-Cafe mailing list