on master help sign in
0.3.0.1
6fd4bd9Csongor Kiss
.gitignore+2
@@ -1,3 +1,5 @@
1tags
1tags
2dist*
2dist*
3.stack-work
3.stack-work
4+.cabal-sandbox
5+cabal.sandbox.config
generic-lens.cabal+1−1
@@ -1,5 +1,5 @@
1name: generic-lens
1name: generic-lens
2−version: 0.3.0.0
2+version: 0.3.0.1
3synopsis: Generic data-structure operations exposed as lenses.
3synopsis: Generic data-structure operations exposed as lenses.
4description: This package uses the GHC 8 Generic representation to derive various operations on data structures with a lens interface, including structural subtype relationship between records and positional indexing into arbitrary product types.
4description: This package uses the GHC 8 Generic representation to derive various operations on data structures with a lens interface, including structural subtype relationship between records and positional indexing into arbitrary product types.
5
5
src/Data/Generics/Internal/Families/Count.hs+5−7
@@ -21,8 +21,10 @@ module Data.Generics.Internal.Families.Count
21 ) where
21 ) where
22
22
23import GHC.Generics
23import GHC.Generics
24−import GHC.TypeLits
24+
25−import Data.Type.Bool (If)
25+import Data.Type.Bool (If)
26+import Data.Type.Equality (type (==))
27+import GHC.TypeLits (TypeError, ErrorMessage (..))
26
28
27import Data.Generics.Internal.HList
29import Data.Generics.Internal.HList
28
30
@@ -55,14 +57,10 @@ type family CountPartialType t f :: Count where
55 CountPartialType t (l :+: r)
57 CountPartialType t (l :+: r)
56 = CountPartialType t l <|> CountPartialType t r
58 = CountPartialType t l <|> CountPartialType t r
57 CountPartialType t (C1 m f)
59 CountPartialType t (C1 m f)
58− = If (Equals t (ListToTuple (GCollect f))) 'One 'None
60+ = If (t == ListToTuple (GCollect f)) 'One 'None
59 CountPartialType t (D1 _ f)
61 CountPartialType t (D1 _ f)
60 = CountPartialType t f
62 = CountPartialType t f
61
63
62−type family Equals a b where
63− Equals a a = 'True
64− Equals _ _ = 'False
65−
66data Count
64data Count
67 = None
65 = None
68 | One
66 | One
src/Data/Generics/Internal/Families/Has.hs+5−7
@@ -21,9 +21,11 @@ module Data.Generics.Internal.Families.Has
21 , HasCtorP
21 , HasCtorP
22 ) where
22 ) where
23
23
24−import Data.Type.Bool (type (||), type (&&))
25import GHC.Generics
24import GHC.Generics
25+
26+import Data.Type.Bool (type (||), type (&&))
27+import Data.Type.Equality (type (==))
26−import GHC.TypeLits
28+import GHC.TypeLits (Symbol, TypeError, ErrorMessage (..))
27
29
28import Data.Generics.Internal.HList
30import Data.Generics.Internal.HList
29
31
@@ -81,14 +83,10 @@ type family HasPartialTypeTupleP a f :: Bool where
81 HasPartialTypeTupleP t (l :+: r)
83 HasPartialTypeTupleP t (l :+: r)
82 = HasPartialTypeTupleP t l || HasPartialTypeTupleP t r
84 = HasPartialTypeTupleP t l || HasPartialTypeTupleP t r
83 HasPartialTypeTupleP t (C1 m f)
85 HasPartialTypeTupleP t (C1 m f)
84− = Equals t (ListToTuple (GCollect f))
86+ = t == ListToTuple (GCollect f)
85 HasPartialTypeTupleP t _
87 HasPartialTypeTupleP t _
86 = 'False
88 = 'False
87
89
88−type family Equals a b where
89− Equals a a = 'True
90− Equals _ _ = 'False
91−
92type family HasCtorP (ctor :: Symbol) f :: Bool where
90type family HasCtorP (ctor :: Symbol) f :: Bool where
93 HasCtorP ctor (C1 ('MetaCons ctor _ _) _)
91 HasCtorP ctor (C1 ('MetaCons ctor _ _) _)
94 = 'True
92 = 'True
src/Data/Generics/Internal/HList.hs+1−1
@@ -29,7 +29,7 @@ module Data.Generics.Internal.HList
29 , GCollectible (..)
29 , GCollectible (..)
30 ) where
30 ) where
31
31
32−import Data.Kind
32+import Data.Kind (Type)
33import GHC.Generics
33import GHC.Generics
34
34
35data HList (xs :: [Type]) where
35data HList (xs :: [Type]) where
src/Data/Generics/Internal/Lens.hs+1−1
@@ -18,7 +18,7 @@ module Data.Generics.Internal.Lens where
18import Control.Applicative (Const(..))
18import Control.Applicative (Const(..))
19import Data.Functor.Identity (Identity(..))
19import Data.Functor.Identity (Identity(..))
20import Data.Profunctor (Choice(right'), Profunctor(dimap))
20import Data.Profunctor (Choice(right'), Profunctor(dimap))
21−import GHC.Generics ((:*:)(..), Generic(..), K1(..), M1(..), Rep, (:+:)(..))
21+import GHC.Generics ((:*:)(..), (:+:)(..), Generic(..), K1(..), M1(..), Rep)
22
22
23-- | Type alias for lens
23-- | Type alias for lens
24type Lens' s a
24type Lens' s a
src/Data/Generics/Product/Fields.hs+2−2
@@ -36,9 +36,9 @@ module Data.Generics.Product.Fields
36import Data.Generics.Internal.Families
36import Data.Generics.Internal.Families
37import Data.Generics.Internal.Lens
37import Data.Generics.Internal.Lens
38
38
39−import Data.Kind
39+import Data.Kind (Constraint, Type)
40import GHC.Generics
40import GHC.Generics
41−import GHC.TypeLits
41+import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
42
42
43-- $example
43-- $example
44-- @
44-- @
src/Data/Generics/Product/Positions.hs+3−3
@@ -36,10 +36,10 @@ module Data.Generics.Product.Positions
36
36
37import Data.Generics.Internal.Lens
37import Data.Generics.Internal.Lens
38
38
39−import Data.Kind
39+import Data.Kind (Constraint, Type)
40−import Data.Type.Bool
40+import Data.Type.Bool (If, type (&&), Not)
41import GHC.Generics
41import GHC.Generics
42−import GHC.TypeLits
42+import GHC.TypeLits (type (<=?), type (+), Nat, TypeError, ErrorMessage(..))
43
43
44-- $example
44-- $example
45-- @
45-- @
src/Data/Generics/Product/Subtype.hs+1−1
@@ -57,7 +57,7 @@ import Data.Generics.Internal.Families
57import Data.Generics.Internal.Lens
57import Data.Generics.Internal.Lens
58import Data.Generics.Product.Fields
58import Data.Generics.Product.Fields
59
59
60−import Data.Kind
60+import Data.Kind (Type)
61import GHC.Generics
61import GHC.Generics
62
62
63-- |Structural subtype relationship
63-- |Structural subtype relationship
src/Data/Generics/Product/Typed.hs+2−2
@@ -36,9 +36,9 @@ module Data.Generics.Product.Typed
36import Data.Generics.Internal.Families
36import Data.Generics.Internal.Families
37import Data.Generics.Internal.Lens
37import Data.Generics.Internal.Lens
38
38
39−import Data.Kind
39+import Data.Kind (Constraint, Type)
40import GHC.Generics
40import GHC.Generics
41−import GHC.TypeLits
41+import GHC.TypeLits (TypeError, ErrorMessage (..))
42
42
43-- $example
43-- $example
44-- @
44-- @
src/Data/Generics/Sum/Constructors.hs+2−2
@@ -34,9 +34,9 @@ import Data.Generics.Internal.Families
34import Data.Generics.Internal.HList
34import Data.Generics.Internal.HList
35import Data.Generics.Internal.Lens
35import Data.Generics.Internal.Lens
36
36
37−import Data.Kind
37+import Data.Kind (Constraint, Type)
38import GHC.Generics
38import GHC.Generics
39−import GHC.TypeLits
39+import GHC.TypeLits (Symbol, TypeError, ErrorMessage (..))
40
40
41-- $example
41-- $example
42-- @
42-- @
src/Data/Generics/Sum/Typed.hs+4−4
@@ -36,14 +36,14 @@ module Data.Generics.Sum.Typed
36 , GAsType (..)
36 , GAsType (..)
37 ) where
37 ) where
38
38
39+import Data.Kind
40+import GHC.Generics
41+import GHC.TypeLits (TypeError, ErrorMessage (..))
42+
39import Data.Generics.Internal.Families
43import Data.Generics.Internal.Families
40import Data.Generics.Internal.HList
44import Data.Generics.Internal.HList
41import Data.Generics.Internal.Lens
45import Data.Generics.Internal.Lens
42
46
43−import Data.Kind
44−import GHC.Generics
45−import GHC.TypeLits
46−
47-- $example
47-- $example
48-- @
48-- @
49-- module Example where
49-- module Example where