{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_HADDOCK hide #-}
module Internal.Rounding
( RoundingDirection (..)
, round
) where
import Prelude hiding ( round )
data RoundingDirection
= RoundUp
| RoundDown
deriving (RoundingDirection -> RoundingDirection -> Bool
(RoundingDirection -> RoundingDirection -> Bool)
-> (RoundingDirection -> RoundingDirection -> Bool)
-> Eq RoundingDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RoundingDirection -> RoundingDirection -> Bool
== :: RoundingDirection -> RoundingDirection -> Bool
$c/= :: RoundingDirection -> RoundingDirection -> Bool
/= :: RoundingDirection -> RoundingDirection -> Bool
Eq, Int -> RoundingDirection -> ShowS
[RoundingDirection] -> ShowS
RoundingDirection -> String
(Int -> RoundingDirection -> ShowS)
-> (RoundingDirection -> String)
-> ([RoundingDirection] -> ShowS)
-> Show RoundingDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RoundingDirection -> ShowS
showsPrec :: Int -> RoundingDirection -> ShowS
$cshow :: RoundingDirection -> String
show :: RoundingDirection -> String
$cshowList :: [RoundingDirection] -> ShowS
showList :: [RoundingDirection] -> ShowS
Show)
round :: (RealFrac a, Integral b) => RoundingDirection -> a -> b
round :: forall a b. (RealFrac a, Integral b) => RoundingDirection -> a -> b
round = \case
RoundingDirection
RoundUp -> a -> b
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
ceiling
RoundingDirection
RoundDown -> a -> b
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor