ref: 30bbf972cec6f7ed080b42d6ccead04e110f8b98
parent: 3129f49efc43bb6f3d21f6200e996c2212e7e236
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Feb 2 17:22:45 EST 2024
Some more functionality.
--- a/README.md
+++ b/README.md
@@ -111,8 +111,9 @@
```
## Libraries
-There are a number of libraries that have some of the standard Haskell functions.
-But in general, the `Prelude` contains less.
+The `Prelude` contains the functions from the Haskell Report and a few extensions,
+with the notable exception that `Foldable` and `Traversable` are not part of the `Prelude`.
+They can be imported separately, though.
## Types
There are some primitive data types, e.g `Int`, `IO`, `Ptr`, and `Double`.
--- a/lib/System/Environment.hs
+++ b/lib/System/Environment.hs
@@ -2,6 +2,7 @@
-- See LICENSE file for full license.
module System.Environment(
getArgs,
+ getProgName,
withArgs,
lookupEnv,
) where
@@ -36,3 +37,7 @@
return Nothing
else
Just <$> peekCAString cptr
+
+-- XXX implement this
+getProgName :: IO String
+getProgName = return "???"
--- /dev/null
+++ b/lib/System/Exit.hs
@@ -1,0 +1,26 @@
+module System.Exit(
+ ExitCode(..),
+ exitWith,
+ exitFailure,
+ exitSuccess,
+ die,
+ ) where
+import Prelude
+import Control.Exception
+import System.IO
+
+data ExitCode = ExitSuccess | ExitFailure Int
+ deriving (Show)
+
+-- XXX This needs work
+exitWith :: forall a . ExitCode -> IO a
+exitWith e = throwIO (Exn (show e))
+
+exitFailure :: forall a . IO a
+exitFailure = exitWith (ExitFailure 1)
+
+exitSuccess :: forall a . IO a
+exitSuccess = exitWith ExitSuccess
+
+die :: forall a . String -> IO a
+die err = hPutStrLn stderr err >> exitFailure
--
⑨