Take, for example, the sequence of rolls [5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
In this, we would expect the 6 is the erroneous roll. By this, we mean that if game = roll 6 (roll 5 bowlingStart), no matter what you do to game you cannot get a score out of it.
The tests don't test that precisely - they currently cannot, since roll returns a Bowling, and there is no way to determine the above-described property of a Bowling without trying to roll it to completion.
So my question is: Would we like to be more precise about which roll is erroneous?
(I have argued the same in the Rust implementation)
The gist is that I like to fail fast and close to the source of the error, so that it is easy to understand what caused the error.
If we find this desirable, some proposals to do it:
- Add
isValid :: Bowling -> Bool. I find this a little unclean.
- Change
roll's type to roll :: Bowling -> Int -> Either ___ Bowling (the ___ can be any user-defined error they like; the tests only need to test isLeft on it)
And a final question:
Should this be brought to x-common? Note that there will be a slight challenge in how to represent the "this specific roll should fail" in JSON (my current leading thought is keeping the rolls array but then adding a roll_should_fail entry)
Take, for example, the sequence of rolls
[5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]In this, we would expect the 6 is the erroneous roll. By this, we mean that if
game = roll 6 (roll 5 bowlingStart), no matter what you do togameyou cannot get a score out of it.The tests don't test that precisely - they currently cannot, since
rollreturns aBowling, and there is no way to determine the above-described property of aBowlingwithout trying torollit to completion.So my question is: Would we like to be more precise about which roll is erroneous?
(I have argued the same in the Rust implementation)
The gist is that I like to fail fast and close to the source of the error, so that it is easy to understand what caused the error.
If we find this desirable, some proposals to do it:
isValid :: Bowling -> Bool. I find this a little unclean.roll's type toroll :: Bowling -> Int -> Either ___ Bowling(the ___ can be any user-defined error they like; the tests only need to testisLefton it)And a final question:
Should this be brought to x-common? Note that there will be a slight challenge in how to represent the "this specific roll should fail" in JSON (my current leading thought is keeping the
rollsarray but then adding aroll_should_failentry)