packages feed

autodocodec 0.2.2.0 → 0.2.3.0

raw patch · 8 files changed

+40/−34 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Autodocodec.Class: instance Autodocodec.Class.HasCodec Data.Void.Void
+ Autodocodec.Class: instance Autodocodec.Class.HasCodec GHC.Base.Void
+ Autodocodec.Codec: instance GHC.Classes.Ord Autodocodec.Codec.NumberBounds

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.2.3.0] - 2024-06-23++### Added++* `Ord NumberBounds` instance+ ## [0.2.2.0] - 2023-11-20  ### Added
autodocodec.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack  name:           autodocodec-version:        0.2.2.0+version:        0.2.3.0 synopsis:       Self-documenting encoder and decoder homepage:       https://github.com/NorfairKing/autodocodec#readme bug-reports:    https://github.com/NorfairKing/autodocodec/issues
src/Autodocodec/Aeson.hs view
@@ -39,9 +39,9 @@ import qualified Data.ByteString.Lazy as LB  -- | Encode a value as a JSON 'LB.ByteString' via its type's 'codec'.-encodeJSONViaCodec :: HasCodec a => a -> LB.ByteString+encodeJSONViaCodec :: (HasCodec a) => a -> LB.ByteString encodeJSONViaCodec = Aeson.encode . Autodocodec  -- | Parse a JSON 'LB.ByteString' using a type's 'codec'.-eitherDecodeJSONViaCodec :: HasCodec a => LB.ByteString -> Either String a+eitherDecodeJSONViaCodec :: (HasCodec a) => LB.ByteString -> Either String a eitherDecodeJSONViaCodec = fmap unAutodocodec . Aeson.eitherDecode
src/Autodocodec/Aeson/Compat.hs view
@@ -69,21 +69,21 @@ map = HM.map #endif -liftToJSON :: JSON.ToJSON1 f => (a -> JSON.Value) -> ([a] -> JSON.Value) -> f a -> JSON.Value+liftToJSON :: (JSON.ToJSON1 f) => (a -> JSON.Value) -> ([a] -> JSON.Value) -> f a -> JSON.Value #if MIN_VERSION_aeson(2,2,0) liftToJSON = JSON.liftToJSON (const False) #else liftToJSON = JSON.liftToJSON #endif -liftToEncoding :: JSON.ToJSON1 f => (a -> JSON.Encoding) -> ([a] -> JSON.Encoding) -> f a -> JSON.Encoding+liftToEncoding :: (JSON.ToJSON1 f) => (a -> JSON.Encoding) -> ([a] -> JSON.Encoding) -> f a -> JSON.Encoding #if MIN_VERSION_aeson(2,2,0) liftToEncoding = JSON.liftToEncoding (const False) #else liftToEncoding = JSON.liftToEncoding #endif -liftParseJSON :: JSON.FromJSON1 f => (JSON.Value -> JSON.Parser a) -> (JSON.Value -> JSON.Parser [a]) -> JSON.Value -> JSON.Parser (f a)+liftParseJSON :: (JSON.FromJSON1 f) => (JSON.Value -> JSON.Parser a) -> (JSON.Value -> JSON.Parser [a]) -> JSON.Value -> JSON.Parser (f a) #if MIN_VERSION_aeson(2,2,0) liftParseJSON = JSON.liftParseJSON Nothing #else
src/Autodocodec/Aeson/Decode.hs view
@@ -33,14 +33,14 @@ import qualified Data.Vector as V  -- | Implement 'JSON.parseJSON' via a type's codec.-parseJSONViaCodec :: HasCodec a => JSON.Value -> JSON.Parser a+parseJSONViaCodec :: (HasCodec a) => JSON.Value -> JSON.Parser a parseJSONViaCodec = parseJSONVia codec  -- | Implement 'JSON.parseJSON' via a given codec. parseJSONVia :: ValueCodec void a -> JSON.Value -> JSON.Parser a parseJSONVia = parseJSONContextVia -parseJSONObjectViaCodec :: HasObjectCodec a => JSON.Object -> JSON.Parser a+parseJSONObjectViaCodec :: (HasObjectCodec a) => JSON.Object -> JSON.Parser a parseJSONObjectViaCodec = parseJSONObjectVia objectCodec  parseJSONObjectVia :: ObjectCodec void a -> JSON.Object -> JSON.Parser a@@ -152,5 +152,5 @@       PureCodec a -> pure a       ApCodec ocf oca -> go (value :: JSON.Object) ocf <*> go (value :: JSON.Object) oca -instance HasCodec a => JSON.FromJSON (Autodocodec a) where+instance (HasCodec a) => JSON.FromJSON (Autodocodec a) where   parseJSON = fmap Autodocodec <$> parseJSONViaCodec
src/Autodocodec/Aeson/Encode.hs view
@@ -33,10 +33,10 @@ import qualified Data.Vector as V  -- | Implement 'JSON.toJSON' via a type's codec.-toJSONViaCodec :: HasCodec a => a -> JSON.Value+toJSONViaCodec :: (HasCodec a) => a -> JSON.Value toJSONViaCodec = toJSONVia codec -toJSONObjectViaCodec :: HasObjectCodec a => a -> JSON.Object+toJSONObjectViaCodec :: (HasObjectCodec a) => a -> JSON.Object toJSONObjectViaCodec = toJSONObjectVia objectCodec  toJSONObjectVia :: ObjectCodec a void -> a -> JSON.Object@@ -90,10 +90,10 @@       ReferenceCodec _ c -> go a c  -- | Implement 'JSON.toEncoding' via a type's codec.-toEncodingViaCodec :: HasCodec a => a -> JSON.Encoding+toEncodingViaCodec :: (HasCodec a) => a -> JSON.Encoding toEncodingViaCodec = toEncodingVia codec -toSeriesViaCodec :: HasObjectCodec a => a -> JSON.Series+toSeriesViaCodec :: (HasObjectCodec a) => a -> JSON.Series toSeriesViaCodec = toSeriesVia objectCodec  toSeriesVia :: ObjectCodec a void -> a -> JSON.Series@@ -144,6 +144,6 @@       CommentCodec _ c -> go a c       ReferenceCodec _ c -> go a c -instance HasCodec a => JSON.ToJSON (Autodocodec a) where+instance (HasCodec a) => JSON.ToJSON (Autodocodec a) where   toJSON = toJSONViaCodec . unAutodocodec   toEncoding = toEncodingViaCodec . unAutodocodec
src/Autodocodec/Class.hs view
@@ -119,10 +119,10 @@ instance HasCodec JSON.Value where   codec = ValueCodec -instance HasCodec a => HasCodec (Identity a) where+instance (HasCodec a) => HasCodec (Identity a) where   codec = dimapCodec runIdentity Identity codec -instance HasCodec a => HasCodec (Maybe a) where+instance (HasCodec a) => HasCodec (Maybe a) where   codec = maybeCodec codec  instance (HasCodec l, HasCodec r) => HasCodec (Either l r) where@@ -131,13 +131,13 @@       (ObjectOfCodec Nothing (requiredField' "Left"))       (ObjectOfCodec Nothing (requiredField' "Right")) -instance HasCodec a => HasCodec (Vector a) where+instance (HasCodec a) => HasCodec (Vector a) where   codec = vectorCodec codec -instance HasCodec a => HasCodec [a] where+instance (HasCodec a) => HasCodec [a] where   codec = listCodecForStringCompatibility -instance HasCodec a => HasCodec (NonEmpty a) where+instance (HasCodec a) => HasCodec (NonEmpty a) where   codec = nonEmptyCodec codec  instance (Ord a, HasCodec a) => HasCodec (Set a) where@@ -194,7 +194,7 @@ -- -- See 'requiredFieldWith' requiredField ::-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   -- | Documentation@@ -204,7 +204,7 @@  -- | Like 'requiredField', but without documentation requiredField' ::-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   ObjectCodec output output@@ -218,7 +218,7 @@ -- -- See 'optionalFieldWith' optionalField ::-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   -- | Documentation@@ -228,7 +228,7 @@  -- | Like 'optionalField', but without documentation optionalField' ::-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   ObjectCodec (Maybe output) (Maybe output)@@ -270,7 +270,7 @@ -- During encoding, the field will be in the object if it is not 'Nothing', and omitted otherwise. optionalFieldOrNull ::   forall output.-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   -- | Documentation@@ -281,7 +281,7 @@ -- | Like 'optionalFieldOrNull', but without documentation optionalFieldOrNull' ::   forall output.-  HasCodec output =>+  (HasCodec output) =>   -- | Key   Text ->   ObjectCodec (Maybe output) (Maybe output)
src/Autodocodec/Codec.hs view
@@ -235,7 +235,7 @@     Maybe Text ->     ObjectCodec value value   OptionalKeyWithOmittedDefaultCodec ::-    Eq value =>+    (Eq value) =>     -- | Key     Text ->     -- | Codec for the value@@ -266,7 +266,7 @@   { numberBoundsLower :: !Scientific,     numberBoundsUpper :: !Scientific   }-  deriving (Show, Eq, Generic)+  deriving (Show, Eq, Ord, Generic)  instance Validity NumberBounds @@ -975,7 +975,7 @@ -- -- The shown version of the default value will appear in the documentation. optionalFieldWithOmittedDefaultWith ::-  Eq output =>+  (Eq output) =>   -- | Key   Text ->   -- | Codec for the value@@ -989,7 +989,7 @@  -- | Like 'optionalFieldWithOmittedDefaultWith', but without documentation. optionalFieldWithOmittedDefaultWith' ::-  Eq output =>+  (Eq output) =>   -- | Key   Text ->   -- | Codec for the value@@ -1002,7 +1002,7 @@ -- | Like 'optionalFieldWithOmittedDefaultWith', but the value may also be -- @null@ and that will be interpreted as the default value. optionalFieldOrNullWithOmittedDefaultWith ::-  Eq output =>+  (Eq output) =>   -- | Key   Text ->   -- | Codec for the value@@ -1022,7 +1022,7 @@ -- | Like 'optionalFieldWithOmittedDefaultWith'', but the value may also be -- @null@ and that will be interpreted as the default value. optionalFieldOrNullWithOmittedDefaultWith' ::-  Eq output =>+  (Eq output) =>   -- | Key   Text ->   -- | Codec for the value@@ -1720,7 +1720,7 @@ -- If you don't provide a string for one of the type's constructors, the last codec in the list will be used instead. enumCodec ::   forall enum context.-  Eq enum =>+  (Eq enum) =>   NonEmpty (enum, Codec context enum enum) ->   Codec context enum enum enumCodec = go@@ -1755,7 +1755,7 @@ -- String "foo" stringConstCodec ::   forall constant.-  Eq constant =>+  (Eq constant) =>   NonEmpty (constant, Text) ->   JSONCodec constant stringConstCodec =