-
Notifications
You must be signed in to change notification settings - Fork 196
Ch6 - account for alternative solutions for Action Multiply Int #338
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
Ch6 - account for alternative solutions for Action Multiply Int #338
Conversation
exercises/chapter6/test/Main.purs
Outdated
Assert.equal 15 | ||
Assert.assert "not one of [ 15, 125 ]" | ||
$ flip elem [ 15, 125 ] | ||
$ act m1 a |
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.
Downside of this change is that we lose the helpful "expected x, got y" test failure messages.
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.
A reader wouldn't know what to expect. But fixed for consistency anyway.
In response to #334 (comment), The additional exercise could be
|
7b9ed55
to
34c89dd
Compare
Looks good. Would you like to also add the bonus exercise to the text? Thinking we should clarify to:
(just added the word "unique"). And what about removing the "Does this instance satisfy the laws listed above?" lines from the exercise texts? Those lines were written before we had the TDD framework. It might also be helpful to be a bit more specific in what we're asking for in the first exercise. Perhaps add this clarification so beginners have something more concrete to start with (similar to the phrasing of the next
I think it's also reasonable to accept the |
```purescript instance actionMultiplyInt :: Action Multiply Int where act (Multiply m) i = i / m ``` and ```purescript import Data.Int (pow) instance actionMultiplyInt :: Action Multiply Int where act (Multiply m) i = pow i m ```
34c89dd
to
fc2e78f
Compare
I don't think we need to stress the unique nature of implementations. We already stated multiple implementations are not allowed.
Changed this line to an instructive "Verify that this instance satisfies the laws listed above.". This is the criterion of this exercise.
Omitting such a hint allows readers to explore implementations that don't satisfy the laws. Given the abstractness of typeclasses, a little math won't hurt.
I agree with concerns raised in #198, a reader may accidentally come up with this solution by just satisfying the types. There is a comment section that addresses this solution. |
I also altered the text, adding some elaboration on the laws. |
1076ba7
to
dd9128f
Compare
- Elaborate on `Action` rules. - Make law satisfaction an istruction. - Add additional exercise to explore alternatives.
dd9128f
to
695b288
Compare
As discussed in #334 and raised in #198. This PR follows this proposal.
This would void #335.