[Haskell-cafe] adding the elements of two lists
Chris Smith
cdsmith at gmail.com
Mon Mar 26 02:41:48 CEST 2012
Jerzy Karczmarczuk <jerzy.karczmarczuk at unicaen.fr> wrote:
> Le 26/03/2012 01:51, Chris Smith a écrit :
>
>> instance (Num a) => Num [a] where
>> xs + ys = zipWith (+) xs ys
>>
>> You can do this in the sense that it's legal Haskell... but it is a bad idea [...]
> It MIGHT be a ring or not. The "real problem" is that one should not confuse
> structural and algebraic (in the "classical" sense) properties of your
> objects.
Of course there are rings for which it's possible to represent the
elements as lists. Nevertheless, there is definitely not one that
defines (+) = zipWith (+), as did the one I was responding to. By the
time you get a ring structure back by some *other* set of rules,
particularly for multiplication, the result will so clearly not be
anything like a general Num instance for lists that it's silly to even
be having this discussion.
--
Chris Smith
More information about the Haskell-Cafe
mailing list