Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resistor-color-duo: Change to
value :: (Color, Color) -> Int
TL;DR: - I don't think we should be teaching people to write functions like this. - The less controversial action would be to reject this PR in favor of one where either value :: [Color] -> Maybe Int value :: [Color] -> Either String Int value :: [Color] -> Either ColorError Int Quick chronological recap of PRs that provide necessary context: - 2019-03-08: exercise created in exercism/problem-specifications#1466 - 2019-03-12: exercise ported to Haskell track in #808 - 2019-08-17: third-band test case and formulation "brown-green-violet should return 15 too, ignoring the third color." + one other similar formulation added to README.md in exercism/problem-specifications#1569. - 2019-10-01: third-band test case added to Haskell track in #849. When this exercise was ported to Haskell track, it was decided to not address error handling in this exercise via `Maybe Int` or similar, which otherwise would be necessary since `value` is not defined for `[Color]` of length 0 or 1. The alternative proposed here, to limit the input to exactly two bands, does not appear to be mentioned. In the meantime, the third-band test case (and formulations) have made `value` explicitly more ambiguous: Unlike 0 or 1 bands, which is undefined, the third band should be ignored, and >3 bands are undefined. Presumably they should be ignored as well, but following this logic, should 0 or 1 bands also be ignored? Why, exactly, are we creating a function so vulnerable to wrong input and not let it handle validation gracefully? README.md explicitly asks to disregard a third color in two places. Given this proposal, those messages become meaningless; you can only specify two bands. I can think of these ways to address the deficiency that this change causes: - Remove the lines from README.md, breaking a track invariant and CI check. - Apply a track-specific hint saying how this exercise is adapted to Haskell track in this way. - Don't change the description; confuse students. ("What third band?!") - Reject this PR in favor of another solution, as highlighted above. - Something else entirely. The Read instance is removed from the stub as it isn't necessary. This changes the version from 2.1.0.2 to 0.1.0.3, because the three-band test case is removed, which makes the test suite no longer reflect canonical tests.
- Loading branch information