module Data.Bits

Manuel M T Chakravarty chak@cse.unsw.edu.au
Wed, 11 Sep 2002 17:28:09 +1000 (EST)


Alastair Reid <alastair@reid-consulting-uk.ltd.uk> wrote,

> 
> > Another conflict between the FFI spec and the current library
> > implementation: the spec says
> 
> >     "The function bitSize returns 0 for types that don't have a
> > fixed bitsize (e.g. Integer)."
> 
> > whereas the current ghc implementation defines bitSize of Integer as
> > a runtime error.
> 
> I think both are unfortunate - we should just admit that not every
> type has a bitsize and return a Maybe.  But that doesn't seem likely
> to happen...
> 
> It isn't clear which is the lesser of the two evils:
> 
> - returning 0 is easy to catch but equally easy to carelessly forget
> 
> - raising an exception is harder to catch but has the huge advantage
>   that the failure is close to the broken code.
> 
>   (Does NHC support non-deterministic exceptions?  Dead easy to add if
>   not.)
> 
> Hugs is silent on the issue because we never implemented Bits Integer.
> I think I prefer the GHC semantics.

Ok, I changed the spec to GHC's semantics.

Manuel