Strictness in Haskell

1992-04-08 Thread smk
I like John's idea with a class Strict, but I think there should also be a second class Eval for computing whnf's: class Strict a where strict :: a -> Bool class Eval a where eval :: a -> Bool Example: for Complex we get: instance Strict a => Strict (

Re: Strictness in Haskell

1992-04-08 Thread Lennart Augustsson
> Yes, in general it's not possible. That is, I can't write a function > > evaluate :: a -> a > > which will force its argument to WHNF. I don't think you mean what you are actually saying, it's perfectly possible write evaluate :-) evaluate x = x This function will evaluate its a

Re: Strictness in Haskell

1992-04-08 Thread Kevin Hammond
> Hi ! > > Can anyone tell me whether it's possible to force Haskell to evaluate an > expression strict ? Yes, in general it's not possible. That is, I can't write a function evaluate :: a -> a which will force its argument to WHNF. I can, as you've noted, write a function: e

Strictness in Haskell

1992-04-08 Thread john peterson
As others have mentioned, Haskell does not provide a direct means for strict evaluation. While the class system can be used, the trick of f x = x | x == x is not guaranteed to work since == methods defined by the user may not have the desired strictness property. I could always put instance E

Re: Strictness in Haskell

1992-04-08 Thread laufer
My apologies for the previous message, which was intended to go to Cornel Klein only. -Konstantin

Re: Strictness in Haskell

1992-04-08 Thread laufer
Cornel, > data Sequ a = Empty > | Cons (a,Sequ a) wieso verwendest Du hier nicht einfach [a]? > If the typevariable "a" would be restricted to range over the typeclass Eq, > the dirty trick of adding the guard > > n==n > > to the definition of mergesort could be used

Strictness in Haskell

1992-04-08 Thread Cornel Klein
Hi ! Can anyone tell me whether it's possible to force Haskell to evaluate an expression strict ? Consider the following Haskell program: --- module Mergesort where data Sequ a = Empty | Cons (a,Sequ a) merge