module Data.Bits

Alastair Reid alastair at
Tue Sep 10 12:16:07 EDT 2002

> 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

Hugs is silent on the issue because we never implemented Bits Integer.
I think I prefer the GHC semantics.


More information about the FFI mailing list