
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. So my questions are: What was the motivation for not providing them in Haskell 98? Are there any technical problems with adding them to Haskell now (or then)? If there aren't any issues, are strictness annotations on any implementors' wish-list to be added when there is sufficient demand or no more pressing matters? Googling the haskell archives didn't (immediately at least) turn up any answers to these questions, but did turn up a couple posts suggesting the desirability this. http://www.haskell.org/pipermail/haskell/2002-March/009176.html http://www.haskell.org/pipermail/haskell-cafe/2001-June/001995.html

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@foo.net ---------------------------------------------------------------------------

G'day all.
Quoting John Meacham
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.
Although that's not quite what you want. Having ! part of the type signature suggests that it's the caller's job to do the seq, not the callee's. This way, you can avoid the eval if the caller has already evaluated the argument, or if the caller knows that evaluation is a no-op.
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)
Yes, I don't like the precedence (or associativity, for that matter) of $! either. Cheers, Andrew Bromage
participants (3)
-
ajb@spamcop.net
-
Derek Elkins
-
John Meacham