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

Jake McArthur jake.mcarthur at gmail.com
Wed Feb 24 14:34:09 UTC 2016


A pair is a certainly a container of two things, but an (a, b) is a
container of only one b. The length function is not named sufficiently
descriptively to explain it's behavior here, but that doesn't make the
behavior nonsensical.

On Wed, Feb 24, 2016, 9:20 AM Henrik Nilsson <
Henrik.Nilsson at nottingham.ac.uk> wrote:

> I am totally with Lennart here: something that used to be conceptually
> very simple, clear, and, not the least, easy to teach, has become complex
> and muddled for little if any good reason at all. What is that if not
> obfuscation?
>
> And I am not just drawing on my own experience here, but also from that of
> many colleagues with years and years of teaching experience.
>
> /Henrik
>
>
> Henrik Nilsson
> School of Computer Science
> The University of Nottingham
> nhn at cs.nott.ac.uk
>
>
>
> -------- Original message --------
> From: Nathan Bouscal
> Date:2016/02/24 13:43 (GMT+00:00)
> To: Haskell Libraries
> Subject: Re: Haskell Foldable Wats (Was: Add conspicuously missing Functor
> instances for tuples)
>
> I'm not trying to say that a pair is not a container of two things. I'm
> saying that that description is insufficiently specific to be useful for
> the purposes of the discussion. There are many ways to be a container of
> two things, and if we are to have functions whose behavior depends on the
> structure of the data they're working on, it's inevitable that those
> functions will behave differently for different of those ways of being a
> container. If the issue is that "containers" don't always behave the way
> one might naively expect containers to behave, then I'm just pointing out
> that this isn't the only place that holds, and that in other areas we've
> already accepted this.
>
> On Wed, Feb 24, 2016 at 1:38 PM, Augustsson, Lennart <
> Lennart.Augustsson at sc.com> wrote:
>
>> Of course a pair is a container of two things (which can have different
>> types).
>>
>> You can come up with some different definition of what it means to be a
>> container, so that a pair is no longer a container of two things, but this
>> is just obfuscation.
>>
>>
>>
>> *From:* Libraries [mailto:libraries-bounces at haskell.org] *On Behalf Of *Nathan
>> Bouscal
>> *Sent:* 24 February 2016 13:29
>> *To:* Haskell Libraries
>> *Subject:* Re: Haskell Foldable Wats (Was: Add conspicuously missing
>> Functor instances for tuples)
>>
>>
>>
>> On Wed, Feb 24, 2016 at 1:04 PM, Henrik Nilsson <
>> Henrik.Nilsson at 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 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.
>>
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>> This email and any attachments are confidential and may also be
>> privileged. If you are not the intended recipient, please delete all copies
>> and notify the sender immediately. You may wish to refer to the
>> incorporation details of Standard Chartered PLC, Standard Chartered Bank
>> and their subsidiaries at
>> http://www.standardchartered.com/en/incorporation-details.html
>>
>> Insofar as this communication contains any market commentary, the market
>> commentary has been prepared by sales and/or trading desk of Standard
>> Chartered Bank or its affiliate. It is not and does not constitute research
>> material, independent research, recommendation or financial advice. Any
>> market commentary is for information purpose only and shall not be relied
>> for any other purpose, and is subject to the relevant disclaimers available
>> at
>> http://wholesalebanking.standardchartered.com/en/utility/Pages/d-mkt.aspx
>>
>> Insofar as this e-mail contains the term sheet for a proposed
>> transaction, by responding affirmatively to this e-mail, you agree that you
>> have understood the terms and conditions in the attached term sheet and
>> evaluated the merits and risks of the transaction. We may at times also
>> request you to sign on the term sheet to acknowledge in respect of the same.
>>
>> Please visit
>> http://wholesalebanking.standardchartered.com/en/capabilities/financialmarkets/Pages/doddfrankdisclosures.aspx
>> for important information with respect to derivative products.
>>
>
>
>
>
> 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160224/a9ba5c88/attachment.html>


More information about the Libraries mailing list