Skip to content
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

Add run-length-encoding exercise #146

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

ageron
Copy link
Contributor

@ageron ageron commented Oct 10, 2024

Since the instructions specify that the input strings will always be simple ASCII, the BadUtf8 error can never really happen, so the annotation for encode could just be Str -> Str, but it's simpler for the user if the annotation is Str -> Result Str _, this way they can just call Str.fromUtf8 without having to worry about it.
Moreover, a very long string of digits could break decode, so it's also simpler to use annotation Str -> Result Str _.

Copy link
Contributor

@isaacvando isaacvando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fun one! I agree about the types, that seems like the best approach here.

Replace `|> \state -> appendCountAndLetter state` with `|> appendCountAndLetter` as suggested by Isaac.

Co-authored-by: Isaac Van Doren <69181572+isaacvando@users.noreply.github.com>
@ageron ageron merged commit c14d567 into exercism:main Oct 11, 2024
2 checks passed
@ageron ageron deleted the add-run-length-encoding branch October 11, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants