[Haskell-cafe] Re: Numeric type classes

Aaron Denney wnoise at ofb.net
Wed Sep 13 14:59:53 EDT 2006


On 2006-09-13, Ross Paterson <ross at soi.city.ac.uk> wrote:
> 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?

Absolutely.  It needs to be fixed, and much better now than later.

-- 
Aaron Denney
-><-



More information about the Haskell-Cafe mailing list