from-env-0.1.2.0: from-env.cabal
cabal-version: 2.4
name: from-env
version: 0.1.2.0
synopsis:
Provides a generic way to construct values from environment variables.
description:
.
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 <- fromEnv
.
The 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`.
bug-reports: https://github.com/aloussase/from-env/issues
license: MIT
author: Alexander Goussas
maintainer: goussasalexander@gmail.com
copyright: Alexander Goussas 2023
category: Configuration
extra-source-files: README.md
source-repository head
type: git
location: https://github.com/aloussase/from-env.git
library
exposed-modules:
System.Environment.FromEnv
System.Environment.FromEnv.TryParse
ghc-options: -Wall
-- other-modules:
build-depends:
, base ^>=4.16.3.0
, casing >=0.1.4 && <0.2
, text >=1.2.5 && <1.3
hs-source-dirs: src
default-language: Haskell2010
test-suite from-env-test-suite
type: exitcode-stdio-1.0
ghc-options: -Wall
hs-source-dirs: test
main-is: Spec.hs
other-modules: System.Environment.FromEnvSpec
build-depends:
, base ^>=4.16.3.0
, from-env
, hspec
build-tool-depends: hspec-discover:hspec-discover
default-language: Haskell2010