Constraints on definition of `length` should be strengthened

Anthony Clayden anthony_clayden at clear.net.nz
Sat Apr 8 02:03:32 UTC 2017


> On Tue Apr 4 06:50:55 UTC 2017, Sven Panne wrote:

>> 2017-04-04 8:15 GMT+02:00 Vladislav Zavialov:

>>> Tuples are unbiased cartesian products, full stop.
>>
>> This statement is not correct.

> According to probably all the math books in the world,
> the statement is correct, 
> at least if we want to see tuples as cartesian products.
..

Sven, I have a lot of sympathy with the digruntlement about
Foldable `length` over tuples.
But if you're going to start appealing to math,
you'd better get your math correct.

Whether or not tuples are unbiased,
even wikipedia will tell you they're not commutative.

So to take your examples from an earlier thread,
what do you expect Haskell to do here?:

   maximum (True,2)   =>   ?
   minimum ((3, 4),5)   => ?   -- i.e. :: ((Int, Int), Int)
   sum (7,3.14)   =>   ?     -- i.e. :: (Int, Double)
   product (Left $ error "Errk")   =>   ?   -- i.e. ::
Either e Int

Do you expect Foldable (a, a) to behave differently
vs Foldable (b, a) vs Foldable ((a, a), a) vs ...?

Let's get everybody agreed on that.
Then we can talk about our currying/kind system.

Note that there's been an `instance Foldable Maybe` for
ever,
and `toList` applied to that returns a 0-or-1 length list.

>> Look at their kind:
>>
>> > :k (,)
>> > (,) :: * -> * -> *
>>
>> The same currying business is going on here. [...]

> That's an artifact of our kind system,
> not a consequence of the usual definition of cartesian
products.


AntC


More information about the Libraries mailing list