
10 Apr
2001
10 Apr
'01
3:53 a.m.
Hello! On Tue, Apr 10, 2001 at 01:55:21AM +0200, Thomas Pasch wrote:
is there an easy way to box/unbox Types. I need this for Int's, so is there a function that does:
Int# -> Int Int -> Int#
You must import the appropriate modules, to "see" the type definition for Int (which is data Int = I# Int# in GHC). Then just use plain pattern matching: unboxInt :: Int -> Int# unboxInt (I# i#) = i# boxInt :: Int# -> Int boxInt i# = I# i# Note that there are some restrictions for handling unboxed values, see the documentation. Kind regards, Hannah.