from-env: Provides a generic way to construct values from environment variables.
This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.
Warnings:
- These packages miss upper bounds: - hspec Please add them, using `cabal gen-bounds` for suggestions. For more information see: https://pvp.haskell.org/
This package exposes a class FromEnv that works with GHC.Generics to provide a generic way
to construct values from environment variables.
In many applications you'll have a configuration object holding a connection string to your
database, the url of an S3 bucket, you name it. It can be tedious to have to construct this
configuration object manually. With this package, you just derive Generic and then create an
instance of FromEnv for your configuration type and you're done. Just call fromEnv and you got
your configuration.
import System.Environment.FromEnv
import GHC.Generics
newtype Config = Config { configS3BucketUrl :: String } deriving Generic
instance FromEnv Config
config <- fromEnvThe default behaviour is to convert field names like configS3BucketUrl into
environment variables like CONFIG_S3_BUCKET_URL, but it can be overriden by providing a
custom instance of FromEnv.
[Skip to Readme]
Properties
| Versions | 0.1.0.0, 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0 |
|---|---|
| Change log | None available |
| Dependencies | base (>=4.16.4.0 && <4.17), casing (>=0.1.4 && <0.2), text (>=1.2.5 && <1.3) [details] |
| License | MIT |
| Copyright | Alexander Goussas 2023 |
| Author | Alexander Goussas |
| Maintainer | goussasalexander@gmail.com |
| Category | Configuration |
| Bug tracker | https://github.com/aloussase/from-env/issues |
| Source repo | head: git clone https://github.com/aloussase/from-env.git |
| Uploaded | by aloussase at 2023-07-30T20:18:45Z |
Modules
- System
- Environment
- System.Environment.FromEnv
- System.Environment.FromEnv.TryParse
- System.Environment.FromEnv
- Environment
Downloads
- from-env-0.1.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
Package maintainers
For package maintainers and hackage trustees