On Dec 20, 2011, at 8:40 PM, Jesse Schalken wrote:If you think a value might not reduce, return an error in an error monad.Okay, I'm completely convinced! Now all that we have to do is to solve the halting problem to make your solution work... :-)
intDiv x y = if y > x then 0 else 1 + (intDiv (x - y) y)
intDiv :: (Ord a, Num a) => a -> a -> Either String aintDiv _ 0 = Left "Division by 0!"intDiv x y = if y > x then Right 0 else intDiv (x - y) y >>= (Right . (1 +))
Cheers,Greg