Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Foldable for (,) (Jonathon Delgado)
2. Re: Foldable for (,) (Francesco Ariis)
3. Re: Foldable for (,) (Jonathon Delgado)
4. Re: Foldable for (,) (Francesco Ariis)
5. Francesco Ariis (Jonathon Delgado)
6. Re: Foldable for (,) (Jonathon Delgado)
----------------------------------------------------------------------
Message: 1
Date: Sun, 23 Apr 2017 08:21:34 +0000
From: Jonathon Delgado <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Foldable for (,)
Message-ID:
<loxp123mb1399216246a6af63ee570dcacd...@loxp123mb1399.gbrp123.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
I've seen many threads, including the one going on now, about why we need to
have:
length (2,3) = 1
product (2,3) = 3
sum (2,3) = 3
or (True,False) = False
but the justifications all go over my head. Is there a beginner-friendly
explanation for why such seemingly unintuitive operations should be allowed by
default?
------------------------------
Message: 2
Date: Sun, 23 Apr 2017 10:45:34 +0200
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Foldable for (,)
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sun, Apr 23, 2017 at 08:21:34AM +0000, Jonathon Delgado wrote:
> I've seen many threads, including the one going on now, about why we need
> to have:
>
> length (2,3) = 1
> product (2,3) = 3
> sum (2,3) = 3
> or (True,False) = False
>
> but the justifications all go over my head. Is there a beginner-friendly
> explanation for why such seemingly unintuitive operations should be
> allowed by default?
Hello Jonathon,
the proponents of `Foldable (a,)` see `(2,3)` not as a pair of 'equal'
values, but as a value *and* an annotation, much like some other folks
see Either as having a value (Right a) *or* an annotation (usually an
error in the form of Left e).
So to go back to your examples:
(2,3)
^ ^
| +------------- I am the value
|
+--------------- I am an annotation (and since tuples arguments can
be heterogeneous, I could be a String, a Bool,
anything).
If you agree with this paradigm, `length`, `sum` and friend become a
bit less icky.
I would prefer tuples to be unbiased, but this intuition helped me
connect with the people on the other side of the line.
Does this help?
------------------------------
Message: 3
Date: Sun, 23 Apr 2017 10:06:00 +0000
From: Jonathon Delgado <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Re: [Haskell-beginners] Foldable for (,)
Message-ID:
<loxp123mb13994f042b0a99cb902a7616cd...@loxp123mb1399.gbrp123.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
If a tuple only has one value, why do functions for operating over sets make
sense at all? I can see from your explanations why the answers could be
considered correct (if a particular convention is assumed), but why does the
operation make sense at all? It seems like we're asking for the length of a
single value, its product, etc.
Francesco Ariis wrote:
> I've seen many threads, including the one going on now, about why we need
> to have:
>
> length (2,3) = 1
> product (2,3) = 3
> sum (2,3) = 3
> or (True,False) = False
>
> but the justifications all go over my head. Is there a beginner-friendly
> explanation for why such seemingly unintuitive operations should be
> allowed by default?
Hello Jonathon,
the proponents of `Foldable (a,)` see `(2,3)` not as a pair of 'equal'
values, but as a value *and* an annotation, much like some other folks
see Either as having a value (Right a) *or* an annotation (usually an
error in the form of Left e).
So to go back to your examples:
(2,3)
^ ^
| +------------- I am the value
|
+--------------- I am an annotation (and since tuples arguments can
be heterogeneous, I could be a String, a Bool,
anything).
If you agree with this paradigm, `length`, `sum` and friend become a
bit less icky.
I would prefer tuples to be unbiased, but this intuition helped me
connect with the people on the other side of the line.
Does this help?
------------------------------
Message: 4
Date: Sun, 23 Apr 2017 12:56:38 +0200
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Foldable for (,)
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sun, Apr 23, 2017 at 10:06:00AM +0000, Jonathon Delgado wrote:
> If a tuple only has one value, why do functions for operating over sets
> make sense at all? I can see from your explanations why the answers could
> be considered correct (if a particular convention is assumed), but why
> does the operation make sense at all? It seems like we're asking for the
> length of a single value, its product, etc.
I can only guess: consistency. Once you create an instance of `Foldable`
you instantly get some functions "for free". Among those are foldMap,
foldr etc. *and* sum, length and friends.
I cannot see an occurrence where writing `length (x, y)` instead of 1
makes sense.
------------------------------
Message: 5
Date: Sun, 23 Apr 2017 11:08:45 +0000
From: Jonathon Delgado <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Francesco Ariis
Message-ID:
<loxp123mb13992dc79a7b1d720b6711dacd...@loxp123mb1399.gbrp123.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
So then the question becomes, why do tuples need Foldable if the functions it
defines aren't useful?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170423/137d3cb7/attachment-0001.html>
------------------------------
Message: 6
Date: Sun, 23 Apr 2017 11:48:16 +0000
From: Jonathon Delgado <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Re: [Haskell-beginners] Foldable for (,)
Message-ID:
<loxp123mb1399752238540bc48ffad00dcd...@loxp123mb1399.gbrp123.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
So then the question becomes, why do tuples need Foldable if the functions it
defines aren't useful?
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 106, Issue 16
******************************************