[Haskell-cafe] Why is Bool no instance of Num and Bits?

Edward Kmett ekmett at gmail.com
Fri Jun 26 11:10:38 EDT 2009


Agreed. I wound up having to add a horrible Num instance for Bool in
'monoids' in order to support a decent Boolean Ring type.

http://comonad.com/haskell/monoids/dist/doc/html/monoids/Data-Ring-Boolean.html

I would much rather be able to get rid of it!

The only problem with eliminating the constraint is that any code that uses
Bits polymorphically might have to pick up a Num annotation, but I can't see
it being a serious problem.

-Edward Kmett

On Wed, Jun 24, 2009 at 8:13 AM, John Meacham <john at repetae.net> wrote:

> On Fri, May 08, 2009 at 04:36:41PM +0200, Stephan Friedrichs wrote:
> > When looking for an xor function, I found one in Data.Bits but couldn't
> > use it for Bool, because Bool is no instance of Bits and of Num (which
> > would be necessary, because it's "class (Num b) => Bits b"). My question
> > is: Why not?
>
> This has bothered me too. However, I think the root problem is that
> 'Num' is a superclass of 'Bits'. There is no reason it should be, all
> the default instances can be specified without the Num dependency.
>
>        John
>
> --
> John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
>  _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090626/0a7bcd84/attachment.html


More information about the Haskell-Cafe mailing list