poset: Add fixity declarations.
[altfloat.git] / Data / Floating / Instances.hs
blob59906c6ee21fc2875ef553573541b4eac1987f24
1 {-
2 - Copyright (C) 2009 Nick Bowler.
4 - License BSD2: 2-clause BSD license. See LICENSE for full terms.
5 - This is free software: you are free to change and redistribute it.
6 - There is NO WARRANTY, to the extent permitted by law.
7 -}
9 module Data.Floating.Instances where
11 import qualified Prelude
12 import Prelude hiding (round, floor, ceiling, truncate)
13 import Data.Floating.Types.Core
14 import Data.Ratio
16 instance Integral a => Roundable (Ratio a) where
17 toIntegral = Just . fst . properFraction
18 round x
19 | abs frac >= 1%2 = int%1 + signum frac
20 | otherwise = int%1
21 where (int, frac) = properFraction x