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

Andrew Wagner wagner.andrew at gmail.com
Fri May 8 11:49:41 EDT 2009


Err, I'm not seeing the danger of this
(+) :: forall a. (Num a) => a -> a -> a

Doesn't this require the two parameters to be the same instance of Num?

On Fri, May 8, 2009 at 10:51 AM, Sittampalam, Ganesh <
ganesh.sittampalam at credit-suisse.com> wrote:

> 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?
> >
> > [...]
> > quite trivial... Why is this not part of base? Or am I missing
> > something?
>
> One reason would be that we don't want 1 + True to typecheck, even if it
> does have a sensible interpretation.
>
> Ganesh
>
>
> ===============================================================================
>  Please access the attached hyperlink for an important electronic
> communications disclaimer:
>  http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>
>  ===============================================================================
>
> _______________________________________________
> 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/20090508/5590cddb/attachment.htm


More information about the Haskell-Cafe mailing list