File tree Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,12 @@ New modules
213
213
System.Environment.Primitive
214
214
```
215
215
216
+ * Added bindings for Haskell's ` System.Exit ` :
217
+ ```
218
+ System.Exit
219
+ System.Exit.Primitive
220
+ ```
221
+
216
222
* New morphisms
217
223
```
218
224
Algebra.Morphism.LatticeMonomorphism
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ unsafeModules = map modToFile
43
43
, " Relation.Binary.PropositionalEquality.TrustMe"
44
44
, " System.Environment"
45
45
, " System.Environment.Primitive"
46
+ , " System.Exit"
47
+ , " System.Exit.Primitive"
46
48
, " Text.Pretty.Core"
47
49
, " Text.Pretty"
48
50
]
Original file line number Diff line number Diff line change
1
+ ------------------------------------------------------------------------
2
+ -- The Agda standard library
3
+ --
4
+ -- Exiting the program.
5
+ ------------------------------------------------------------------------
6
+
7
+ {-# OPTIONS --without-K #-}
8
+
9
+ module System.Exit where
10
+
11
+ open import Level using (Level)
12
+ open import Data.Nat.Base using (ℕ)
13
+ open import Data.String.Base using (String)
14
+ open import Function.Base using (_$_)
15
+ open import IO using (IO; lift; _>>_; putStrLn)
16
+
17
+ ------------------------------------------------------------------------
18
+ -- Re-exporting the ExitCode data structure
19
+
20
+ open import System.Exit.Primitive as Prim
21
+ using ( ExitCode
22
+ ; ExitSuccess
23
+ ; ExitFailure
24
+ )
25
+ public
26
+
27
+ ------------------------------------------------------------------------
28
+ -- Various exiting function
29
+
30
+ private
31
+ variable
32
+ a : Level
33
+ A : Set a
34
+
35
+ exitWith : ExitCode → IO A
36
+ exitWith c = lift (Prim.exitWith c)
37
+
38
+ exitFailure : IO A
39
+ exitFailure = exitWith (ExitFailure 1 )
40
+
41
+ exitSuccess : IO A
42
+ exitSuccess = exitWith ExitSuccess
43
+
44
+ die : String → IO A
45
+ die str = do
46
+ putStrLn str
47
+ exitFailure
Original file line number Diff line number Diff line change
1
+ ------------------------------------------------------------------------
2
+ -- The Agda standard library
3
+ --
4
+ -- Primitive System.Exit simple bindings to Haskell functions
5
+ ------------------------------------------------------------------------
6
+
7
+ {-# OPTIONS --without-K #-}
8
+
9
+ module System.Exit.Primitive where
10
+
11
+ open import Data.Nat.Base using (ℕ)
12
+ open import IO.Primitive using (IO)
13
+
14
+ data ExitCode : Set where
15
+ ExitSuccess : ExitCode
16
+ ExitFailure : ℕ → ExitCode
17
+
18
+ {-# FOREIGN GHC data AgdaExitCode = AgdaExitSuccess | AgdaExitFailure Integer #-}
19
+ {-# COMPILE GHC ExitCode = data AgdaExitCode (AgdaExitSuccess | AgdaExitFailure) #-}
20
+
21
+ {-# FOREIGN GHC import qualified System.Exit as SE #-}
22
+
23
+ {-# FOREIGN GHC
24
+ toExitCode :: AgdaExitCode -> SE.ExitCode
25
+ toExitCode AgdaExitSuccess = SE.ExitSuccess
26
+ toExitCode (AgdaExitFailure n) = SE.ExitFailure (fromIntegral n)
27
+ #-}
28
+
29
+ postulate
30
+ exitWith : ∀ {a} {A : Set a} → ExitCode → IO A
31
+
32
+ {-# COMPILE GHC exitWith = \ _ _ -> SE.exitWith . toExitCode #-}
You can’t perform that action at this time.
0 commit comments