Debian Codegraph @

src/System/Process.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Calling external processes
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --guardedness #-}
8
9 module System.Process where
10
11 open import Level using (Level)
12 open import Data.List.Base using (List)
13 open import Data.Product.Base using (_×_; proj₁)
14 open import Data.String.Base using (String)
15 open import Data.Unit.Polymorphic using (⊤)
16 open import Foreign.Haskell.Coerce
17 open import IO.Base
18
19 open import System.Exit
20 import System.Process.Primitive as Prim
21
22 private
23 variable
24 ℓ : Level
25
26 callCommand : String → IO {ℓ} ⊤
27 callCommand cmd = lift′ (Prim.callCommand cmd)
28
29 system : String → IO ExitCode
30 system cmd = lift (Prim.system cmd)
31
32 callProcess : String → List String → IO {ℓ} ⊤
33 callProcess exe args = lift′ (Prim.callProcess exe args)
34
35 readProcess
36 : String -- Filename of the executable
37 → List String -- any arguments
38 → String -- standard input
39 → IO String -- stdout
40 readProcess exe args stdin = lift (Prim.readProcess exe args stdin)
41
42 readProcessWithExitCode
43 : String -- Filename of the executable
44 → List String -- any arguments
45 → String -- standard input
46 → IO (ExitCode × String × String) -- exitcode, stdout, stderr
47 readProcessWithExitCode exe args stdin =
48 lift (coerce Prim.readProcessWithExitCode exe args stdin)
49
50 callProcessWithExitCode : String → List String → IO ExitCode
51 callProcessWithExitCode exe args = proj₁ <$> readProcessWithExitCode exe args ""