1 -----------------------------------------------------------------------------
2 -- Standard Library: System operations
4 -- Warning: the implementation of these functions in Hugs 98 is very weak.
5 -- The functions themselves are best suited to uses in compiled programs,
6 -- and not to use in an interpreter-based environment like Hugs.
8 -- Suitable for use with Hugs 98
9 -----------------------------------------------------------------------------
12 ExitCode(..), exitWith, exitFailure,
13 getArgs, getProgName, getEnv,
17 data ExitCode = ExitSuccess | ExitFailure Int
18 deriving (Eq, Ord, Read, Show)
20 getArgs :: IO [String]
21 getArgs = primGetRawArgs >>= \rawargs ->
22 return (drop 1 (dropWhile (/= "--") rawargs))
24 getProgName :: IO String
25 getProgName = primGetRawArgs >>= \rawargs ->
28 getEnv :: String -> IO String
31 system :: String -> IO ExitCode
32 system s = error "System.system unimplemented"
34 exitWith :: ExitCode -> IO a
35 exitWith c = error "System.exitWith unimplemented"
38 exitFailure = exitWith (ExitFailure 1)
40 toExitCode :: Int -> ExitCode
41 toExitCode 0 = ExitSuccess
42 toExitCode n = ExitFailure n
44 fromExitCode :: ExitCode -> Int
45 fromExitCode ExitSuccess = 0
46 fromExitCode (ExitFailure n) = n
48 -----------------------------------------------------------------------------