forked from agda/agda-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.agda
More file actions
51 lines (40 loc) · 1.66 KB
/
Process.agda
File metadata and controls
51 lines (40 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-----------------------------------------------------------------------
-- The Agda standard library
--
-- Calling external processes
------------------------------------------------------------------------
{-# OPTIONS --cubical-compatible --guardedness #-}
module System.Process where
open import Level using (Level)
open import Data.List.Base using (List)
open import Data.Product.Base using (_×_; proj₁)
open import Data.String.Base using (String)
open import Data.Unit.Polymorphic using (⊤)
open import Foreign.Haskell.Coerce
open import IO.Base
open import System.Exit
import System.Process.Primitive as Prim
private
variable
ℓ : Level
callCommand : String → IO {ℓ} ⊤
callCommand cmd = lift′ (Prim.callCommand cmd)
system : String → IO ExitCode
system cmd = lift (Prim.system cmd)
callProcess : String → List String → IO {ℓ} ⊤
callProcess exe args = lift′ (Prim.callProcess exe args)
readProcess
: String -- Filename of the executable
→ List String -- any arguments
→ String -- standard input
→ IO String -- stdout
readProcess exe args stdin = lift (Prim.readProcess exe args stdin)
readProcessWithExitCode
: String -- Filename of the executable
→ List String -- any arguments
→ String -- standard input
→ IO (ExitCode × String × String) -- exitcode, stdout, stderr
readProcessWithExitCode exe args stdin =
lift (coerce Prim.readProcessWithExitCode exe args stdin)
callProcessWithExitCode : String → List String → IO ExitCode
callProcessWithExitCode exe args = proj₁ <$> readProcessWithExitCode exe args ""