
I was recently presented with the problem of writing a function like so seqInt__ :: forall a . a -> Int# -> Int# seqInt__ x y = x `seq` y which seems fine, except 'seq' of type forall a b . a -> b -> b cannot be applied to an unboxed value. I could not think of a way to actually get the behavior I wanted until I remembered bang patterns. seqInt__ :: forall a . a -> Int# -> Int# seqInt__ !x y = y which seems to work! my question is, is this actually something fundamentally new that bang patterns allow or was I just not able to figure out the "old" way to do it? Also, is there a way to do something similar but for 'lazy' rather than 'seq'? I want something of type type World__ = State# RealWorld {-# NOINLINE newWorld__ #-} newWorld__ :: a -> World__ newWorld__ x = realWord# -- ??? except that I need newWorld__ to be lazy in its first argument. I need to convince the opimizer that the World__ newWorld__ is returning depends on the argument passed to newWorld__. using any wacky ghc primitives in 6.6 is fine, I would just like something that stands up to ghc -O2. when compiling with -O, ghc is too clever and sees through tricks like this. (at least, that is what I think is happening) John -- John Meacham - ⑆repetae.net⑆john⑈