<div dir="ltr">A few caveats to the above:<div><br></div><div>1) The literal <b>1</b> is polymorphic, but I hand-waved over that for now</div><div>2) <b>Either e Int</b> is an <b>Int</b> in <i>some</i> structure, but it's not the structure we want. In the type signature for <b>for</b>, the function argument does not contain the <b>t</b> type variable at all, which, again, is in our case <b>t ~ Either SyncFailure</b>. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 24, 2021 at 9:43 AM Steven Leiva <<a href="mailto:leiva.steven@gmail.com">leiva.steven@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Wonderful question. I would love to see something like this too. <div><br></div><div>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?</div><div><br></div><div><b>If</b> 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:</div><div><br></div><div><b>for eIdpData \ $(schoolId, districtId, tenantId) -> pure $ Right 1</b></div><div><br></div><div>The type of for is <b>for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)</b></div><div><br></div><div>In my case, I knew the following:</div><div><br></div><div><b>t ~ Either SyncFailure</b></div><div><b>a ~ IdpData</b></div><div><b>f ~ WriterT Logs m</b></div><div><b>b ~ Int</b></div><div><br></div><div>Once I do replace type variables with concrete types / type constructors, it becomes clear that my function argument should return an <b>Int</b> in some structure, and instead I am returning an <b>Either a Int</b>. This helps me figure out the problem. </div><div><br></div><div>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. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 23, 2021 at 11:42 PM Michael Turner <<a href="mailto:michael.eugene.turner@gmail.com" target="_blank">michael.eugene.turner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When I write C, or even C++, I have a mental model of how execution<br>
will proceed.<br>
<br>
When I write Prolog, but get confused, I run a kind of skeletal<br>
inference algorithm in my head and the confusion usually clears up. I<br>
can imagine how things are stored and what's done with them. I can see<br>
/through/ the code to the machine.<br>
<br>
With Haskell, I still feel blind.<br>
<br>
Has anyone summarized it all in a chart where I can look at it and<br>
think, "Ah, OK, GHC is taking this line and thinking of it THIS way"?<br>
If someone wanted to write an interpreter for Haskell, would there be<br>
a way for them to see how it would basically need to work, in one<br>
chart?<br>
<br>
Regards,<br>
Michael Turner<br>
Executive Director<br>
Project Persephone<br>
1-25-33 Takadanobaba<br>
Shinjuku-ku Tokyo 169-0075<br>
Mobile: +81 (90) 5203-8682<br>
<a href="mailto:turner@projectpersephone.org" target="_blank">turner@projectpersephone.org</a><br>
<br>
Understand - <a href="http://www.projectpersephone.org/" rel="noreferrer" target="_blank">http://www.projectpersephone.org/</a><br>
Join - <a href="http://www.facebook.com/groups/ProjectPersephone/" rel="noreferrer" target="_blank">http://www.facebook.com/groups/ProjectPersephone/</a><br>
Donate - <a href="http://www.patreon.com/ProjectPersephone" rel="noreferrer" target="_blank">http://www.patreon.com/ProjectPersephone</a><br>
Volunteer - <a href="https://github.com/ProjectPersephone" rel="noreferrer" target="_blank">https://github.com/ProjectPersephone</a><br>
<br>
"Love does not consist in gazing at each other, but in looking outward<br>
together in the same direction." -- Antoine de Saint-Exupéry<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr">Steven Leiva<br>305.528.6038<br><a href="mailto:leiva.steven@gmail.com" target="_blank">leiva.steven@gmail.com</a><br><a href="http://www.linkedin.com/in/stevenleiva" target="_blank">http://www.linkedin.com/in/stevenleiva</a><br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Steven Leiva<br>305.528.6038<br><a href="mailto:leiva.steven@gmail.com" target="_blank">leiva.steven@gmail.com</a><br><a href="http://www.linkedin.com/in/stevenleiva" target="_blank">http://www.linkedin.com/in/stevenleiva</a><br></div>