Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Francesco Ariis (Ryan Trinkle) 2. Re: Foldable for (,) (Doug McIlroy) 3. Re: Foldable for (,) (Tony Morris) 4. Re: Foldable for (,) (Michael Orlitzky) 5. Re: Foldable for (,) (Jonathon Delgado) 6. Re: Foldable for (,) (David Thomas) 7. Re: Foldable for (,) (Tony Morris) ---------------------------------------------------------------------- Message: 1 Date: Sun, 23 Apr 2017 08:45:59 -0400 From: Ryan Trinkle <ryan.trin...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Francesco Ariis Message-ID: <CAHNEpiy30oN1OJ5F8vh_M_Gw22EtdJa35e=zicm5d0rerys...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I've used them plenty of times, especially in conjunction with Compose <https://hackage.haskell.org/package/transformers-0.3.0.0/docs/Data-Functor-Compose.html#t:Compose>, to add annotations to things I'm traversing. On Sun, Apr 23, 2017 at 7:08 AM, Jonathon Delgado <volderm...@hotmail.com> wrote: > So then the question becomes, why do tuples need Foldable if the functions > it defines aren't useful? > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170423/21b9ea2f/attachment-0001.html> ------------------------------ Message: 2 Date: Sun, 23 Apr 2017 10:47:31 -0400 From: Doug McIlroy <d...@cs.dartmouth.edu> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <201704231447.v3nelvmc008...@coolidge.cs.dartmouth.edu> Content-Type: text/plain; charset=us-ascii > 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. To me, "annotation" connotes auxiliary information--yet it will be the primary key when pairs are sorted. I would be more comfortable with the explanation if the field were referred to as an "identifier", or some similar term. Doug ------------------------------ Message: 3 Date: Mon, 24 Apr 2017 10:29:49 +1000 From: Tony Morris <tonymor...@gmail.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <06c55922-c9a5-3e16-e8c7-208efd3e4...@gmail.com> Content-Type: text/plain; charset="utf-8" A tuple doesn't only have one value. forall a. ((,) a) only has one value. Fortunately, Haskell has a kind system so we can easily determine what length does. > :k Foldable Foldable :: (* -> *) -> Constraint Clearly then, if we see a program (length x) where x is a tuple, then we can easily determine that this a constant value 1. For the same reason if we see (length [[1,2,3], [4,5,6]]) and ask, is the length 2 or 6? It's clearly 2; just look at the kind of Foldable. I like types, and types of types. Join me. On 23/04/17 20:06, Jonathon Delgado wrote: > If a tuple only has one value, -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170424/52191e27/attachment-0001.sig> ------------------------------ Message: 4 Date: Sun, 23 Apr 2017 21:36:08 -0400 From: Michael Orlitzky <mich...@orlitzky.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <c596c5ca-adb6-e726-791f-34709ba0c...@orlitzky.com> Content-Type: text/plain; charset=utf-8; format=flowed On 04/23/2017 08:29 PM, Tony Morris wrote: > A tuple doesn't only have one value. forall a. ((,) a) only has one > value. Fortunately, Haskell has a kind system so we can easily determine > what length does. This all makes sense when you realize that Foldable is just the "Object" class from Visual Basic. There's only one sensible way to define a ToString() method on an arbitrary object; therefore it makes sense to provide that method by default, and to have it do the one thing it can do (print garbage). ------------------------------ Message: 5 Date: Mon, 24 Apr 2017 06:52:54 +0000 From: Jonathon Delgado <volderm...@hotmail.com> To: "beginners@haskell.org" <beginners@haskell.org> Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <loxp123mb13991dc9e627b969a2498bfecd...@loxp123mb1399.gbrp123.prod.outlook.com> Content-Type: text/plain; charset="iso-8859-1" Tony Morris - please could you give a (practical) example of code where the a tuple could realistically be passed to length, but you don't know what the answer will be at compile time? Michael Orlitzky - everything in .NET has to descend from Object because of it's OO design. Why does tuple have to implement Foldable if it doesn't provide any useful functions? Thank you very much everyone in this thread for helping me understand! ------------------------------ Message: 6 Date: Mon, 24 Apr 2017 01:20:10 -0700 From: David Thomas <davidleotho...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <cajudvcghlregc7jylf-vppmuxeymxt0mzyk45oeclkamn63...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 One thing that's been missed in this discussion is that constraints can propagate. Of course no one is wanting to pass something they know is a tuple into a function they know is length. But a function that expects something Foldable might want to know length or sum, and it might be reasonable to call that function on a tuple. On Sun, Apr 23, 2017 at 11:52 PM, Jonathon Delgado <volderm...@hotmail.com> wrote: > Tony Morris - please could you give a (practical) example of code where the a > tuple could realistically be passed to length, but you don't know what the > answer will be at compile time? > > Michael Orlitzky - everything in .NET has to descend from Object because of > it's OO design. Why does tuple have to implement Foldable if it doesn't > provide any useful functions? > > Thank you very much everyone in this thread for helping me understand! > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ Message: 7 Date: Mon, 24 Apr 2017 20:30:54 +1000 From: Tony Morris <tmor...@tmorris.net> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Foldable for (,) Message-ID: <CAJf6UsiE8w+yL81f5tckwFEGBX=g1yufxq2pemjfcutmjgr...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I only know that the length of any forall a. ((,) a) is going to be one. When it is polymorphic, I don't know that it is ((,) a) although it might be at the call site, and so I don't know the length. On Mon, Apr 24, 2017 at 4:52 PM, Jonathon Delgado <volderm...@hotmail.com> wrote: > Tony Morris - please could you give a (practical) example of code where > the a tuple could realistically be passed to length, but you don't know > what the answer will be at compile time? > > Michael Orlitzky - everything in .NET has to descend from Object because > of it's OO design. Why does tuple have to implement Foldable if it doesn't > provide any useful functions? > > Thank you very much everyone in this thread for helping me understand! > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170424/103c927e/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 106, Issue 17 ******************************************