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: A one- or two-page diagram of how Haskell works? (Steven Leiva) 2. Re: A one- or two-page diagram of how Haskell works? (Steven Leiva) 3. Re: A one- or two-page diagram of how Haskell works? (Tarik ÖZKANLI) ---------------------------------------------------------------------- Message: 1 Date: Thu, 24 Jun 2021 09:43:10 -0400 From: Steven Leiva <leiva.ste...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] A one- or two-page diagram of how Haskell works? Message-ID: <CA+=woS63+teNkVA4_=uoscmgpk-k-qkxnwyefu2g73degps...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Wonderful question. I would love to see something like this too. What kind of confusion are you running into with Haskell? Are they of the type error variety, or do you have a well-typed program that doesn't do what you want? *If* it is the type error stuff, I would recommend that you give the compiler information about what you think the types are. The reason is that type information can flow from very far away places than where you are getting an error. For example, I was writing this code the other day: *for eIdpData \ $(schoolId, districtId, tenantId) -> pure $ Right 1* The type of for is *for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)* In my case, I knew the following: *t ~ Either SyncFailure* *a ~ IdpData* *f ~ WriterT Logs m* *b ~ Int* Once I do replace type variables with concrete types / type constructors, it becomes clear that my function argument should return an *Int* in some structure, and instead I am returning an *Either a Int*. This helps me figure out the problem. Writing out takes a lot longer than actually doing it. Anyway, the key is to provide GHC with the information you think you know; this will prevent type inference from allowing type information to flow from far away places, and the error will become clearer or at the very least more localized. On Wed, Jun 23, 2021 at 11:42 PM Michael Turner < michael.eugene.tur...@gmail.com> 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 > tur...@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@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- Steven Leiva 305.528.6038 leiva.ste...@gmail.com http://www.linkedin.com/in/stevenleiva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210624/8b61c92b/attachment-0001.html> ------------------------------ Message: 2 Date: Thu, 24 Jun 2021 09:45:27 -0400 From: Steven Leiva <leiva.ste...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] A one- or two-page diagram of how Haskell works? Message-ID: <CA+=woS7_pLRJ_PX95hGTHjR0qgUrj7sSJzO=W=o0vAW6WVvO=w...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" A few caveats to the above: 1) The literal *1* is polymorphic, but I hand-waved over that for now 2) *Either e Int* is an *Int* in *some* structure, but it's not the structure we want. In the type signature for *for*, the function argument does not contain the *t* type variable at all, which, again, is in our case *t ~ Either SyncFailure*. On Thu, Jun 24, 2021 at 9:43 AM Steven Leiva <leiva.ste...@gmail.com> wrote: > Wonderful question. I would love to see something like this too. > > What kind of confusion are you running into with Haskell? Are they of the > type error variety, or do you have a well-typed program that doesn't do > what you want? > > *If* it is the type error stuff, I would recommend that you give the > compiler information about what you think the types are. The reason is that > type information can flow from very far away places than where you are > getting an error. For example, I was writing this code the other day: > > *for eIdpData \ $(schoolId, districtId, tenantId) -> pure $ Right 1* > > The type of for is *for :: (Traversable t, Applicative f) => t a -> (a -> > f b) -> f (t b)* > > In my case, I knew the following: > > *t ~ Either SyncFailure* > *a ~ IdpData* > *f ~ WriterT Logs m* > *b ~ Int* > > Once I do replace type variables with concrete types / type constructors, > it becomes clear that my function argument should return an *Int* in some > structure, and instead I am returning an *Either a Int*. This helps me > figure out the problem. > > Writing out takes a lot longer than actually doing it. Anyway, the key is > to provide GHC with the information you think you know; this will prevent > type inference from allowing type information to flow from far away places, > and the error will become clearer or at the very least more localized. > > On Wed, Jun 23, 2021 at 11:42 PM Michael Turner < > michael.eugene.tur...@gmail.com> 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 >> tur...@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@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > > > -- > Steven Leiva > 305.528.6038 > leiva.ste...@gmail.com > http://www.linkedin.com/in/stevenleiva > -- Steven Leiva 305.528.6038 leiva.ste...@gmail.com http://www.linkedin.com/in/stevenleiva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210624/8a222f1f/attachment-0001.html> ------------------------------ Message: 3 Date: Thu, 24 Jun 2021 17:10:48 +0300 From: Tarik ÖZKANLI <tozkanli2...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] A one- or two-page diagram of how Haskell works? Message-ID: <cagxnkg9ryluljnhztaj8pg3jfsyiudahmb5sv+14sfryrf1...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" It's better to try to model execution using lambda calculus. The most dominant factor in languages like Haskell is lambda calculus. Think through lambda calculus for a mental model. On Thu, 24 Jun 2021 at 16:45, Steven Leiva <leiva.ste...@gmail.com> wrote: > Wonderful question. I would love to see something like this too. > > What kind of confusion are you running into with Haskell? Are they of the > type error variety, or do you have a well-typed program that doesn't do > what you want? > > *If* it is the type error stuff, I would recommend that you give the > compiler information about what you think the types are. The reason is that > type information can flow from very far away places than where you are > getting an error. For example, I was writing this code the other day: > > *for eIdpData \ $(schoolId, districtId, tenantId) -> pure $ Right 1* > > The type of for is *for :: (Traversable t, Applicative f) => t a -> (a -> > f b) -> f (t b)* > > In my case, I knew the following: > > *t ~ Either SyncFailure* > *a ~ IdpData* > *f ~ WriterT Logs m* > *b ~ Int* > > Once I do replace type variables with concrete types / type constructors, > it becomes clear that my function argument should return an *Int* in some > structure, and instead I am returning an *Either a Int*. This helps me > figure out the problem. > > Writing out takes a lot longer than actually doing it. Anyway, the key is > to provide GHC with the information you think you know; this will prevent > type inference from allowing type information to flow from far away places, > and the error will become clearer or at the very least more localized. > > On Wed, Jun 23, 2021 at 11:42 PM Michael Turner < > michael.eugene.tur...@gmail.com> 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 >> tur...@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@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > > > -- > Steven Leiva > 305.528.6038 > leiva.ste...@gmail.com > http://www.linkedin.com/in/stevenleiva > _______________________________________________ > 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/20210624/5708a2e6/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 155, Issue 9 *****************************************