homepage: https://github.com/yigitozkavci/generic-env#readme
changelog-type: markdown
hash: 19a4071cb8ff4e99fd5f61e6522bdca54643e7df4caeac1bc715798ef9f6d7cf
test-bench-deps: {}
maintainer: yigitozkavci8@gmail.com
synopsis: Generic Environment Generator
changelog: |
  # Changelog for generic-env

  ## Unreleased changes
basic-deps:
  base: ! '>=4.7 && <5'
  text: -any
  containers: -any
all-versions:
- 0.1.0.0
author: Yigit Ozkavci
latest: 0.1.0.0
description-type: markdown
description: |
  # generic-env
  generic-env lets you produce your generic type from a given subset of environment variables.

  # Usage
  ```haskell
  {-# LANGUAGE DeriveGeneric #-}
  {-# LANGUAGE TypeApplications #-}

  module Example1 where

  import GenericEnv
  import GHC.Generics
  import System.Environment

  data AppEnv = AppEnv { name :: String, ver :: String } deriving (Generic, Show)

  main :: IO ()
  main = do
    setEnv "APP_NAME" "wow"
    setEnv "APP_VER" "1.0"
    print =<< fromEnv @AppEnv (withPrefix "APP_")
  ```

  ```
  > main
  Right (AppEnv {name = "wow", ver = "1.0"})
  ```

  Let's change our version from String to Float:
  ```haskell
  data AppEnv = AppEnv { name :: String, ver :: Float } deriving (Generic, Show)
  ```
  and run the same code:
  ```
  > main
  Right (AppEnv {name = "wow", ver = 1.0})
  ```

  Next, try making the version an integer:
  ```haskell
  data AppEnv = AppEnv { name :: String, ver :: Int } deriving (Generic, Show)
  ```

  ```
  > main
  Left "Could not parse value of type 'Int' for the field named 'ver' from environment variable 'APP_VER=1.0'"
  ```

  # LICENSE
  MIT License
license-name: MIT

Update from Hackage at 2019-04-30T20:06:40Z
Update from Hackage at 2019-04-30T20:06:40Z
