
1 Dec
2006
1 Dec
'06
12:30 a.m.
On Thu, Nov 30, 2006 at 08:13:13PM -0800, John Meacham wrote:
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
How about something like this: seqInt__ :: forall a . a -> Int# -> Int# seqInt__ x y = case x `seq` (I# y) of (I# y') -> y' The question is: will GHC optimize out the unneccesary boxing and unboxing? Looking at the output from "ghc -O2 -ddump-simpl" makes me think the answer is "yes". Best regards Tomasz