load-env: Load environment variables from a file.

[ bsd3, configuration, library ] [ Propose Tags ]

Parse a .env file and load any declared variables into the current process's environment. This allows for a .env file to specify development-friendly defaults for configuration values normally set in the deployment environment.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.1.0, 0.1.1, 0.1.2,,,,
Change log CHANGELOG.md
Dependencies base (>=4.8.0 && <5), directory, filepath, parsec [details]
License BSD-3-Clause
Author Pat Brisbin <pbrisbin@gmail.com>
Maintainer Pat Brisbin <pbrisbin@gmail.com>
Category Configuration
Home page https://github.com/pbrisbin/load-env#readme
Bug tracker https://github.com/pbrisbin/load-env/issues
Source repo head: git clone https://github.com/pbrisbin/load-env
Uploaded by PatrickBrisbin at 2018-10-12T20:27:50Z
Distributions Debian:, LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 9442 total (38 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-10-12 [all 1 reports]

Readme for load-env-

[back to package description]


Build Status

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 LoadEnv
import System.Environment (lookupEnv)

main :: IO ()
main = do

    print =<< lookupEnv "FOO"
% cat .env
% runhaskell main.hs
Just "bar"

Development & Test

stack setup
stack build --pedantic --test