-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ch4 Defer Array do notation section #212
Comments
Maybe... but if I'm reading through this book and I have already come across these terms, do you think I might find it a bit weird that the book would choose not to mention them here? It's not as if they're unheard of outside of the pure FP niche. I think the book should at least mention that do notation is not just for arrays (or whatever type we first use it with), as otherwise readers might come away with the impression that it is just for arrays.
Could you explain this one in a little bit more detail please?
I'm not sure about this; I think being able to work with arrays is pretty much necessary, and
I do agree that Maybe may be a better starting point for do notation, but I'm not sure full understanding should really be a goal of any part of this book. I don't think full understanding of do notation is possible until you're well into the "intermediate" category.
In this sentence, the first occurrence of
whereas the second refers to Prelude's map with the more general type. |
I conflated the "do notation for arrays" section (which I'm proposing deferring) with the earlier "array comprehension" section, which we should keep. To elaborate on the confusion with introducing do notation with an The inner-workings of It's tricky to decide on the right sequence for material, since so much content is related. For example, should we cover type classes before |
I don't think type classes should be covered before. This is how you get to "all theory before practice" type of book which in my opinion doesn't keep you engaged very well since you get to do practice way down the line. I think beginners often wonder "How do I access the contents of a wrapped type?" e.g. I think the haskell wikibook introduces it like this via Also the example with |
Thinking of deferring the "do notation" (for arrays) section to Chapter 7. The Applicative Functors for Parallelism section discusses how there's flexibility in ordering of effects (parallel vs sequential), which is a nice parallel to zippy vs default I'd like to introduce do notation with Probably also need to move the "guards" section, since that builds on "do notation", but I don't expect this to be too disruptive to the chapter exercises. |
Pedantic nitpick: I think you can have a zippy |
My 2 Cent, I do wonder how many before me, dropped Purescript at chapter 4 (I honestly and I am not exaggerating, decided to take a break and come back later when I have a clearer mind, but like an itch you could not scratch I came back a day later, and then decided to skip this section, it was hopeless to try to understand, even after few tried to explain it on slack, without full knowledge of Monads, this remains Magic, you can use it, but you have no clue how it works or why it works) Yes please do thoroughly explain Monads, and why we need them, and why we cant do without them in Purescript Why explain Monad comprehension, before you explain Monads Please also note, that one cant just google for the missing information, I tried googling to make sense of chapter 4, it doesnt work |
I often wonder the same and suspect we don't hear from those folks, so I appreciate your persistence and willingness to take the time to provide feedback. |
You don't need to know the monad laws to know why guard stops the computation, you just need to know that
I think that if you introduce do notation with just one example, there's always going to be a risk of people thinking it's more specific than it actually is. However, I think trying to explain the full generality of do notation upfront is much more risky than that; it's really quite a big hill to get over, as if the reader hasn't already come across a pure FP language, they probably won't have (properly) encountered an abstraction that's as powerful as Monad is. So I agree that starting with just one example at first is best, and I think Maybe is a good candidate because it is indeed simpler, but I disagree that the reason for doing so is that the Array example gives readers the wrong impression that it always means "choose"; I think the reason should just be that Array is too complex an example to start with.
This is correct: you can only implement a zippy Applicative for lazy lists, because the implementation of |
I was looking for a way to give feedback on the "Array comprehensions/Do notation/Guards" trilogy in chapter 4, and this issue seems to be the best place for that. This feedback might give you some insight on why someone could be discouraged from learning PureScript altogether after reaching this chapter. Note that I started the book already familiar with some basic concepts of functional programming (recursion, currying, immutability...), while still unaware of or unable to wrap my head around deeper concepts, especially monads. I understand that monads are used for side-effects but I still haven't managed to form an intuition of how they fit in the functional paradigm. Without further ado:
As a general note, it seems like this chapter comes too early in the book. Algebraic types and pattern matching are introduced one chapter later, and they are to me both easier to understand and more fundamental to functional programming than do notation, or even recursion for that matter. Teaching recursion without being able to pattern match linked lists or trees in your examples feels a bit masochistic IMO, but maybe that argument has been discussed in another issue, in which case feel free to redirect me. In any case, I would argue that rather than deferring the Array do notation section, deferring the whole chapter altogether should be considered. |
I'm not against including the The previous discussion is long, and I have skimmed it. I don't think I am repeating anything above, but I might have missed something.
|
Some opinions and proposals for the Do Notation section section (feel free to disagree):
bind
ormonad
here.Some other confusing bits of this section are discussed in #63
And what's going on with this comparison between
map
andmap
? Aren't those the same for arrays? Was this different in the past?The text was updated successfully, but these errors were encountered: