interpolator 0.1.1 → 0.1.2
raw patch · 2 files changed
+9/−8 lines, 2 filesnew-uploader
Files
- interpolator.cabal +4/−4
- src/Data/Interpolation.hs +5/−4
interpolator.cabal view
@@ -1,16 +1,16 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.0.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 81768ccb2307e3de44aa6d39b0295cc9a459e02c136be78538dc08541f68365e+-- hash: 99eadf3b4df4c6738c42e6f6e4789426dc11140f7faae6ecb7253fc6017283a2 name: interpolator-version: 0.1.1+version: 0.1.2 synopsis: Runtime interpolation of environment variables in records using profunctors description: Runtime interpolation of environment variables in records using profunctors. See- `https://github.com/tvision-insights/interpolator/README.md`.+ the [README](https://github.com/tvision-insights/interpolator/blob/master/README.md). category: Data stability: experimental homepage: https://github.com/tvision-insights/interpolator
src/Data/Interpolation.hs view
@@ -6,6 +6,7 @@ import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Reader (Reader, asks, runReader) import Data.Aeson (FromJSON, ToJSON, Value (String), parseJSON, toJSON, withText)+import Data.Char (isAlphaNum) import Data.Containers (mapFromList, setFromList, setToList) import Data.Either.Validation (Validation (Failure, Success), validationToEither) import Data.Map (Map, lookup)@@ -186,12 +187,12 @@ maybeGen :: Gen a -> Gen (Maybe a) maybeGen x = frequency [(1, pure Nothing), (3, Just <$> x)] -noEnv, noColons :: Gen T.Text+noEnv, varNameAllowed :: Gen T.Text noEnv = fmap T.pack $ arbitrary `suchThat` (\ s -> not ("_env:" `isPrefixOf` s) && not (null s))-noColons = fmap T.pack . listOf1 $ arbitrary `suchThat` (/= ':')+varNameAllowed = fmap T.pack . listOf1 $ arbitrary `suchThat` (\c -> isAlphaNum c || c == '_') instance Arbitrary TemplateKey where- arbitrary = TemplateKey <$> noColons+ arbitrary = TemplateKey <$> varNameAllowed instance {-# OVERLAPPABLE #-} Arbitrary a => Arbitrary (Uninterpolated a) where arbitrary = oneof@@ -202,5 +203,5 @@ instance {-# OVERLAPPING #-} Arbitrary (Uninterpolated T.Text) where arbitrary = oneof [ Literal <$> noEnv- , Templated <$> (Template <$> arbitrary <*> maybeGen noColons)+ , Templated <$> (Template <$> arbitrary <*> maybeGen noEnv) ]