[Haskell-cafe] instance Monad m => Functor m
Hans Aberg
haberg at math.su.se
Wed Apr 9 14:42:37 EDT 2008
On 9 Apr 2008, at 17:49, Henning Thielemann wrote:
> Also (2*5 == 7) would surprise people, if (*) is the symbol for a
> general group operation, and we want to use it for the additive
> group of integers.
One might resolve the "Num" binding of (+) problem by putting all
operators into an implicit superclass:
Roughly, let T be the set of of most general types, and for each t in
T define a mangling string s(t). Then if the operator
<op> :: t
is defined somewhere, it is internally defined as
class Operator_s(t)_<op> t where
<op> :: t
Then usages of it get implicit
class (Operator_s(t)_<op> t, ...) => <Class> where ...
and
instance Operator_s(t)_<op> t where ...
If I now have another class using (+), it need not be derived from
Num, as both usages are derivable from an internal
class Operator_(+)
The mangling of the type via s(t) might be used to generate C++ style
name overloading. It will then depend on how much ambiguity one wants
to accept in the context.
I do not see exactly how this works with Haskell current syntax; just
an input.
Hans
More information about the Haskell-Cafe
mailing list