packages feed

lens-utils 1.4.2 → 1.4.3

raw patch · 2 files changed

+56/−18 lines, 2 filesdep +splitPVP ok

version bump matches the API change (PVP)

Dependencies added: split

API changes (from Hackage documentation)

+ Control.Lens.Aeson: optionsYamlStyle :: Options
+ Control.Lens.Aeson: parseYamlStyle :: (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
+ Control.Lens.Aeson: toEncodingYamlStyle :: (Generic a, GToEncoding Zero (Rep a)) => a -> Encoding
+ Control.Lens.Aeson: toJSONYamlStyle :: (Generic a, GToJSON Zero (Rep a)) => a -> Value

Files

lens-utils.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6b0a6fa8e9f8498288aa0e25318be82b6fca0619f852c1d3bd024b814cca8af9+-- hash: 2207e6de888dc697b0877f5ef66e0678ce42a78e4e422575b3b4444cb11e7586  name:           lens-utils-version:        1.4.2+version:        1.4.3 synopsis:       Collection of missing lens utilities. category:       Data stability:      experimental@@ -22,7 +22,7 @@ library   hs-source-dirs:       src-  default-extensions: AllowAmbiguousTypes ApplicativeDo BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse DuplicateRecordFields EmptyDataDecls FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs LambdaCase MonadComprehensions MultiWayIf NamedWildCards NegativeLiterals NumDecimals OverloadedLabels PackageImports QuasiQuotes PatternSynonyms RankNTypes RecursiveDo ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UnicodeSyntax ViewPatterns LiberalTypeSynonyms RelaxedPolyRec+  default-extensions: AllowAmbiguousTypes ApplicativeDo BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse DuplicateRecordFields EmptyDataDecls FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs LambdaCase LiberalTypeSynonyms MonadComprehensions MultiWayIf NamedWildCards NegativeLiterals NumDecimals OverloadedLabels PackageImports PatternSynonyms QuasiQuotes RankNTypes RecursiveDo RelaxedPolyRec ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UnicodeSyntax ViewPatterns   ghc-options: -Wall -O2   build-depends:       aeson@@ -31,6 +31,7 @@     , data-default     , lens     , monoid+    , split     , template-haskell   exposed-modules:       Control.Lens.Aeson
src/Control/Lens/Aeson.hs view
@@ -1,31 +1,68 @@ module Control.Lens.Aeson where  import qualified Data.Aeson          as JSON-import qualified Data.Aeson.Types    as JSON import qualified Data.Aeson.Encoding as JSON+import qualified Data.Aeson.Types    as JSON+import qualified Data.Char           as Char+import qualified Data.List           as List+import qualified Data.List.Split     as List -import qualified Data.List as List import GHC.Generics (Generic, Rep) - ------------------------------------------ -- === JSON / Yaml conversion utils === -- ------------------------------------------ -options, optionsDropUnary :: JSON.Options-options          = JSON.defaultOptions { JSON.fieldLabelModifier = List.dropWhile (== '_')}+-- === API === --++options :: JSON.Options+options = JSON.defaultOptions+    { JSON.fieldLabelModifier = List.dropWhile (== '_')}++optionsDropUnary :: JSON.Options optionsDropUnary = options { JSON.unwrapUnaryRecords = True } -parse      :: (Generic a, JSON.GFromJSON   JSON.Zero (Rep a)) => JSON.Value -> JSON.Parser a-toEncoding :: (Generic a, JSON.GToEncoding JSON.Zero (Rep a)) => a -> JSON.Encoding-toJSON     :: (Generic a, JSON.GToJSON     JSON.Zero (Rep a)) => a -> JSON.Value-parse      = JSON.genericParseJSON  options+optionsYamlStyle :: JSON.Options+optionsYamlStyle = JSON.defaultOptions { JSON.fieldLabelModifier = yaml } where+    yaml str = List.intercalate "-"+            $ (\xs -> Char.toLower <$> xs) <$> splitUpperKeep noUnderscores+        where noUnderscores  = List.dropWhile (== '_') str+              splitUpperKeep = List.split+                (List.keepDelimsL $ List.oneOf ['A'..'Z'])++parse :: (Generic a, JSON.GFromJSON JSON.Zero (Rep a)) => JSON.Value+      -> JSON.Parser a+parse = JSON.genericParseJSON  options++toEncoding :: (Generic a, JSON.GToEncoding JSON.Zero (Rep a)) => a+           -> JSON.Encoding toEncoding = JSON.genericToEncoding options-toJSON     = JSON.genericToJSON     options -parseDropUnary      :: (Generic a, JSON.GFromJSON   JSON.Zero (Rep a)) => JSON.Value -> JSON.Parser a-toEncodingDropUnary :: (Generic a, JSON.GToEncoding JSON.Zero (Rep a)) => a -> JSON.Encoding-toJSONDropUnary     :: (Generic a, JSON.GToJSON     JSON.Zero (Rep a)) => a -> JSON.Value-parseDropUnary      = JSON.genericParseJSON  optionsDropUnary+toJSON :: (Generic a, JSON.GToJSON JSON.Zero (Rep a)) => a -> JSON.Value+toJSON = JSON.genericToJSON     options++parseDropUnary :: (Generic a, JSON.GFromJSON JSON.Zero (Rep a)) => JSON.Value+               -> JSON.Parser a+parseDropUnary = JSON.genericParseJSON  optionsDropUnary++toEncodingDropUnary :: (Generic a, JSON.GToEncoding JSON.Zero (Rep a)) => a+                    -> JSON.Encoding toEncodingDropUnary = JSON.genericToEncoding optionsDropUnary-toJSONDropUnary     = JSON.genericToJSON     optionsDropUnary++toJSONDropUnary :: (Generic a, JSON.GToJSON JSON.Zero (Rep a)) => a+                -> JSON.Value+toJSONDropUnary = JSON.genericToJSON optionsDropUnary++parseYamlStyle :: (Generic a, JSON.GFromJSON JSON.Zero (Rep a)) => JSON.Value+               -> JSON.Parser a+parseYamlStyle = JSON.genericParseJSON  optionsYamlStyle++toEncodingYamlStyle :: (Generic a, JSON.GToEncoding JSON.Zero (Rep a)) => a+                    -> JSON.Encoding+toEncodingYamlStyle = JSON.genericToEncoding optionsYamlStyle++toJSONYamlStyle :: (Generic a, JSON.GToJSON JSON.Zero (Rep a)) => a+                -> JSON.Value+toJSONYamlStyle = JSON.genericToJSON     optionsYamlStyle++