From michael.eugene.turner at gmail.com Tue Aug 3 09:06:35 2021 From: michael.eugene.turner at gmail.com (Michael Turner) Date: Tue, 3 Aug 2021 18:06:35 +0900 Subject: [Haskell-beginners] Beginners Digest, Vol 157, Issue 1 In-Reply-To: References: Message-ID: "I recently wrote a blog post which explains how expressions are evaluated: https://coot.me/posts/containers-strict-foldr.html" OK, but what I was asking for is a one-or-two-page diagram of the dependencies among Haskell concepts. A diagram. Do you know of any such thing? Regards, Michael Turner Executive Director Project Persephone 1-25-33 Takadanobaba Shinjuku-ku Tokyo 169-0075 Mobile: +81 (90) 5203-8682 turner at projectpersephone.org Understand - http://www.projectpersephone.org/ Join - http://www.facebook.com/groups/ProjectPersephone/ Donate - http://www.patreon.com/ProjectPersephone Volunteer - https://github.com/ProjectPersephone "Love does not consist in gazing at each other, but in looking outward together in the same direction." -- Antoine de Saint-Exupéry On Sun, Aug 1, 2021 at 9:07 PM wrote: > > Send Beginners mailing list submissions to > beginners at 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-request at haskell.org > > You can reach the person managing the list at > beginners-owner at 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: A one- or two-page diagram of how Haskell works? > (coot at coot.me) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 31 Jul 2021 14:49:16 +0000 > From: coot at coot.me > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] A one- or two-page diagram of how > Haskell works? > Message-ID: > > > Content-Type: text/plain; charset="utf-8" > > I recently wrote a blog post which explains how expressions are evaluated: https://coot.me/posts/containers-strict-foldr.html > > Best regards, > Marcin > > Sent with ProtonMail Secure Email. > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > > On Thursday, June 24th, 2021 at 05:41, Michael Turner wrote: > > > When I write C, or even C++, I have a mental model of how execution > > > > > will proceed. > > > > > When I write Prolog, but get confused, I run a kind of skeletal > > > > > inference algorithm in my head and the confusion usually clears up. I > > > > > can imagine how things are stored and what's done with them. I can see > > > > > /through/ the code to the machine. > > > > > With Haskell, I still feel blind. > > > > > Has anyone summarized it all in a chart where I can look at it and > > > > > think, "Ah, OK, GHC is taking this line and thinking of it THIS way"? > > > > > If someone wanted to write an interpreter for Haskell, would there be > > > > > a way for them to see how it would basically need to work, in one > > > > > chart? > > > > > Regards, > > > > > Michael Turner > > > > > Executive Director > > > > > Project Persephone > > > > > 1-25-33 Takadanobaba > > > > > Shinjuku-ku Tokyo 169-0075 > > > > > Mobile: +81 (90) 5203-8682 > > > > > turner at projectpersephone.org > > > > > Understand - http://www.projectpersephone.org/ > > > > > Join - http://www.facebook.com/groups/ProjectPersephone/ > > > > > Donate - http://www.patreon.com/ProjectPersephone > > > > > Volunteer - https://github.com/ProjectPersephone > > > > > "Love does not consist in gazing at each other, but in looking outward > > > > > together in the same direction." -- Antoine de Saint-Exupéry > > > > > Beginners mailing list > > > > > Beginners at haskell.org > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: signature.asc > Type: application/pgp-signature > Size: 509 bytes > Desc: OpenPGP digital signature > URL: > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 157, Issue 1 > ***************************************** From borgauf at gmail.com Tue Aug 3 22:14:38 2021 From: borgauf at gmail.com (Galaxy Being) Date: Tue, 3 Aug 2021 17:14:38 -0500 Subject: [Haskell-beginners] Explanation of elem data type Message-ID: According to this elem is Eq a => a -> [a] -> Bool but according to my ghci :t it's this elem :: (Foldable t, Eq a) => a -> t a -> Bool I understand the first, but not the second, especially with the t. What is this saying extra, different from the first one? ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Aug 3 22:37:43 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 4 Aug 2021 00:37:43 +0200 Subject: [Haskell-beginners] Explanation of elem data type In-Reply-To: References: Message-ID: <20210803223743.GA1485@extensa> Hello Lawrence, Il 03 agosto 2021 alle 17:14 Galaxy Being ha scritto: > According to this > elem is > > Eq a => a -> [a] -> Bool > > but according to my ghci :t it's this > > elem :: (Foldable t, Eq a) => a -> t a -> Bool > > I understand the first, but not the second, especially with the t. What is > this saying extra, different from the first one? Yup, some years ago there was a shift of some functions — after a big discussion, as there were a few controversial changes — from «working on lists only» to «working on all instances of some class» (in this case: Foldable, alias «data structures that can be folded») [1]. What is there for you? You gain the ability to use `elem` on other structures than lists (e.g. Trees). If you — like me — do not fancy reading signatures with too many typeclasses, you can always use +d in ghci to default to concrete types: λ> :t foldr foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b λ> :t +d foldr foldr :: (a -> b -> b) -> b -> [a] -> b [1] https://wiki.haskell.org/Foldable_Traversable_In_Prelude From borgauf at gmail.com Wed Aug 4 00:36:20 2021 From: borgauf at gmail.com (Galaxy Being) Date: Tue, 3 Aug 2021 19:36:20 -0500 Subject: [Haskell-beginners] Explanation of elem data type In-Reply-To: <20210803223743.GA1485@extensa> References: <20210803223743.GA1485@extensa> Message-ID: Thanks for the insights. So what then does the t a part mean? In the simpler version t a is [a]. Is t some container? It's not meant to be a function, is it? On Tue, Aug 3, 2021 at 5:39 PM Francesco Ariis wrote: > Hello Lawrence, > > Il 03 agosto 2021 alle 17:14 Galaxy Being ha scritto: > > According to this < > http://zvon.org/other/haskell/Outputprelude/elem_f.html> > > elem is > > > > Eq a => a -> [a] -> Bool > > > > but according to my ghci :t it's this > > > > elem :: (Foldable t, Eq a) => a -> t a -> Bool > > > > I understand the first, but not the second, especially with the t. What > is > > this saying extra, different from the first one? > > Yup, some years ago there was a shift of some functions — after > a big discussion, as there were a few controversial changes — from > «working on lists only» to «working on all instances of some > class» (in this case: Foldable, alias «data structures that can > be folded») [1]. > > What is there for you? You gain the ability to use `elem` on > other structures than lists (e.g. Trees). > If you — like me — do not fancy reading signatures with too many > typeclasses, you can always use +d in ghci to default to concrete > types: > > λ> :t foldr > foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b > λ> :t +d foldr > foldr :: (a -> b -> b) -> b -> [a] -> b > > [1] https://wiki.haskell.org/Foldable_Traversable_In_Prelude > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Wed Aug 4 01:03:54 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 4 Aug 2021 03:03:54 +0200 Subject: [Haskell-beginners] Explanation of elem data type In-Reply-To: References: <20210803223743.GA1485@extensa> Message-ID: <20210804010353.GA15383@extensa> Il 03 agosto 2021 alle 19:36 Galaxy Being ha scritto: > Thanks for the insights. So what then does the t a part mean? In the > simpler version t a is [a]. Is t some container? It's not meant to be a > function, is it? `t` is any unary type constructor. Maybe, Tree, etc. all take one parameter (Maybe a, Tree a, etc.); in a similar fashion [] takes one parameter ([] a). [a] is just syntactic sugar λ> [7] :: [Int] [7] λ> [7] :: [] Int [7] From rri at silentyak.com Wed Aug 4 01:26:17 2021 From: rri at silentyak.com (Ramnath R Iyer) Date: Tue, 3 Aug 2021 18:26:17 -0700 Subject: [Haskell-beginners] Explanation of elem data type In-Reply-To: <20210804010353.GA15383@extensa> References: <20210803223743.GA1485@extensa> <20210804010353.GA15383@extensa> Message-ID: To add, t is typically some kind of container although it doesn’t have to be. For instance, “t a” could be a “list (of) cat(s)”, except it doesn’t *have* to be a list (can be anything that’s an instance of Foldable), and it doesn’t *have* to be cats (could be a giraffe or a piano or any other type). In “list (of) cat(s)”, list can be thought of as a type-level function that takes a type (cat) to construct a concrete type (list cat), hence the notation. This shows you commonly defined instances of Foldable (notice that the very first one is a list, denoted by [ ]). https://hackage.haskell.org/package/Cabal-3.4.0.0/docs/Distribution-Compat-Prelude-Internal.html#t:Foldable — RRI On Tue, Aug 3, 2021 at 18:06 Francesco Ariis wrote: > Il 03 agosto 2021 alle 19:36 Galaxy Being ha scritto: > > Thanks for the insights. So what then does the t a part mean? In the > > simpler version t a is [a]. Is t some container? It's not meant to be a > > function, is it? > > `t` is any unary type constructor. Maybe, Tree, etc. all take one parameter > (Maybe a, Tree a, etc.); in a similar fashion [] takes one parameter > ([] a). [a] is just syntactic sugar > > λ> [7] :: [Int] > [7] > λ> [7] :: [] Int > [7] > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- -- Ramnath R Iyer -------------- next part -------------- An HTML attachment was scrubbed... URL: