[Haskell-cafe] Re: Numeric type classes

Ross Paterson ross at soi.city.ac.uk
Wed Sep 13 04:58:09 EDT 2006


On Tue, Sep 12, 2006 at 08:59:30PM -0400, ajb at spamcop.net wrote:
> One of the proposals that comes up every so often is to allow the
> declaration of a typeclass instance to automatically declare instances
> for all superclasses.  So, for example:
> 
>     class (Functor m) => Monad m where
>         fmap f m = m >>= return . f
> 
>     instance Monad Foo where
>         return a = {- ... -}
>         m >>= k = {- ... -}
>         fail s = {- ... -}
> 
> This will automatically declare an instance of Functor Foo.
> 
> Similarly, a finer-grained collection of numeric typeclasses could
> simply make Num a synonym for (Show a, Ord a, Ring a, Signum a).
> Declaring an instance for (Num Bar) declares all of the other
> instances that don't yet have a declaration.

Such features would be useful, but are unlikely to be available for
Haskell'.  If we concede that, is it still desirable to make these
changes to the class hierarchy?

I've collected some notes on these issues at

http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/StandardClasses



More information about the Haskell-Cafe mailing list