WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e7077ad

Browse files
committed
[ re agda#2896 ] Restrict clock types
1 parent 0c42bd9 commit e7077ad

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/System/Clock/Primitive.agda

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,38 @@ open import Foreign.Haskell using (Pair)
1414

1515
data Clock : Set where
1616
monotonic realTime processCPUTime : Clock
17-
threadCPUTime monotonicRaw bootTime : Clock
18-
monotonicCoarse realTimeCoarse : Clock
17+
threadCPUTime monotonicRaw : Clock
1918

20-
{-# COMPILE GHC Clock = data Clock (Monotonic | Realtime | ProcessCPUTime
21-
| ThreadCPUTime | MonotonicRaw | Boottime
22-
| MonotonicCoarse | RealtimeCoarse )
19+
{-# FOREIGN GHC import System.Clock #-}
20+
21+
{-# FOREIGN GHC
22+
data AgdaClock
23+
= AgdaMonotonic
24+
| AgdaRealTime
25+
| AgdaProcessCPUTime
26+
| AgdaThreadCPUTime
27+
| AgdaMonotonicRaw
28+
29+
fromAgdaClock :: AgdaClock -> Clock
30+
fromAgdaClock ac = case ac of
31+
AgdaMonotonic -> Monotonic
32+
AgdaRealTime -> RealTime
33+
AgdaProcessCPUTime -> ProcessCPUTime
34+
AgdaThreadCPUTime -> ThreadCPUTime
35+
AgdaMonotonicRaw -> MonotonicRaw
36+
#-}
37+
38+
{-# COMPILE GHC Clock =
39+
data AgdaClock
40+
( AgdaMonotonic
41+
| AgdaRealtime
42+
| AgdaProcessCPUTime
43+
| AgdaThreadCPUTime
44+
| AgdaMonotonicRaw
45+
)
2346
#-}
2447

2548
postulate getTime : Clock IO (Pair Nat Nat)
2649

27-
{-# FOREIGN GHC import System.Clock #-}
2850
{-# FOREIGN GHC import Data.Function #-}
29-
{-# COMPILE GHC getTime = fmap (\ (TimeSpec a b) -> ((,) `on` fromIntegral) a b) . getTime #-}
51+
{-# COMPILE GHC getTime = fmap (\ (TimeSpec a b) -> ((,) `on` fromIntegral) a b) . getTime . fromAgdaClock #-}

0 commit comments

Comments
 (0)