generics-sop 0.1.0.4 → 0.1.1
raw patch · 7 files changed
+35/−19 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290, t300)
+ Generics.SOP.Instances: instance Generic (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290, t300, t310)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290, t300)
+ Generics.SOP.Instances: instance HasDatatypeInfo (a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0, q0, r0, s0, t0, u0, v0, w0, x0, y0, z0, t280, t290, t300, t310)
- Generics.SOP: class SingI (Code a) => Generic (a :: *) where type family Code a :: [[*]] type instance Code a = GCode a from = gfrom to = gto
+ Generics.SOP: class (SingI (Code a), All SingI (Code a)) => Generic (a :: *) where type family Code a :: [[*]] type instance Code a = GCode a from = gfrom to = gto
- Generics.SOP.Universe: class SingI (Code a) => Generic (a :: *) where type family Code a :: [[*]] type instance Code a = GCode a from = gfrom to = gto
+ Generics.SOP.Universe: class (SingI (Code a), All SingI (Code a)) => Generic (a :: *) where type family Code a :: [[*]] type instance Code a = GCode a from = gfrom to = gto
Files
- generics-sop.cabal +1/−1
- src/Generics/SOP.hs +8/−8
- src/Generics/SOP/Instances.hs +15/−0
- src/Generics/SOP/NP.hs +6/−6
- src/Generics/SOP/NS.hs +2/−2
- src/Generics/SOP/Sing.hs +1/−1
- src/Generics/SOP/Universe.hs +2/−1
generics-sop.cabal view
@@ -1,5 +1,5 @@ name: generics-sop-version: 0.1.0.4+version: 0.1.1 synopsis: Generic Programming using True Sums of Products description: A library to support the definition of generic functions.
src/Generics/SOP.hs view
@@ -69,9 +69,9 @@ -- For example, -- -- >>> from (D (C True) 3) :: Rep A--- > SOP (S (Z (I (C True) :* I 3 :* Nil)))+-- SOP (S (Z (I (C True) :* I 3 :* Nil))) -- >>> to it :: A--- > D (C True) 3+-- D (C True) 3 -- -- Note that the transformation is shallow: In @D (C True) 3@, the -- inner value @C True@ of type @A@ is not affected by the@@ -153,13 +153,13 @@ -- -- >>> let x = G 2.5 'A' False :: B Double -- >>> from x--- > SOP (S (Z (I 2.5 :* I 'A' :* I False :* Nil)))+-- SOP (S (Z (I 2.5 :* I 'A' :* I False :* Nil))) -- >>> hcliftA (Proxy :: Proxy NFData) (\ (I x) -> K (rnf x)) it--- > SOP (S (Z (K () :* K () :* K () :* Nil)))+-- SOP (S (Z (K () :* K () :* K () :* Nil))) -- >>> hcollapse it--- > [(),(),()]+-- [(),(),()] -- >>> rnf it--- > ()+-- () -- -- The 'from' call converts into the structural representation. -- Via 'hcliftA', we apply 'rnf' to all the components. The result@@ -176,9 +176,9 @@ -- class 'Generic'. -- -- >>> grnf (G 2.5 'A' False)--- > ()+-- () -- >>> grnf (G 2.5 undefined False)--- > *** Exception: Prelude.undefined+-- *** Exception: Prelude.undefined -- -- Note that the type of 'grnf' requires that all components of the -- type are in the 'Control.DeepSeq.NFData' class. For a recursive
src/Generics/SOP/Instances.hs view
@@ -67,6 +67,21 @@ deriveGeneric ''(,,,,,,,,,,,,) deriveGeneric ''(,,,,,,,,,,,,,) deriveGeneric ''(,,,,,,,,,,,,,,) -- 15+deriveGeneric ''(,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,) -- 20+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,) -- 25+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,)+deriveGeneric ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) -- 30 deriveGeneric ''[] -- Other types from base:
src/Generics/SOP/NP.hs view
@@ -122,9 +122,9 @@ -- /Example:/ -- -- >>> pure_NP [] :: NP [] '[Char, Bool]--- > "" :* [] :* Nil+-- "" :* [] :* Nil -- >>> pure_NP (K 0) :: NP (K Int) '[Double, Int, String]--- > K 0 :* K 0 :* K 0 :* Nil+-- K 0 :* K 0 :* K 0 :* Nil -- pure_NP :: forall f xs. SingI xs => (forall a. f a) -> NP f xs pure_NP f = case sing :: Sing xs of@@ -311,7 +311,7 @@ -- /Example:/ -- -- >>> collapse_NP (K 1 :* K 2 :* K 3 :* Nil)--- > [1,2,3]+-- [1,2,3] -- collapse_NP :: NP (K a) xs -> [a] @@ -320,7 +320,7 @@ -- /Example:/ -- -- >>> collapse_POP (POP ((K 'a' :* Nil) :* (K 'b' :* K 'c' :* Nil) :* Nil) :: POP (K Char) '[ '[(a :: *)], '[b, c] ])--- > ["a", "bc"]+-- ["a", "bc"] -- -- (The type signature is only necessary in this case to fix the kind of the type variables.) --@@ -358,7 +358,7 @@ -- /Example:/ -- -- >>> sequence_NP (Just 1 :* Just 2 :* Nil)--- > Just (I 1 :* I 2 :* Nil)+-- Just (I 1 :* I 2 :* Nil) -- sequence_NP :: (SingI xs, Applicative f) => NP f xs -> f (NP I xs) @@ -367,7 +367,7 @@ -- /Example:/ -- -- >>> sequence_POP (POP ((Just 1 :* Nil) :* (Just 2 :* Just 3 :* Nil) :* Nil))--- > Just (POP ((I 1 :* Nil) :* ((I 2 :* (I 3 :* Nil)) :* Nil)))+-- Just (POP ((I 1 :* Nil) :* ((I 2 :* (I 3 :* Nil)) :* Nil))) -- sequence_POP :: (SingI xss, Applicative f) => POP f xss -> f (POP I xss)
src/Generics/SOP/NS.hs view
@@ -152,7 +152,7 @@ -- /Example:/ -- -- >>> apInjs_NP (I 'x' :* I True :* I 2 :* Nil)--- > [Z (I 'x'), S (Z (I True)), S (S (Z (I 2)))]+-- [Z (I 'x'), S (Z (I True)), S (S (Z (I 2)))] -- apInjs_NP :: SingI xs => NP f xs -> [NS f xs] apInjs_NP = hcollapse . hap injections@@ -167,7 +167,7 @@ -- /Example:/ -- -- >>> apInjs_POP (POP ((I 'x' :* Nil) :* (I True :* I 2 :* Nil) :* Nil))--- > [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* (I 2 :* Nil))))]+-- [SOP (Z (I 'x' :* Nil)),SOP (S (Z (I True :* (I 2 :* Nil))))] -- apInjs_POP :: SingI xss => POP f xss -> [SOP f xss] apInjs_POP = map SOP . apInjs_NP . unPOP
src/Generics/SOP/Sing.hs view
@@ -83,7 +83,7 @@ -- of type-level lists (esp because of https://ghc.haskell.org/trac/ghc/ticket/9108) data Shape :: [k] -> * where ShapeNil :: Shape '[]- ShapeCons :: SingI xs => Shape xs -> Shape (x ': xs)+ ShapeCons :: (SingI x, SingI xs) => Shape xs -> Shape (x ': xs) deriving instance Show (Shape xs) deriving instance Eq (Shape xs)
src/Generics/SOP/Universe.hs view
@@ -6,6 +6,7 @@ import qualified GHC.Generics as GHC import Generics.SOP.BasicFunctors+import Generics.SOP.Constraint import Generics.SOP.NS import Generics.SOP.Sing import Generics.SOP.GGP@@ -89,7 +90,7 @@ -- -- still holds. ---class SingI (Code a) => Generic (a :: *) where+class (SingI (Code a), All SingI (Code a)) => Generic (a :: *) where -- | The code of a datatype. -- -- This is a list of lists of its components. The outer list contains