8||| Get the command-line arguments that the program was called with.
9getArgs : IO (List String)
10getArgs = do n <- numArgs
14 numArgs = mkForeign (FFun "idris_numArgs" [] FInt)
16 getArg : Int -> IO String
17 getArg x = mkForeign (FFun "idris_getArg" [FInt] FString) x
19 ga' : List String -> Int -> Int -> IO (List String)
20 ga' acc i n = if (i == n) then (return $ reverse acc) else
22 ga' (arg :: acc) (i+1) n
24||| Retrieves an value from the environment, if the given key is present,
25||| otherwise it returns Nothing.
26getEnv : String -> IO (Maybe String)
29 is_nil <- nullStr str_ptr
32 else pure (Just str_ptr)
35 getEnv' = mkForeign (FFun "getenv" [FString] FString) key
37||| Sets an environment variable with a given value.
38||| Returns true if the operation was successful.
39setEnv : String -> String -> IO Bool
41 ok <- mkForeign (FFun "setenv" [FString, FString, FInt] FInt) key value 1
44||| Unsets an environment variable.
45||| Returns true if the variable was able to be unset.
46unsetEnv : String -> IO Bool
48 ok <- mkForeign (FFun "unsetenv" [FString] FInt) key
51getEnvironment : IO (List (String, String))
52getEnvironment = getAllPairs 0 []
54 getEnvPair : Int -> IO String
55 getEnvPair i = mkForeign (FFun "getEnvPair" [FInt] FString) i
57 splitEq : String -> (String, String)
59 -- FIXME: There has to be a better way to split this up
60 let (k, v) = break (== '=') str in
61 let (_, v') = break (/= '=') v in
64 getAllPairs : Int -> List String -> IO (List (String, String))
65 getAllPairs n acc = do
66 envPair <- getEnvPair n
67 is_nil <- nullStr envPair
69 then return $ reverse $ map splitEq acc
70 else getAllPairs (n + 1) (envPair :: acc)
72||| Quit with a particular exit code
74exit code = mkForeign (FFun "exit" [FInt] FUnit) code
78time = mkForeign (FFun "idris_time" [] FInt)
81usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list