schemas 0.2.0.1 → 0.2.0.2
raw patch · 5 files changed
+11/−2 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +3/−0
- README.md +1/−1
- schemas.cabal +1/−1
- src/Schemas/Class.hs +1/−0
- test/SchemasSpec.hs +5/−0
CHANGELOG.md view
@@ -1,5 +1,8 @@ # Revision history for schemas +## 0.2.0.2 -- 2019-10-07+* Change the default schema for `Either` to handle both CamelCase and lowercase+ ## 0.2.0.1 -- 2019-10-02 * Fixed subtyping relation for arrays
README.md view
@@ -53,7 +53,7 @@ Sometimes there is more than one way to encode a value. A field can be renamed or change its type, an optional field become mandatory, several fields can be merged into one, etc. Alternative encodings allow for backwards compatible schema evolution. This library support alternative encodings via the `Monoid` instance for typed schemas and the `Alternative` instance for `RecordFields`. -The schema `A|B` encodes a value in two alternative ways `A` and `B`. A message created with this schema may encodings A, B or both. 'encode' will always create messages with all the possible encodings. While messages with multiple alternative encodings are not desirable for serialization, the desired message can be carved out using the subtyping relation. All the following hold:+The schema `A|B` encodes a value in two alternative ways `A` and `B`. A message created with this schema may use encodings A, B or both. 'encode' will always create messages with all the possible encodings. While messages with multiple alternative encodings are not desirable for serialization, the desired message can be carved out using the subtyping relation. All the following hold: ``` A < A|B (the coercion A -> A|B will produce a message with an A encoding) B < A|B (the coercion B -> A|B will produce a message with a B encoding)
schemas.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: schemas-version: 0.2.0.1+version: 0.2.0.2 synopsis: schema guided serialization description: Schemas is a Haskell library for serializing and deserializing data in JSON.
src/Schemas/Class.hs view
@@ -121,6 +121,7 @@ instance (HasSchema a, HasSchema b) => HasSchema (Either a b) where schema = union' [alt "Left" _Left, alt "Right" _Right]+ <> union' [alt "left" _Left, alt "right" _Right] instance (Eq key, Hashable key, HasSchema a, Key key) => HasSchema (HashMap key a) where schema = dimap toKeyed fromKeyed $ stringMap schema
test/SchemasSpec.hs view
@@ -71,6 +71,11 @@ prim `shouldBeSubtypeOf` Array prim it "subtypes cannot introduce an array" $ do Array prim `shouldNotBeSubtypeOf` prim+ describe "HasSchema" $ do+ it "Left is a constructor of Either" $ do+ Union [constructor' "Left" Empty] `shouldBeSubtypeOf` theSchema @(Either () ())+ it "left is a constructor of Either too" $ do+ Union [constructor' "left" Empty] `shouldBeSubtypeOf` theSchema @(Either () ()) describe "examples" $ do describe "Schemas" $ do prop "finite(schema @Schema) is a supertype of (schema @Schema)" $ \(SmallNatural n) ->