Haskell Foldable Wats (Was: Add conspicuously missing Functor instances for tuples)

Henrik Nilsson Henrik.Nilsson at nottingham.ac.uk
Wed Feb 24 13:04:00 UTC 2016


Hi,

On 02/24/2016 11:08 AM, Fumiaki Kinoshita wrote:
> Thinking tuples of as multi-element containers is not recommended. A
> tuple (a, b) is, a pair of one 'a' and one 'b';

Which, to me, at least, very much sounds like a container of two
elements?

Seriosuly, if, as a result of tuples being instances of Functor and
Foldable etc., the end result is confusion to the point that
many no longer understand a tuple simply as a container of a certain
number of elements, then that's another case in point against
this whole design. (In particular the Foldable part: while I personally
don't find the functor instances particularly compelling or useful,
they seem less likely to seriously bite.)

> as Foldable works on
> values pointed by the rightmost type argument, 1 should be the only
> reasonable result of 'length'.
>
>      data TwoThree a b = TwoThree a a b b b
>
> What should 'length (TwoThree "Foo" "Bar" 0 1 2)' be?

A static type error, perhaps?

(As indeed it will be unless the appropriate instances are made
for TwoThree. But I am guessing we should understand TwoThree
as a tuple here.)

> Looking at only
> the expression, 5 might seem to make sense, but is not meaningful
> considering the type.
>

Best,

/Henrik
-- 
Henrik Nilsson
School of Computer Science
The University of Nottingham
nhn at cs.nott.ac.uk




This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.



More information about the Libraries mailing list