OK, Add Option concept exercise and doc by blackk-foxx · Pull Request #1332 · exercism/fsharp · GitHub is now ready for review. It contains a concept exercise in addition to the concept docs.
Thanks @ErikSchierboom for the review/approval. It’s nice to see the new concept and exercise live on the site! After reviewing it, I think maybe the hints could be improved a bit:
- Task 1: a hint about
Option.default - Task 2: something about returning
Some playerorNone - Task 3: use a
matchexpression covering theSomeandNonecases, and remove the mention of themaxfunction since it does not pertain to theOptionsconcept
Other thoughts?
Sounds like a good idea! A PR is appreciated :)
One more thing I noticed in the UI: The human-readable title of the exercise appears as “role-playing-game,” but it should be “Role Playing Game.”
Proposed fix in Correct role-playing-game exercise name by blackk-foxx · Pull Request #1334 · exercism/fsharp · GitHub.
Opened Prefer postfix type annotations for Options by blackk-foxx · Pull Request #1335 · exercism/fsharp · GitHub to address Erik’s comment in #1333.
I was thinking that a Result concept exercise might be a good logical next step. Any thoughts on the content of such an exercise? I propose a parsing exercise – maybe a subset of Forth? Other ideas?
I like the idea of parsing. We already have a Forth exercise, so maybe we could try something else? But something with parsing an integer seems like a good idea as that is a common use case. And then build on that?
How about an interpreter for a simple robot control language consisting of three commands: advance, turn, and speak, where advance requires a distance argument (an integer followed by a units specifier – maybe just cm or m), turn requires an angle argument (an integer between -180 and 180), and speak requires a quoted string? The different error types could be something like UnknownCommand, MissingArgument, ArgumentOutOfRange and InvalidArgument.
I’m sorry to say but that sounds an awful lot like our robot simulator practice exercise. Maybe we could theme it as being an ancient language or a treasure map?
Maybe we take part or all of a hand-written family recipe and digitize it? Converting the ingredient list would let students parse integers and fractions. We can also introduce duplicated ingredients or misspelled ingredients depending on how much we want to focus on validation.
I like this idea!
I like it too!
Draft PR ready for a preliminary review: Result concept exercise (initial draft) by blackk-foxx · Pull Request #1364 · exercism/fsharp · GitHub
I found it difficult to craft a recipe-based exercise that was both focused and engaging. So I decided to close the aforementioned PR and bring the discussion back to the forum.
I have another idea for a Result concept exercise: a password rules checker. I am envisioning two functions:
/// Analyze a user's proposed password for compliance with a set
/// of rules.
let checkPasswordCompliance (password: string) : Result<string, PasswordRule>
/// Return a human-readable message indicating whether the password
/// is acceptable or not, and if not, which rule(s) it violates
let formatPasswordComplianceResult (result: Result<string, PasswordRule>) : string
Thoughts?
In practice, I would expect a function like checkPasswordCompliance to indicate when multiple rules are violated, not just one. To me, this begs for the PasswordRule enum type to be a Flag enum. Would it be too distracting to introduce the Flag enum concept together with the Result concept?
@ErikSchierboom, I don’t want you to think that I have been ignoring your treasure map and encrypted message ideas. I have been considering them. But I fear that the treasure map idea would run into similar difficulties as with the recipe idea. And I worry that an encrypted message exercise would duplicate the existing cipher-based practice exercises. If you don’t agree with those concerns, would you mind elaborating a bit more on those ideas?
They’re both valid concerns. I’m not sure I have a good idea :(
Any feedback on the password rule checker idea in my previous reply?
I think so. I would just make it a regular discriminated union such that only the first violation is returned.