Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  An unsigned int class. (derek riemer)
   2. Re:  An unsigned int class. (Brandon Allbery)
   3. Re:  An unsigned int class. (Marcin Mrotek)
   4. Re:  An unsigned int class. (David Obwaller)


----------------------------------------------------------------------

Message: 1
Date: Fri, 31 Jul 2015 09:30:35 -0600
From: derek riemer <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] An unsigned int class.
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed

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


------------------------------

Message: 2
Date: Fri, 31 Jul 2015 11:32:45 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] An unsigned int class.
Message-ID:
        <CAKFCL4Wu_UTwHNm84K14y+7vL3xbriuF6A-WUbuXPz=yhdp...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, Jul 31, 2015 at 11:30 AM, derek riemer <[email protected]>
wrote:

> 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-1.1.1.0/Data-Word.html

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150731/e8bf5e3b/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 31 Jul 2015 18:08:33 +0200
From: Marcin Mrotek <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] An unsigned int class.
Message-ID:
        <CAJcfPz=yyPLHarJGa6VBEpM_ftEd-OVJYJ1PNV2m8GCFo8aS=w...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150731/36962906/attachment-0001.html>

------------------------------

Message: 4
Date: Fri, 31 Jul 2015 21:08:38 +0200
From: David Obwaller <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] An unsigned int class.
Message-ID: <20150731190838.GA8061@davids-mbp>
Content-Type: text/plain; charset=us-ascii

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


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 86, Issue 1
****************************************

Reply via email to