autodocodec-yaml 0.3.0.1 → 0.3.0.2
raw patch · 4 files changed
+28/−18 lines, 4 filesdep ~autodocodecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: autodocodec
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- autodocodec-yaml.cabal +2/−2
- src/Autodocodec/Yaml/Encode.hs +1/−0
- src/Autodocodec/Yaml/Schema.hs +20/−16
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +## [0.3.0.1] - 2024-07-26+++* Support for `autodocodec >=0.4` and `autodocodec-schema >=0.2`.+ ## [0.3.0.0] - 2024-06-23 ### Added
autodocodec-yaml.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: autodocodec-yaml-version: 0.3.0.1+version: 0.3.0.2 synopsis: Autodocodec interpreters for yaml homepage: https://github.com/NorfairKing/autodocodec#readme bug-reports: https://github.com/NorfairKing/autodocodec/issues@@ -34,7 +34,7 @@ hs-source-dirs: src build-depends:- autodocodec >=0.3.0.0+ autodocodec >=0.4.0.0 , autodocodec-schema >=0.1.0.5 , base >=4.7 && <5 , bytestring
src/Autodocodec/Yaml/Encode.hs view
@@ -36,6 +36,7 @@ NullCodec -> Yaml.null BoolCodec _ -> Yaml.bool (coerce a :: Bool) StringCodec _ -> Yaml.string (coerce a :: Text)+ IntegerCodec _ _ -> Yaml.scientific $ fromInteger (coerce a :: Integer) NumberCodec _ _ -> yamlNumber (coerce a :: Scientific) ArrayOfCodec _ c -> Yaml.array (map (`go` c) (V.toList (coerce a :: Vector _))) ObjectOfCodec _ oc -> Yaml.mapping (goObject a oc)
src/Autodocodec/Yaml/Schema.hs view
@@ -98,9 +98,8 @@ NullSchema -> [[fore yellow "null"]] BoolSchema -> [[fore yellow "<boolean>"]] StringSchema -> [[fore yellow "<string>"]]- NumberSchema mBounds -> case mBounds of- Nothing -> [[fore yellow "<number>"]]- Just nb -> numberBoundsChunks nb+ IntegerSchema bounds -> integerBoundsChunks bounds+ NumberSchema _ -> [[fore yellow "<number>"]] -- TODO bounds? ArraySchema s -> let addListMarker = addInFrontOfFirstInList ["- "] in addListMarker $ go s@@ -144,28 +143,33 @@ ObjectAnyOfSchema ne -> anyOfChunks $ NE.map goObject ne ObjectOneOfSchema ne -> oneOfChunks $ NE.map goObject ne - numberBoundsChunks :: NumberBounds -> [[Chunk]]- numberBoundsChunks nb =- [ [fore yellow "<number>", " # "] ++ case guessNumberBoundsSymbolic nb of+ integerBoundsChunks :: Bounds Integer -> [[Chunk]]+ integerBoundsChunks nb =+ [ fore yellow "<integer>" : case guessIntegerBoundsSymbolic nb of BitUInt w ->- [ fore green $ chunk $ T.pack $ show w <> " bit unsigned integer"+ [ " # ",+ fore green $ chunk $ T.pack $ show w <> " bit unsigned integer" ] BitSInt w ->- [ fore green $ chunk $ T.pack $ show w <> " bit signed integer"- ]- OtherNumberBounds l u ->- [ "between ",- fore green $ scientificChunk l,- " and ",- fore green $ scientificChunk u+ [ " # ",+ fore green $ chunk $ T.pack $ show w <> " bit signed integer" ]+ OtherIntegerBounds ml mu -> case (ml, mu) of+ (Nothing, Nothing) -> []+ (Just l, Nothing) -> [fore green $ integerChunk l, " or more"]+ (Nothing, Just l) -> [fore green $ integerChunk l, " or less"]+ (Just l, Just u) ->+ [ "between ",+ fore green $ integerChunk l,+ " and ",+ fore green $ integerChunk u+ ] ] where- scientificChunk = \case+ integerChunk = \case Zero -> "0" PowerOf2 w -> chunk $ T.pack $ "2^" <> show w PowerOf2MinusOne w -> chunk $ T.pack $ "2^" <> show w <> "-1" MinusPowerOf2 w -> chunk $ T.pack $ "-2^" <> show w MinusPowerOf2MinusOne w -> chunk $ T.pack $ "- (2^" <> show w <> "-1)" OtherInteger i -> chunk $ T.pack $ show i- OtherDouble d -> chunk $ T.pack $ show d