[Haskell-cafe] instance Monad m => Functor m
lemming at henning-thielemann.de
Wed Apr 9 11:49:09 EDT 2008
On Wed, 9 Apr 2008, Hans Aberg wrote:
> On 9 Apr 2008, at 16:26, Henning Thielemann wrote:
>> 1. elementwise multiplication
>> 2. convolution
>> and you have some function which invokes the ring multiplication
>> f :: Ring a => a -> a
>> and a concrete sequence
>> x :: Sequence Integer
>> what multiplication (elementwise or convolution) shall be used for
>> computing (f x) ?
> In math, if there is a theorem about a ring, and one wants to apply it to an
> object which more than one ring structure, one needs to indicate which ring
> to use. So if I translate, then one might get something like
> class Ring (a; o, e, add, mult) ...
> class Ring(a; o, e, add, (*)) => Sequence.mult a
> Ring(a; o, e, add, (**) => Sequence.conv a
> where ...
> Then Sequence.mult and Sequence.conv will be treated as different types
> whenever there is a clash using Sequence only. - I am not sure how this fits
> into Haskell syntax though.
Additionally I see the problem, that we put more interpretation into
standard symbols by convention. Programming is not only about the most
general formulation of an algorithm but also about error detection. E.g.
you cannot compare complex numbers in a natural way, that is
x < (y :: Complex Rational)
is probably a programming error. However, some people might be happy if
(<) is defined by lexicgraphic ordering. This way complex numbers can be
used as keys in a Data.Map. But then accidental uses of (<) could no
longer be detected. (Thus I voted for a different class for keys to be
used in Data.Map, Data.Set et.al.)
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.
More information about the Haskell-Cafe