edwinb/Idris-dev — pull request #491 by gabemc (2013-09-22 06:09:22+00:00)
Title: Adding several functions to interact with environment variables.

In addition to removing the superfluous 'isNullString' function,
now that I understand the FFI a bit better, there is a new
'getEnvPair' function that looks into the 'const char** environ'.
Setting, unsetting, and listing all of the environment variables is
now supported.

A test program that nearly mimics the standard Unix `env` utility is:

```
module Main

import System

mapM_ : (Monad m) => (a -> m b) -> List a -> m ()
mapM_ f xs = sequence_ (map f xs)

toEntry : (String, String) -> IO ()
toEntry (k, v) = do
putStr k
putStr "="
putStrLn v

main : IO ()
main = getEnvironment >>= mapM_ toEntry
```

Potential problems:
* I'm not so happy with the `splitEq` function in `getEnvironment`. I feel that there is a more elegant solution that I'm missing, given my unfamiliarity with the language.
* The `getEnvPair` C-function is in multiple places. Should I keep them in these locations or is it possible to refactor them out to some common place?