2009/2/19 Krasimir Angelov <kr.ange...@gmail.com>: > I was surprised to see this case expression: > >> case GHC.Prim.-# 9223372036854775807 ipv_s1bD >> of wild2_a1xi [ALWAYS Just L] { > > What is the purpose to compare the value with maxBound before the > division? The case expression doesn't disappear even if I use quot > instead of div.
Have a look at this snippet of the base library, file GHC/Real.lhs: a `quot` b | b == 0 = divZeroError | a == minBound && b == (-1) = overflowError | otherwise = a `quotInt` b quotInt is defined in GHC/Base.lhs as: (I# x) `quotInt` (I# y) = I# (x `quotInt#` y) And quotInt# is a primitive, which I guess is implemented via machine division (though I don't work on the codegen stuff at all) - so your offending case must come from those tests in GHC/Real.lhs. In general, if you want to answer questions like this you can usually find the answer by looking at the base code: it's all in Haskell, so very readable! You can get it online at http://darcs.haskell.org/libraries/base/GHC/ Cheers, Max _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users