This is effectively a port of dotenv, whose README explains it best:
Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. dotenv loads variables from a .env file into ENV when the environment is bootstrapped.
This library exposes functions for doing just that.
import System.Environment (lookupEnv)
main :: IO ()
main = do
print =<< lookupEnv "FOO"
% cat .env
% runhaskell main.hs
Development & Test
stack build --pedantic --test
- Allow lower-case characters in variable names @denibertovic
- Packaging and documentation updates
- Traverse up parent directories to find the
- Packaging updates
- Parse variables names more strictly
- Don’t fail on an empty file
- Ignore any invalid lines, not specifically things that look like comments
- Don’t throw an exception if the
.envfile is missing
- Variable names can contain underscores
- Drop support for GHC < 7.8