-
Notifications
You must be signed in to change notification settings - Fork 0
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
Chapter4 answers #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Fantastic work!
Thank you so much for taking this course! I hope you had fun 🕺 🎤
We would really appreciate your feedback on the course!
You can also ask any questions @vrom911 or me and we can discuss any topics you would like to dig into as well 🙂 Don't be a stranger!
If you would like to continue your journey to Haskell, check out our Haskell Knowledge Map for the list of topics to explore 🗺️
@@ -267,7 +276,8 @@ instance Functor Maybe where | |||
fmap _ x = x | |||
@ | |||
-} | |||
|
|||
-- The type of x is a, and that implementation does not change the | |||
-- type of a to b, so the return type is wrong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely correct 💯
|
||
(<*>) :: Secret e (a -> b) -> Secret e a -> Secret e b | ||
(<*>) = error "(<*>) Secret: Not implemented!" | ||
Trap e <*> _ = Trap e | ||
Reward f <*> x = f <$> x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on reusing Functor
instance for Secret
! 🗺️
-- weird expected behavior, I personally assumed it would be the same as | ||
-- liftM2 (&&), but that was not the case | ||
andM :: (Monad m) => m Bool -> m Bool -> m Bool | ||
andM = error "andM: Not implemented!" | ||
andM b1 b2 = b1 >>= (\b -> if not b then pure b else (&&) b <$> b2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ordinary &&
if lazy on the second argument. Meaning that if it meets False
as the first argument, there is no need to calculate another arg. In andM
we would like to keep the same behaviour, so the
Just False `andM` _
should be Just False
🙂
@@ -673,7 +712,24 @@ Specifically, | |||
❃ Implement the function to convert Tree to list | |||
-} | |||
|
|||
-- this felt a little easy for a final boss xD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already an issue for that 😅
Thank you very much for all the help and the course. |
Solutions for Chapter 4
The final chapter! And the one with content I always struggled, but was very good to understand with your explanations!
cc @vrom911 @chshersh