
Is there anything in haskell that represents an unsigned Int class? namely, something bounded below at 0? If not, is it possible to define an Int in this way to add the bounded constraint (I can't immagine trying to define Int like this, there has got to be a better way that I haven't quite understood in my study of haskell). data UnsignedInt = 0 | 1 | 2 | (...) for a long time doing that ... deriving (Show, Eq, Ord, Bounded, Read) Thanks, Derek

On Fri, Jul 31, 2015 at 11:30 AM, derek riemer
Is there anything in haskell that represents an unsigned Int class?
It's a type, not a class. "Class" implies something very different in Haskell. And I think you're looking for the "Word" type from Data.Word. http://lambda.haskell.org/platform/doc/current/ghc-doc/libraries/haskell2010... -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hello, If you're interested in numbers from 0 upto bignums, there's also Numeric.Natural: https://hackage.haskell.org/package/base-4.8.1.0/docs/Numeric-Natural.html Best regards, Marcin Mrotek

Hi, On Fri, Jul 31, 2015 at 09:30:35AM -0600, derek riemer wrote:
Is there anything in haskell that represents an unsigned Int class? namely, something bounded below at 0?
The module Data.Word provides unsigned integral types with modular arithmetic: Word (same size as Int), Word8, Word16, etc. $ ghci > import Data.Word ... > maxBound :: Word 18446744073709551615 > maxBound :: Word8 255 > maxBound :: Word32 4294967295 > 0 - 1 :: Word8 255 > maxBound + 1 :: Word8 0 Is that what you are looking for? http://hackage.haskell.org/package/base-4.8.1.0/docs/Data-Word.html David
participants (4)
-
Brandon Allbery
-
David Obwaller
-
derek riemer
-
Marcin Mrotek