[commit: packages/time] format-widths, master, posix-perf, tasty: workaround for test unix dependency (91e345b)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:19:11 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,master,posix-perf,tasty
Link       : http://git.haskell.org/packages/time.git/commitdiff/91e345b1014851a23b7b7ea1000337a9bab1fde9

>---------------------------------------------------------------

commit 91e345b1014851a23b7b7ea1000337a9bab1fde9
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Tue Dec 6 00:34:48 2016 -0800

    workaround for test unix dependency


>---------------------------------------------------------------

91e345b1014851a23b7b7ea1000337a9bab1fde9
 lib/Data/Time/Clock/POSIX.hs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/Data/Time/Clock/POSIX.hs b/lib/Data/Time/Clock/POSIX.hs
index 91a096a..2bd1965 100644
--- a/lib/Data/Time/Clock/POSIX.hs
+++ b/lib/Data/Time/Clock/POSIX.hs
@@ -36,6 +36,30 @@ data POSIXTime = POSIXTime
     , ptNanoSeconds :: {-# UNPACK #-} !Word32
     } deriving (Eq,Ord)
 
+#if 0
+-- workaround for time test stanza dependency on unix, which needs fromRational and toRational
+
+instance Show POSIXTime where
+    show = error "undefined POSIXTime function"
+
+instance Num POSIXTime where
+    (+) = error "undefined POSIXTime function"
+    (-) = error "undefined POSIXTime function"
+    (*) = error "undefined POSIXTime function"
+    negate = error "undefined POSIXTime function"
+    abs = error "undefined POSIXTime function"
+    signum = error "undefined POSIXTime function"
+    fromInteger = error "undefined POSIXTime function"
+
+instance Real POSIXTime where
+    toRational (POSIXTime xs xn) = toRational xs + (toRational xn) / 1000000000
+
+instance Fractional POSIXTime where
+    fromRational r = makePOSIXTime 0 $ floor $ r * 1000000000
+    recip = error "undefined POSIXTime function"
+    (/) = error "undefined POSIXTime function"
+#endif
+
 makePOSIXTime :: Int64 -> Word32 -> POSIXTime
 makePOSIXTime xs xn
     | xn < 0 || xn >= 1000000000 = POSIXTime (xs + fromIntegral q)  r



More information about the ghc-commits mailing list