describe 0.2.0.3 → 0.2.0.4
raw patch · 3 files changed
+8/−3 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Serialize.Describe.Combinators: newtype Predicate t p => Optional p t
+ Data.Serialize.Describe.Combinators: newtype Optional p t
Files
- CHANGELOG.md +4/−0
- describe.cabal +2/−1
- src/Data/Serialize/Describe/Combinators.hs +2/−2
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for describe +## 0.2.0.4 -- 2019-10-06++* Made Vec instance for Equals overlapping. + ## 0.2.0.3 -- 2019-10-06 * Added constraint on `Optional` to prevent overlapping instances on the supplied predicate.
describe.cabal view
@@ -3,7 +3,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: describe-version: 0.2.0.3+version: 0.2.0.4 synopsis: Combinators for describing binary data structures description: Combinators for describing binary data structures, which eliminate the boilerplate of having to write isomorphic Get and Put instances. Please see the Github page for examples. homepage: https://github.com/riugabachi/describe@@ -25,6 +25,7 @@ FunctionalDependencies, TypeFamilies, TypeOperators,+ OverlappingInstances, FlexibleContexts, DefaultSignatures, DataKinds,
src/Data/Serialize/Describe/Combinators.hs view
@@ -15,7 +15,7 @@ import qualified Data.Serialize.Get as G -- | An 'Optional' represents a field which is optionally-serializable. The field will be parsed via a lookAhead and, if the value matches the 'Predicate' p, then the field exists. If not, it is assumed as though the field was never serialized in the first place and the value will be set to 'Nothing'; parsing will then continue on as usual.-newtype Predicate t p => Optional p t = Optional { unwrapOptional :: Maybe t }+newtype Optional p t = Optional { unwrapOptional :: Maybe t } class Predicate t a where check :: t -> Bool@@ -25,7 +25,7 @@ instance (KnownNat n, Integral i) => Predicate i (Equals n) where check i = i == (fromIntegral $ natVal (Proxy :: Proxy n)) -instance (KnownNat n1, KnownNat n2, V.Arity n2, V.Vector (Vec n2) i, Integral i) => Predicate (Vec n2 i) (Equals n1) where+instance {-# OVERLAPPING #-} (KnownNat n1, KnownNat n2, V.Arity n2, V.Vector (Vec n2) i, Integral i) => Predicate (Vec n2 i) (Equals n1) where check = V.all (== fromIntegral (natVal (Proxy :: Proxy n1))) instance (Describe a, Predicate a p) => Describe (Optional p a) where