packages feed

describe 0.4.0.2 → 0.4.0.3

raw patch · 4 files changed

+28/−1 lines, 4 filesdep +template-haskellPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: template-haskell

API changes (from Hackage documentation)

+ Data.Serialize.Describe.Class: describeVia :: Name -> Name -> Q [Dec]

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for describe +##0.4.0.3 -- 2020-02-07++* Added `describeVia` as an alternative to now-nonfunctional DerivingVia+ ##0.4.0.2 -- 2020-02-07  * Added representational type roles for BE and LE
describe.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                describe-version:             0.4.0.2+version:             0.4.0.3 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@@ -37,6 +37,7 @@                       ViewPatterns,                       DefaultSignatures,                       DataKinds,+                      TemplateHaskell,                       UndecidableInstances,                       PolyKinds,                       KindSignatures@@ -51,6 +52,7 @@                  text                 >= 1.2.3 && < 1.3,                  transformers         >= 0.5.6 && < 0.6,                  lens                 >= 4.18.1 && < 4.19,+                 template-haskell,                  mtl                  >= 2.2.2 && < 2.3,                  profunctors          >= 5.5.1 && < 5.6,                  mmorph               >= 1.1.3 && < 1.2,
src/Data/Serialize/Describe/Class.hs view
@@ -1,11 +1,13 @@ module Data.Serialize.Describe.Class(   Describe(..),+  describeVia,   field, isoField ) where  import GHC.Generics import GHC.Exts import GHC.TypeNats+import Language.Haskell.TH import Data.Profunctor import Control.Monad import qualified Data.Vector.Fixed as V@@ -37,6 +39,23 @@                       , forall x. Monad x => Monad (m x)                       ) => DescriptorM m a a    describe = morphTransformer (lift . runIdentityT) $ dimap from to gdescribe++-- | An alternative to DerivingVia, as the type variable @a@ of @Describe@ is bound to the type family @Context@ making its role @nominal@, and subsequently, uncoercible as per the semantics of DerivingVia. A restriction exists, however: both of the types specified must be @Coercible@.+describeVia +  :: Name +  -- ^ The type to inherit @describe@ from+  -> Name+  --  ^ The type to create a @Describe@ instance for+  -> Q [Dec]+describeVia src dst =+  [d| +    instance Describe $destination where+      type Context m $destination = Context m $source+      describe = lmap coerce coerce describe+  |]+  where+    source = conT src+    destination = conT dst  -- | A descriptor from structure to field. field 
src/Data/Serialize/Describe/Internal/Descriptor.hs view
@@ -15,6 +15,8 @@ newtype DescriptorM m s a    = Descriptor { unwrapDescriptor :: (StateT Int (m Get) a, s -> StateT Int (m PutM) a) } +type role DescriptorM nominal representational nominal+ type Descriptor s a = DescriptorM IdentityT s a  instance (MonadTrans m, forall x. Monad x => Monad (m x)) => Functor (DescriptorM m s) where