[Haskell-beginners] overflow safe Word types
aslatter at gmail.com
Fri Mar 26 22:51:12 EDT 2010
On Fri, Mar 26, 2010 at 1:23 PM, Ashish Agarwal <agarwal1975 at gmail.com> wrote:
> Is there an alternative implementation of the types Word8, Word16, etc. that
> disallow overflow? For example, currently:
> Prelude Word> (fromInteger 256) :: Word8
> I'd like a type whose constructors disallow this.
In a way. There's this:
Which provides replacements for all of the Word/Int types, except it
always errors on overflow.
It's not intended for production use, as it adds quite a bit of
overhead to evaluation.
In retrospect, I'm not sure why I didn't use Control.Exception.assert.
More information about the Beginners