packages feed

higgledy 0.2.0.0 → 0.2.0.1

raw patch · 4 files changed

+40/−12 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Generic.HKD.Types: instance (Data.Barbie.Internal.Functor.FunctorB (Data.Generic.HKD.Types.HKD structure), Data.Generic.HKD.Types.GConstraintsB (GHC.Generics.Rep structure)) => Data.Barbie.Internal.Constraints.ConstraintsB (Data.Generic.HKD.Types.HKD structure)
- Data.Generic.HKD.Types: instance c inner => Data.Generic.HKD.Types.GConstraintsB (GHC.Generics.K1 index inner)
+ Data.Generic.HKD.Types: instance (Data.Barbie.Internal.Functor.FunctorB (Data.Generic.HKD.Types.HKD structure), Data.Generic.HKD.Types.GConstraintsB (GHC.Generics.Rep structure), Data.Generic.HKD.Types.GAllBC (GHC.Generics.Rep structure)) => Data.Barbie.Internal.Constraints.ConstraintsB (Data.Generic.HKD.Types.HKD structure)
+ Data.Generic.HKD.Types: instance (Data.Generic.HKD.Types.GAllBC left, Data.Generic.HKD.Types.GAllBC right) => Data.Generic.HKD.Types.GAllBC (left GHC.Generics.:*: right)
+ Data.Generic.HKD.Types: instance Data.Generic.HKD.Types.GAllBC (GHC.Generics.K1 index inner)
+ Data.Generic.HKD.Types: instance Data.Generic.HKD.Types.GAllBC inner => Data.Generic.HKD.Types.GAllBC (GHC.Generics.M1 index meta inner)
+ Data.Generic.HKD.Types: instance Data.Generic.HKD.Types.GConstraintsB (GHC.Generics.K1 index inner)

Files

README.md view
@@ -53,8 +53,8 @@ module Example where  import Control.Lens ((.~), (^.), (&), Const (..), Identity, anyOf)-import Data.Funtor.Const (Const (..))-import Data.Funtor.Identity (Identity (..))+import Data.Functor.Const (Const (..))+import Data.Functor.Identity (Identity (..)) import Data.Generic.HKD import Data.Maybe (isJust, isNothing) import Data.Monoid (Last (..))
higgledy.cabal view
@@ -1,7 +1,7 @@ cabal-version:       2.4  name:                higgledy-version:             0.2.0.0+version:             0.2.0.1 synopsis:            Partial types as a type constructor. description:         Use the generic representation of an ADT to get a higher-kinded data-style interface automatically. homepage:            https://github.com/i-am-tom/higgledy@@ -34,6 +34,7 @@  test-suite test   build-depends:       base+                     , barbies ^>= 1.1.0                      , doctest ^>= 0.16.0                      , higgledy                      , hspec ^>= 2.6.1
src/Data/Generic/HKD/Types.hs view
@@ -266,33 +266,47 @@  ------------------------------------------------------------------------------- -class GConstraintsB (rep :: Type -> Type) where+class GAllBC (rep :: Type -> Type) where   type GAllB (c :: Type -> Constraint) rep :: Constraint +class GConstraintsB (rep :: Type -> Type) where   gbaddDicts :: GAllB c rep => GHKD_ f rep p -> GHKD_ (Dict c `Product` f) rep p -instance GConstraintsB inner => GConstraintsB (M1 index meta inner) where+instance GAllBC inner => GAllBC (M1 index meta inner) where   type GAllB c (M1 index meta inner) = GAllB c inner +instance GConstraintsB inner => GConstraintsB (M1 index meta inner) where   gbaddDicts (M1 x) = M1 (gbaddDicts @inner x) -instance (GConstraintsB left, GConstraintsB right)-    => GConstraintsB (left :*: right) where+instance (GAllBC left, GAllBC right) => GAllBC (left :*: right) where   type GAllB c (left :*: right) = (GAllB c left, GAllB c right) +instance (GConstraintsB left, GConstraintsB right)+    => GConstraintsB (left :*: right) where   gbaddDicts (left :*: right)     = gbaddDicts @left left :*: gbaddDicts @right right -instance c inner => GConstraintsB (K1 index inner) where+instance GAllBC (K1 index inner) where   type GAllB c (K1 index inner) = c inner -  gbaddDicts (K1 x)-    = K1 (Pair Dict x)+instance GConstraintsB (K1 index inner) where+  gbaddDicts (K1 x) = K1 (Pair Dict x) -instance (FunctorB (HKD structure), GConstraintsB (Rep structure))+instance+    ( FunctorB (HKD structure)+    , GConstraintsB (Rep structure)+    , GAllBC (Rep structure)+    )     => ConstraintsB (HKD structure) where   type AllB c (HKD structure) = GAllB c (Rep structure)-  baddDicts (HKD x) = HKD (gbaddDicts @(Rep structure) x)++  baddDicts+    :: forall c f+     . AllB c (HKD structure)+    => HKD structure f+    -> HKD structure (Dict c `Product` f)+  baddDicts (HKD x)+    = HKD (gbaddDicts @(Rep structure) x)  ------------------------------------------------------------------------------- 
test/Main.hs view
@@ -14,6 +14,10 @@ import Data.Function ((&), on) import Data.Generic.HKD import Data.Monoid (Last (..))+import Data.Barbie+import Data.Barbie.Constraints (Dict)+import Data.Functor.Product (Product (..))+import Data.Functor.Identity (Identity (..)) import GHC.Generics import Test.DocTest import Test.Hspec@@ -189,3 +193,12 @@      it "round-trips" $ property \(x :: a) ->       construct (deconstruct @[] x) == pure x++-- Just to test that `baddDicts` does what it's told.+data Y = Y { getY :: Int } deriving (Generic, Show)++test :: HKD Y (Product (Dict Num) Identity)+test = baddDicts test+  where+    test :: HKD Y Identity+    test = deconstruct @Identity (Y 10)