Skip to content

Commit 49fd711

Browse files
committed
[ fix ] Add cast from Int to ExitCode to Libraries
1 parent d8d360a commit 49fd711

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Core/Core.idr

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Libraries.Text.PrettyPrint.Prettyprinter
1212
import Libraries.Text.PrettyPrint.Prettyprinter.Util
1313
import Libraries.Text.PrettyPrint.Prettyprinter.Doc
1414
import Libraries.Data.Tap
15+
import Libraries.System
1516

1617
import public Data.IORef
1718
import System
@@ -989,7 +990,7 @@ handleExitCode cmd (ExitFailure status) = throw $ NonZeroExitCode cmd status
989990

990991
export
991992
system : String -> Core ExitCode
992-
system = map cast . coreLift . system
993+
system = map (cast @{ToExitCode}) . coreLift . system
993994

994995
||| Execute a shell command. Throws `NonZeroExitCode` if the command returns
995996
||| non-zero exit code.
@@ -1000,7 +1001,7 @@ safeSystem cmd = system cmd >>= handleExitCode cmd
10001001
namespace Escaped
10011002
export
10021003
system : List String -> Core ExitCode
1003-
system = map cast . coreLift . system
1004+
system = map (cast @{ToExitCode}) . coreLift . system
10041005

10051006
export
10061007
safeSystem : List String -> Core ()

src/Libraries/System.idr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Libraries.System
2+
3+
import System
4+
5+
-- TODO: Remove this, once `Cast` from `base` is available to the compiler
6+
7+
export
8+
[ToExitCode] Cast Int ExitCode where
9+
cast code with (code == 0) proof prf
10+
_ | True = ExitSuccess
11+
_ | False = ExitFailure code @{rewrite prf in Oh}

0 commit comments

Comments
 (0)