[Haskell-cafe] Laziness question

Felipe Lessa felipe.lessa at gmail.com
Sun Aug 1 10:52:48 EDT 2010


On Sun, Aug 1, 2010 at 11:29 AM, Nicolas Pouillard
<nicolas.pouillard at gmail.com> wrote:
> Finally maybe we can simply forbidden the forcing of function (as we do with
> Eq). The few cases where it does matter will rescue to unsafeSeqFunction.

What's the problem with

  class Eval a where
    seq :: a -> t -> t

  instance Eval b => Eval (a -> b) where
    seq f = seq (f undefined)

It would reduce at least to WHNF as unsafeSeq would.  Does it compute
more than WHNF?

Hmmm, I see, if we had

  f :: Int -> Int
  f _ = undefined

Then my seq above would diverge while unsafeSeq wouldn't.  Perhaps
that instance would be a good compromise if we insist in not using
'unsafeSeq' to define it.

Cheers, =)

-- 
Felipe.


More information about the Haskell-Cafe mailing list