New concept exercises for F#

For reference - that’s also mentioned here: Concept exercise title not capitalized - #2 by BNAndras

Opened Prefer postfix type annotations for Options by blackk-foxx · Pull Request #1335 · exercism/fsharp · GitHub to address Erik’s comment in #1333.

1 Like

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?

1 Like

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.

3 Likes

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

2 Likes

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.

I had totally missed that. I like the idea, except for the flags enum part.

1 Like

Add PasswordChecker exercise for Result concept by blackk-foxx · Pull Request #1368 · exercism/fsharp · GitHub is ready for a full review.

1 Like

Created Add missing link; improve formatting by blackk-foxx · Pull Request #1370 · exercism/fsharp · GitHub to address some formatting issues in the instructions document.

1 Like

While thinking about a proposed Improved Password Checker concept exercise to teach the Flags attribute (see the relevant conversation in PR #1368), I noticed the Attack of the Trolls concept exercise in the C# track that teaches Flags enums. Would it make sense to port that one over to F# instead of, or maybe in addition to, the Improved Password Checker?

1 Like

That is perfectly fine!