haskell-problem-sets icon indicating copy to clipboard operation
haskell-problem-sets copied to clipboard

Arithmetic

Open JD95 opened this issue 7 years ago • 3 comments

Have some problems that outline the differences between the different number type classes and how to deal with conversions between the two

JD95 avatar Nov 29 '17 01:11 JD95

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)

agentultra avatar Jan 07 '18 16:01 agentultra

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 avatar Jan 08 '18 01:01 JD95

@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.

agentultra avatar Jan 21 '18 15:01 agentultra