summaryrefslogtreecommitdiff
path: root/lib/Postdelay/TimeSpec
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Postdelay/TimeSpec')
-rw-r--r--lib/Postdelay/TimeSpec/Utils.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Postdelay/TimeSpec/Utils.hs b/lib/Postdelay/TimeSpec/Utils.hs
index a8c7d4a..fd9c1be 100644
--- a/lib/Postdelay/TimeSpec/Utils.hs
+++ b/lib/Postdelay/TimeSpec/Utils.hs
@@ -22,6 +22,8 @@ import Data.Time.Lens
22import Data.Time.Zones 22import Data.Time.Zones
23 23
24import Data.Bool 24import Data.Bool
25import Data.Maybe
26import Data.List
25import Data.Foldable 27import Data.Foldable
26import Data.Functor 28import Data.Functor
27import Data.Function 29import Data.Function
@@ -53,7 +55,7 @@ sign = label "sign" $ choice [ char '+' $> id
53 , char '-' $> negateV 55 , char '-' $> negateV
54 ] 56 ]
55 57
56boundedNatural :: forall s n m. (Show n, Real n, StringParser s m) 58boundedNatural :: forall s n m. (Show n, Ord n, Num n, StringParser s m)
57 => Bool -- ^ Require number to be padded with zeroes? 59 => Bool -- ^ Require number to be padded with zeroes?
58 -> Interval n -> m n 60 -> Interval n -> m n
59boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do 61boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do
@@ -84,7 +86,7 @@ boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do
84 | otherwise = int 86 | otherwise = int
85 87
86 digits :: n -> Int 88 digits :: n -> Int
87 digits = succ . floor . (logBase 10 :: Double -> Double) . realToFrac . abs 89 digits n = succ . fromJust $ findIndex (\(min, max) -> min <= n && n < max) [ (10^i, 10^(succ i)) | i <- ([0..] :: [Int]) ]
88 90
89boundedRational :: forall s m n. (Show n, RealFrac n, StringParser s m) 91boundedRational :: forall s m n. (Show n, RealFrac n, StringParser s m)
90 => Bool -- ^ Require number to be padded with zeroes 92 => Bool -- ^ Require number to be padded with zeroes