On Mon, Nov 12, 2012 at 2:12 PM, Bas van Dijk <v.dijk.bas@gmail.com> wrote:
On 12 November 2012 13:25, Henning Thielemann
<lemming@henning-thielemann.de> wrote:I think I like this idea. So the package would export something like:
> I don't think of changing it. We could provide a package that exports "the
> right 'seq'" and then encourage people to use this instead of Prelude.seq.
module Control.Seq where
import Prelude hiding (seq)
import GHC.Base hiding (seq)
class WHNFData a where
rwhnf :: a -> ()
instance WHNFData [a] where
rwhnf [] = ()
rwhnf (_:_) = ()
-- and all the others...
seq :: WHNFData a => a -> b -> b
seq a b = case rwhnf a of () -> b
($!) :: WHNFData a => (a -> b) -> a -> b
f $! x = x `seq` f x