-
-
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
Concept Algebraic Data Types with exercise #1110
Conversation
This formulation of Valentine's Day requires the student to use general (i.e. not literal-specific) pattern matching, which has not yet been introduced. I expected Valentine's Day to be used for Pattern Matching. Either way, an extra exercise needs be found for the Concept not paired with Valentine's Day. |
@MatthijsBlom What do you think of Ticket Please for PM2? it seems better suited for a more in-depth look a PM as it makes use of de-structuring, record updates, and requires previous exposure to tuples, records and ADTs. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Well, ALLOWED-TO-NOT-COMPILE implies that the stub doesn't compile. But, this current stub does compile. Therefore, it's forbidden to add ALLOWED-TO-NOT-COMPILE. If the stub cannot be tested, you're supposed to use DONT-TEST-STUB instead. |
@petertseng thanks, that took care of it. |
https://github.com/exercism/haskell#stub-solution is the documentation for DONT-TEST-STUB. I find no documentation for STUB-ALLOWED-TO-NOT-COMPILE. I wouldn't really like to advertise those features. Every instance of those means more manual work that has to be done to make sure the stubs are good, and more manual work means the track is harder to maintain. |
I must admit it is quite embarrassing the problem, and its solution, can be found clearly spelled out in a file I updated just a couple days ago... 😊 |
|
||
rateActivity :: Activity -> Approval | ||
rateActivity activity = | ||
case activity of |
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.
This implementation uses case
, which I don't think is being taught in the prerequisites, correct? If so, we'll need to add another exercise to teach that or rewrite this to use the pattern matching functionality that was already introduced.
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.
case
is introduced in this concept (last paragraph of introduction.md)
All previous comments addressed. Just pending decision on introducing |
case rateActivity Chill of | ||
No -> True | ||
_ -> False |
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.
Surprising. It correctly rejects incorrect implementations, but has the disadvantage of not showing the correct vs incorrect result. I wish there were a way to do that.
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.
Great work!
@petertseng Feel free to merge as you feel fit. |
b16c6bb
to
70514a1
Compare
57f79ef
to
7b0f63d
Compare
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 are no tests for Walk
. Shouldn't there be some? I added them.
- Chill out: no. | ||
- Watch a movie: yes if it is a romantic movie; otherwise, no. | ||
- Go to a restaurant: yes if the cuisine is Korean, maybe if it is Turkish. | ||
- Take a walk: yes if the walk is less than three kilometers; maybe if it is between three and five kilometers (inclusive); otherwise, no. |
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.
I added the (inclusive)
here. Even though I think it was fairly obvious it's inclusive (if it wasn't, the only value that gets a Maybe would have been 4, the answer for 3 would have been undefined), I wanted to be explicit anyway.
it "walk 2 kilometers rated yes" $ | ||
case rateActivity (Walk 2) of | ||
Yes -> True | ||
_ -> False | ||
it "walk 3 kilometers rated maybe" $ | ||
case rateActivity (Walk 3) of | ||
Maybe -> True | ||
_ -> False | ||
it "walk 5 kilometers rated maybe" $ | ||
case rateActivity (Walk 5) of | ||
Maybe -> True | ||
_ -> False | ||
it "walk 6 kilometers rated no" $ | ||
case rateActivity (Walk 6) of | ||
No -> True | ||
_ -> False |
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 were not any tests for walk, before I added them.
First stab at introducing ADTs and the associated exercise (Valentines Day) to get the conversation and edits started.