Revamping the numeric classes

Marcin 'Qrczak' Kowalczyk mk167280@students.mimuw.edu.pl
Wed, 7 Feb 2001 10:37:03 +0100 (CET)


On Wed, 7 Feb 2001, Bjorn Lisper wrote:

> I'd like to point out the connection between the use of +, - on vector
> spaces and * for scaling with features in some data parallel languages.  In
> these languages, writing a + b where a and b are arrays of numerics is
> interpreted as elementwise addition of a and b. This features generalises to
> other operations than +, -, other types than numerical ones, and other data
> structures than arrays.

This is what I dislike. It's implicit fmap / zipWith / etc. But it only
works as long as there is only one meaningful way to insert these fmaps.
When I apply length to a list of lists, is it the length of the whole list
or a list of lengths of its elements? So there must be explicit ways of
specifying the amount of fmaps, and one cannot assume that they will be
always placed automatically. It might be convenient for very specific
types computation but is not a working general idea.

> Furthermore, some of these languages support "promotion": "lifting" a
> "scalar"-typed expression, appearing in a context where an array (say)
> is expected, into an array with suitable dimensions containing copies
> of the scalar.

Again, Haskell does not have subtyping. It is not compatible with type
inference - it can only work in poor languages which require an operation
to be fully applied where it is used, and either don't have static types
or require them to be specified explicitly. In Haskell trying to implement
such overloading would be too clumsy and would not work as expected in all
cases, so better don't go this way.

-- 
Marcin 'Qrczak' Kowalczyk