| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Primitive System.Clock simple bindings to Haskell functions |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible #-} |
| 8 |
|
| 9 |
module System.Clock.Primitive where |
| 10 |
|
| 11 |
open import Agda.Builtin.Nat using (Nat) |
| 12 |
open import IO.Primitive.Core using (IO) |
| 13 |
open import Foreign.Haskell using (Pair) |
| 14 |
|
| 15 |
data Clock : Set where |
| 16 |
monotonic realTime processCPUTime : Clock |
| 17 |
threadCPUTime monotonicRaw bootTime : Clock |
| 18 |
monotonicCoarse realTimeCoarse : Clock |
| 19 |
|
| 20 |
{-# COMPILE GHC Clock = data Clock (Monotonic | Realtime | ProcessCPUTime |
| 21 |
| ThreadCPUTime | MonotonicRaw | Boottime |
| 22 |
| MonotonicCoarse | RealtimeCoarse ) |
| 23 |
#-} |
| 24 |
|
| 25 |
postulate getTime : Clock → IO (Pair Nat Nat) |
| 26 |
|
| 27 |
{-# FOREIGN GHC import System.Clock #-} |
| 28 |
{-# FOREIGN GHC import Data.Function #-} |
| 29 |
{-# COMPILE GHC getTime = fmap (\ (TimeSpec a b) -> ((,) `on` fromIntegral) a b) . getTime #-} |