{-# LANGUAGE ScopedTypeVariables #-}
module Data.Fixed.Extras where
import Data.Fixed
import Prelude
toFixed :: forall res a. (Num a, HasResolution res) => (a -> Integer) -> a -> Fixed res
toFixed :: forall res a.
(Num a, HasResolution res) =>
(a -> Integer) -> a -> Fixed res
toFixed a -> Integer
rounding a
a =
let r :: Integer
r = forall k (a :: k) (p :: k -> *). HasResolution a => p a -> Integer
resolution Fixed res
out
out :: Fixed res
out = forall k (a :: k). Integer -> Fixed a
MkFixed forall a b. (a -> b) -> a -> b
$ a -> Integer
rounding (a
a forall a. Num a => a -> a -> a
* forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
r)
in Fixed res
out