[Haskell] Num is such a fat and greedy class

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Mon Dec 11 03:50:35 EST 2006


>> class Subtraction a b | a -> b where
>>   (-) :: a -> a -> b
> 
> If you split them up like this, things like quadRoots take an
> unwieldly type signature: [...]

ultimately this leads to a style of programming
where you have a  class Has_f  for each function symbol  f.

then the signature of a function contains
all the (wrapper class) names of all the functions
it intends to call.

This shows that type classes are "just" a means
for expressing implicit parameters to functions
(the parameters are the class methods,
and the (invisible) dictionary transports them).

Their usability still is limited
because all (data and) class and instance declarations are global.
Is there a fundamental (design or implementation) reason for this?
I really sometimes would want to write

let { instance Show Foo where ... } in   show ...

or

let data Bar = ... in  ...

Compare Java where you can have nested classes and interfaces.
Where of course part of their motivation is
that Java lacks proper (and anonymous) functions.

Best regards,
-- 
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------



More information about the Haskell mailing list