haskell-problem-sets
haskell-problem-sets copied to clipboard
Arithmetic
Have some problems that outline the differences between the different number type classes and how to deal with conversions between the two
I think the property tests for division and modulus need work to cover examples where the divisor is 0
.
Or, alternatively, we restrict the test input:
describe "Problem 4" $
it "should perform integer division" $
property $ \(x :: Int, (Positive y)) ->
P.division x y == (x `div` y)
That's a good point. Should we make an explicit note to not worry about the case when it's zero (they'd cover that with maybe later) and only test non zero divisors?
@JD95 I think that's fair. Most languages introduce it early but gloss over it unfairly I think.
The only reason to keep it in there is if we want to introduce some kind of option-type like Maybe
or Either
early on.
Then again there's a good reason we could just introduce it later in a different problem set.