
On Wed, Feb 24, 2016 at 1:04 PM, Henrik Nilsson < Henrik.Nilsson@nottingham.ac.uk> wrote:
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?
You can use essentially the same argument to say that [a] sounds like a container of any number of elements, therefore there shouldn't be anything wrong with [1, 'foo']. It's not uncommon in programming for "what a thing naively sounds like" to be quite different from "what a thing actually is". *Tuples are not lists*. I agree that there's room for confusion, but there is room for confusion in *a lot* of parts of Haskell, especially for people who bring a lot of preconceived notions with them. We should try to make the transition easier for them, but to me that looks a lot more like "really good error messages" and less like pointedly ignoring the structure of types that might be confusing.
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@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.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries