packages feed

nri-env-parser 0.1.0.0 → 0.1.0.1

raw patch · 5 files changed

+35/−37 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.1.0.1++- Relax version bounds to encompass `base-4.14.0.0`.+ # 0.1.0.0  - Initial release.
LICENSE view
@@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2017, NoRedInk+Copyright (c) 2020, NoRedInk All rights reserved.  Redistribution and use in source and binary forms, with or without
README.md view
@@ -2,8 +2,6 @@  _Reviewed last on 2019-07-20_ -The 12-factor app uses environment variables for configuration.-A Haskell app will need to parse environmental values into types.-This library provides functionality to do so for commonly used typed.+The 12-factor app uses environment variables for configuration. A Haskell app will need to parse environmental values into types. This library provides functionality to do so for commonly used types.  It also provides a way to generate an overview of all environment variables an app consumes.
nri-env-parser.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: d22fe61021208189a56a80ca09f2b903d8654a0bb3e96494641826d0dae29ca2+-- hash: efef48fbd62525c777eef0dc9107690b7bc0002576e29d7298bfb943028d19d2  name:           nri-env-parser-version:        0.1.0.0+version:        0.1.0.1 synopsis:       Read environment variables as settings to build 12-factor apps. description:    Please see the README at <https://github.com/NoRedInk/haskell-libraries/tree/trunk/env-parser>. homepage:       https://github.com/NoRedInk/haskell-libraries#readme@@ -38,7 +38,7 @@   default-extensions: DataKinds DeriveGeneric FlexibleContexts FlexibleInstances GeneralizedNewtypeDeriving MultiParamTypeClasses NamedFieldPuns NoImplicitPrelude OverloadedStrings PartialTypeSignatures ScopedTypeVariables Strict TypeOperators   ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wpartial-fields -Wredundant-constraints -Wincomplete-uni-patterns   build-depends:-      base >=4.12.0.0 && <4.13+      base >=4.12.0.0 && <4.15     , modern-uri >=0.3.1.0 && <0.4     , network-uri >=2.6.2.0 && <2.8     , nri-prelude >=0.1.0.0 && <0.2
src/Environment.hs view
@@ -2,26 +2,22 @@  -- | A module for reading configuration options from environment variables. ----- Applications have configuration options. [The Twelve-Factor App] recommends--- applications read these from environment variables. This requires us to--- decode environment variables, which are strings, into the different types the--- app's configuration options might have. This module helps with that.+-- Applications have configuration options. [The Twelve-Factor+-- App](https://12factor.net/import) recommends applications read these from+-- environment variables. This requires us to decode environment variables,+-- which are strings, into the different types the app's configuration options+-- might have. This module helps with that. ----- There's a couple of similar modules out there (like @envparse@ and @envy@),--- but we find them overly complicated in some ways and lacking in others.--- Here's what sets this package apart from these other approaches:+-- Here's what sets this package apart from other environment parsers: -- -- - Very small API, supporting just one way to do environment parsing.--- - Comes with parsers for common configuration option types, such as uris.+-- - Comes with parsers for common configuration option types, such as URIs. --   Not using type classes for these parsers means we don't have to write a --   bunch of orphan instances. -- - Mandatory documentation of each environment variable we want to decode. -- - The decoders keep track of all the environment variables they depend on. --   That way the decoder for an application can tell us all the environment---   variables an application depends on and (because of the mandatory---   documentation) what those environment variables are used for.------ [The Twelve-Factor App]: https://12factor.net/import NriPrelude+--   variables an application depends on and what they are used for. module Environment   ( -- * Parsers     Parser,@@ -162,15 +158,15 @@ -- | Create a parser for custom types. Build on the back of one of the primitve -- parsers from this module. -----     data Environment = Development | Production------     environment :: Parser Environment---     environment =---         custom text <| \str ->---             case str of---                 "development" -> Ok Development---                 "production" -> Ok Production---                 _ -> Err ("Unknown environment: " ++ str)+-- > data Environment = Development | Production+-- >+-- > environment :: Parser Environment+-- > environment =+-- >     custom text <| \str ->+-- >         case str of+-- >             "development" -> Ok Development+-- >             "production" -> Ok Production+-- >             _ -> Err ("Unknown environment: " ++ str) custom :: Parser a -> (a -> Result Text b) -> Parser b custom (Parser base) fn = Parser (\val -> base val |> andThen fn) @@ -239,15 +235,15 @@ -- | Produce a configuration from a single environment veriable. Usually you -- will combine these with @mapN@ functions to build larger configurations. -----     Data Settings = Settings---        { amountOfHats :: Int---        , furLined :: Bool---        }------     map2---      Settings---      (variable (Variable "HATS" "Amount of hats" "2") int)---      (variable (Variable "FUR_LINED" "Do hats have fur lining?" "False") boolean)+-- > Data Settings = Settings+-- >    { amountOfHats :: Int+-- >    , furLined :: Bool+-- >    }+-- >+-- > map2+-- >  Settings+-- >  (variable (Variable "HATS" "Amount of hats" "2") int)+-- >  (variable (Variable "FUR_LINED" "Do hats have fur lining?" "False") boolean) variable :: Variable -> Parser a -> Decoder a variable var (Parser parse) =   Decoder