-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Examples in chapter 10 (in Laws) #161
Comments
Thank you! For # 1, I think |
I still don't understand how it will work.
var assemble = liftA3(_.compose(_.concat, _.concat)); Btw, it was pretty tricky to grasp that |
Yeah, that's a really bad example... I'll try to come up with something a little more digestible. |
I think I finally get it. I didn't know that some Maybe implementations include .concat() and when called call .concat() on the wrapped value. The example should work with a Maybe like that. Although, if I remember correctly, it was stated somewhere in previous chapters that the implementation from Folktale is used in the book. And it doesn't seem to include .concat() https://github.com/folktale/data.maybe/blob/master/lib/maybe.js And yeah, the example in general seems a little too hard to grasp :) |
The current definition for var tOfM = compose(Task.of, Maybe.of);
liftA2(_.concat, tOfM('Rainy Days and Mondays'), tOfM(' always get me down'));
// Task(Maybe(Rainy Days and Mondays always get me down)) But using the book definition of const tOfM = compose(Task.of, Maybe.of);
const concatMap = curry((m1, m2) => liftA2(concat, m1, m2));
liftA2(concatMap, tOfM('Rainy Days and Mondays'), tOfM(' always get me down'));
// Task(Maybe(Rainy Days and Mondays always get me down)) Am I missing something ? |
Thanks @salper, yes I really need to get on fixing this. You're definition is a good fix, but I should update to a simpler example anyways. |
Arf, I could actually have made it point free: const concatMap = liftA2(concat); What do you mean by simpler ? |
Instead of
Well...on second thought. Maybe I'll just sneak in the extra |
Hey, @DrBoolean! I just read chapter 10, it's great as always! Noticed couple of minor issues in examples.
# 1
https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch10.md#laws
I think
assemble
should be defined as:# 2
https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch10.md#interchange
Here
var x = Task.of('Sparklehorse');
should bevar x = 'Sparklehorse';
.The text was updated successfully, but these errors were encountered: