Replies: 1 comment 1 reply
-
The ordinary
should be If you don't use the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, I love the course. I have been dabbling in Haskell over the last few months when I stumbled upon your course, and really appreciate it as a resource.
The Task is as follows:
I went ahead and implemented it (wont post solution here) as prescribed, and upon running the tests, only the following test case failed:
it "Just False - Nothing" $ andM (Just False) Nothing
shouldBeJust False
Intuitively, this makes sense, because of boolean short circuiting. However, if you run the following in ghci (note that this would be equivalent to a cheating implementation of andM = liftM2 (&&) ):
liftM2 (&&) (Just False) Nothing
You get Nothing, which would also fail the unit test, and is at least consistent with what my implementation outputs.
I did update my implementation to short-circuit and got the test to pass, but given the results of using liftM2, is short-circuiting necessary for correctness when doing boolean AND in a monadic context?
Thank in advance,
Sergio
Beta Was this translation helpful? Give feedback.
All reactions