darcs patch: more portabilization

Ian Lynagh igloo at earth.li
Wed Jan 16 19:18:45 EST 2008


On Wed, Jan 16, 2008 at 06:56:15PM -0500, Isaac Dupree wrote:
>
> argh! conflicts!

Ug, sorry about that  :-(

> oh, darnit, you wanted to panic for invalid FastBools... which seems
> reasonable and hard to work around.  (although: if the code typechecks
> with FastBool=Bool, then I don't think it's possible to happen?

No panics are supposed to be possible to happen  :-)

> although if they're really supposed to be Fast, I question putting any 
> extra checks than "is it equal to zero or not" for example, even to 
> panic.

I just added e.g. the third line to:

    fastOr 1# _ = 1#
    fastOr 0# x = x
    fastOr _  _ = panic# "FastTypes: fastOr"

but without it GHC effectively inserts a line something like

    fastOr _  _ = throw "fastOr: Non-exhaustive patterns matches"

so I don't think it should be any slower than it was. An alternative
would be to change the code to

    fastOr 1# _ = 1#
    fastOr _  x = x

which would be slightly faster, avoid the need for panic, but could
potentially hide bugs.

It's a pity we can't

    newtype FastBool = FastBool Int#

which would at least mean we could restrict potentially buggy code to
the few functions in the FastBool module.


Thanks
Ian



More information about the Cvs-ghc mailing list