> 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:
evaluateEq :: Eq a => a -> a
evaluateEq a = if a == a then a else a
which will work for Eq types. Or I can write similar functions for
other classes of objects. For example,
class Evaluable a where
evaluate :: a -> a
instance Evaluable Int where
evaluate n = if n == 0 then n else n
instance Evaluable a => Evaluable [a] where ...
...
I can't evaluate arbitary functions this way, but otherwise I can
specify exactly which types admit evaluation. This should suit your
situation, I expect. Overall, I tend to regard this as a feature
rather than a bug :-)
Kevin