tags:

views:

77

answers:

2

I want to convert between various integral types (for example, Word32 and Word8).

What is the idiomatic way to do that in haskell?

Word8 -> Word32 conversion can always succeed. Word32 -> Word8 conversion might result in an overflow and I'll deal with that (either for testing explicitly or getting an indication from whatever the conversion idiom is...)

+7  A: 

fromIntegral will convert from an integral type to any numeric type, including other integral types

newacct
+2  A: 

See Converting Numbers in the Haskell wiki

MtnViewMark