mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-14 22:21:10 +00:00
041838a942
* First cut reading JSON into an Agda representation of Luau syntax
29 lines
949 B
Agda
29 lines
949 B
Agda
module FFI.System.Exit where
|
||
|
||
open import Agda.Builtin.Int using (Int)
|
||
open import Agda.Builtin.IO using (IO)
|
||
open import Agda.Builtin.Unit using (⊤)
|
||
|
||
data ExitCode : Set where
|
||
ExitSuccess : ExitCode
|
||
ExitFailure : Int → ExitCode
|
||
|
||
{-# FOREIGN GHC data AgdaExitCode = AgdaExitSuccess | AgdaExitFailure Integer #-}
|
||
{-# COMPILE GHC ExitCode = data AgdaExitCode (AgdaExitSuccess | AgdaExitFailure) #-}
|
||
|
||
{-# FOREIGN GHC import qualified System.Exit #-}
|
||
|
||
{-# FOREIGN GHC
|
||
toExitCode :: AgdaExitCode -> System.Exit.ExitCode
|
||
toExitCode AgdaExitSuccess = System.Exit.ExitSuccess
|
||
toExitCode (AgdaExitFailure n) = System.Exit.ExitFailure (fromIntegral n)
|
||
|
||
fromExitCode :: System.Exit.ExitCode -> AgdaExitCode
|
||
fromExitCode System.Exit.ExitSuccess = AgdaExitSuccess
|
||
fromExitCode (System.Exit.ExitFailure n) = AgdaExitFailure (fromIntegral n)
|
||
#-}
|
||
|
||
postulate
|
||
exitWith : ExitCode → IO ⊤
|
||
|
||
{-# COMPILE GHC exitWith = System.Exit.exitWith . toExitCode #-}
|