-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
pangram 1.4.1.10: Add test case: determine pangram lazily #795
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fail if the input stream was touched beyond the first occurrence of each letter. Many standard solutions achieve this property without much effort, and some don't. This test case notifies the student that a more optimal solution is within reach.
While `success-standard` passes this test, and a `String`-based `fail-too-eager` example fails as expected, `success-text` cannot easily succeed, even if is changed into using `Data.Text.Lazy`: One can write a `Data.Text.Lazy as LT`-specific test: describe "isPangram" $ do it "is lazy" $ isPangram (LT.fromChunks ["a...z", undefined]) `shouldBe` True But when the input comes via `fromString :: IsString s => String -> s`, the implementation has little control of the chunking. A failed attempt to circumvent this, newtype ChunkyLazyText = ChunkyLazyText LT.Text instance IsString ChunkyLazyText where fromString = ChunkyLazyText . LT.fromChunks . map (T.pack . return) still causes the `T.pack` invocation on `[undefined]`. And as @bobdalgleish pointed out in [this StackOverflow question][SO], I'd actually end up testing `fromString`. Since "laziness" doesn't mean the same thing for `String` as it does for `Data.Text.Lazy` because chunking works differently, the reliable alternative is to write tests for each implementation. Or, in this case, let string-type specific tests remain commented out. [SO]: https://stackoverflow.com/questions/53784627/testing-laziness-of-isstring-s-s-bool-function
petertseng
approved these changes
Dec 15, 2018
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.
Interesting observations about Text-based implementations.
Yes. It's a property of very granulated strings. The main reason to discourage lazy Text appears to have to do with I/O. Also it's a rabbit hole. |
sshine
added a commit
that referenced
this pull request
Mar 8, 2019
As part of [The Track Anatomy Project][1], the Haskell core track is restructured in #798 using @F3PiX'es multi-stage framework referred to as "The Track Tool". Since The Track Tool is still under development, it isn't documented yet. But the execution of the first step can be viewed for other languages, e.g. exercism/javascript#590. --- Proposal: - Switch "Bob" and "Pangram". They're both about handling textual data. Pangram has fewer gotchas, is quicker done, has more variations among its alternative solutions, and doesn't lend itself as well to `Data.Text`. (See #795.) Bob often involves more refactoring, has more learning objectives and has the extra "You could do it with Data.Text, too!" part. This way people don't try to solve Pangram with Data.Text which is possible but not ideal without mono-traversable, and they get an exercise more under their belt before being thrown into a lot of refactoring. - Switch "Nucleotide Count" and "Sum of Multiples". Eventually I think we should delete "Sum of Multiples" and "Grains" (see #761). But since The Track Tool does not address removal yet, I want to make "Nucleotide Count" come immediately after "RNA Transcription", since they're both thematically related and Nucleotide Count uses Either while RNA Transcription uses Maybe for monadic error handling, so they practice the same thing in progressive difficulty. The proposed track reordering looks like: 1. hello-world 2. leap 3. space-age 4. **pangram** 5. **bob** 6. collatz-conjecture 7. rna-transcription 8. **nucleotide-count** 9. sum-of-multiples 10. grains [1]: https://exercism.io/blog/track-anatomy-project
ErikSchierboom
added a commit
to ErikSchierboom/haskell
that referenced
this pull request
Jan 27, 2021
* [Docs] Move implementing-a-concept-exercise.md to reference folder * [Docs] Move reference documents to docs folder * [Docs] Update to student-facing docs * [Docs] Add new issue template Co-Authored-By: Jeremy Walker <[email protected]> Co-Authored-By: Victor Goff <[email protected]> Co-authored-by: Sascha Mann <[email protected]>
ErikSchierboom
added a commit
to ErikSchierboom/haskell
that referenced
this pull request
Jan 28, 2021
* [Docs] Move implementing-a-concept-exercise.md to reference folder * [Docs] Move reference documents to docs folder * [Docs] Update to student-facing docs * [Docs] Add new issue template Co-Authored-By: Jeremy Walker <[email protected]> Co-Authored-By: Victor Goff <[email protected]> Co-authored-by: Sascha Mann <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fail if the input stream was touched beyond the first occurrence of each letter.
Many standard solutions achieve this property without much effort, and some don't.
This test case notifies the student that a more optimal solution is within reach.
It is commented out by default: