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

Nathan Bouscal nbouscal at gmail.com
Wed Feb 24 15:37:40 UTC 2016


Apologies for being unclear. By marginal, I meant that I expect many
learners who end up confused by this would have otherwise come across the
same confusion by other paths. So, the long-run net amount of confusion
would be the same. That's obviously a complete guess on my part, but it
does seem somewhat reasonable. Learners definitely have to understand the
difference between lists and tuples at some point. They also ought to
understand how constructor classes work at some point. If we want to reduce
the friction in that process, we should focus our energy on creating better
educational material, not on removing certain instances that we think are
particularly opaque.

On Wed, Feb 24, 2016 at 3:24 PM, Henrik Nilsson <
Henrik.Nilsson at nottingham.ac.uk> wrote:

> Hi,
>
> Sorry Nathan, I am not following your argument: you seem to be arguing two
> ways at the same time. Maybe "marginal" should have been "major"?
>
> However:
>
> > I see an additional way for an unwary
> > learner to discover complexity that
> > was already there, by passing a value
> > that they weren't previously able to
> > pass to a function
>
> No, that specific complexity were *not* there previously. Applying length
> or maximum etc. to a tuple used to be a type error. End of story. And that
> was a good thing for many reasons, including that length or maximum on
> tuples are not particularly useful: the former being a roundabout way to
> compute 1, the latter being a rather obscurely named projection function.
>

One could similarly argue that `id` is not particularly useful, being a
roundabout way to compute something you already have.

We're clearly talking about different specific complexities. As I see it,
the complexity is in how constructor classes work (as Chris helpfully
pointed out). They work the same regardless of what instance of them you
focus on. If a learner happens to come across their existence sooner
because they accidentally called length on a tuple and became confused, we
can either 1) take the opportunity to teach them about a useful concept, or
2) postpone the explanation for later. In either case, the concept itself
is exactly as complex as it ever was.


>
> /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 14:42 (GMT+00:00)
> To: Haskell Libraries
> Subject: Re: Haskell Foldable Wats (Was: Add conspicuously missing Functor
> instances for tuples)
>
> I don't see any additional complexity. I see an additional way for an
> unwary learner to discover complexity that was already there, by passing a
> value that they weren't previously able to pass to a function that they
> don't yet have a complete model of. That will definitely cause some
> confusion, but I'm not convinced it will cause marginal confusion, nor that
> such confusion is bad. This is not the only way that learners can mix up
> tuples and lists, and that distinction is something every learner has to
> understand at some point.
>
> You can still teach tuples exactly the same way that you used to teach
> tuples, and you can still teach finding the length of a list exactly the
> same way that you used to teach it. Unless your curriculum previously
> included an explicit demonstration of `length (1, 2)` causing an error, I
> don't see why it would need to change.
>
> On Wed, Feb 24, 2016 at 2:20 PM, 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.
>>
>>
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160224/25774b08/attachment-0001.html>


More information about the Libraries mailing list