[Haskell-beginners] Overflow when reading C types

Patrick Redmond plredmond at gmail.com
Mon Dec 2 22:05:06 UTC 2013


Yeah, the unsigned is to demonstrate how "-10" is being interpreted as a
number before being cast to an unsigned.

My question is: Why isn't this just a read/parse error? "-10" isn't a valid
representation for any value of the CUInt type.

On Monday, December 2, 2013, wrote:

> On Mon, Dec 02, 2013 at 11:38:33AM +1300, ml at extensibl.com <javascript:;>wrote:
> > On Mon, Dec 02, 2013 at 11:30:50AM +1300, Patrick Redmond wrote:
> > > Prelude> import Foreign.C.Types
> > > Prelude Foreign.C.Types> read "-10" :: CUInt
> > > 4294967286
> > > Prelude Foreign.C.Types> read "300" :: CChar
> > > 44
> > >
> >
> > CUInt? I would try CInt instead.
> >
>
> Whoops, that is not related to the original question, sorry.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org <javascript:;>
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131203/f63a68da/attachment.html>


More information about the Beginners mailing list