on master help sign in
More inlining
9d943c2Csongor Kiss
src/Data/Generics/Internal/Profunctor/Lens.hs+6
@@ -41,6 +41,12 @@ type LensLike p s t a b
41s ^. l = getConst (l Const s)
41s ^. l = getConst (l Const s)
42infixl 8 ^.
42infixl 8 ^.
43
43
44+ravel :: (ALens a b a b -> ALens a b s t) -> Lens s t a b
45+ravel l pab = conv (l idLens) pab
46+ where
47+ conv :: ALens a b s t -> Lens s t a b
48+ conv (ALens _get _set) = lens _get _set
49+
44-- | Setting
50-- | Setting
45set :: ((a -> b) -> s -> t) -> (s, b) -> t
51set :: ((a -> b) -> s -> t) -> (s, b) -> t
46set f (s, b)
52set f (s, b)
src/Data/Generics/Product/Fields.hs+2−2
@@ -45,7 +45,7 @@ import Data.Generics.Product.Internal.Keyed
45import Data.Kind (Constraint, Type)
45import Data.Kind (Constraint, Type)
46import GHC.Generics
46import GHC.Generics
47import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
47import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
48−import Data.Generics.Internal.Profunctor.Lens
48+import Data.Generics.Internal.Profunctor.Lens as P
49
49
50-- $setup
50-- $setup
51-- == /Running example:/
51-- == /Running example:/
@@ -146,7 +146,7 @@ instance -- see Note [Changing type parameters]
146 , s ~ Infer t b' a
146 , s ~ Infer t b' a
147 ) => HasField field s t a b where
147 ) => HasField field s t a b where
148
148
149− field f s = ravel (repLens . gkey @field) f s
149+ field f s = VL.ravel (repLens . gkey @field) f s
150
150
151-- -- See Note [Uncluttering type signatures]
151-- -- See Note [Uncluttering type signatures]
152instance {-# OVERLAPPING #-} HasField f (Void1 a) (Void1 b) a b where
152instance {-# OVERLAPPING #-} HasField f (Void1 a) (Void1 b) a b where
src/Data/Generics/Product/Internal/Keyed.hs+5−3
@@ -39,9 +39,11 @@ type GHasKey' key s a = GHasKey key s s a a
39
39
40instance (GHasKey key l l' a b, GHasKey key r r' a b) => GHasKey key (l :+: r) (l' :+: r') a b where
40instance (GHasKey key l l' a b, GHasKey key r r' a b) => GHasKey key (l :+: r) (l' :+: r') a b where
41 gkey = sumIso . choosing (gkey @key) (gkey @key)
41 gkey = sumIso . choosing (gkey @key) (gkey @key)
42+ {-# INLINE gkey #-}
42
43
43instance (GHasKey key f g a b) => GHasKey key (M1 D meta f) (M1 D meta g) a b where
44instance (GHasKey key f g a b) => GHasKey key (M1 D meta f) (M1 D meta g) a b where
44− gkey = mLens . gkey @key
45+ gkey = ravel (mLens . gkey @key)
46+ {-# INLINE gkey #-}
45
47
46instance
48instance
47 ( Elem as key i a
49 ( Elem as key i a
@@ -49,5 +51,5 @@ instance
49 , IndexList i as bs a b
51 , IndexList i as bs a b
50 , GIsList k f g as bs
52 , GIsList k f g as bs
51 ) => GHasKey (key :: k) (M1 C meta f) (M1 C meta g) a b where
53 ) => GHasKey (key :: k) (M1 C meta f) (M1 C meta g) a b where
52− gkey = mIso . glist @k . point @i
54+ gkey = mLens . glist @k . point @i
53−
55+ {-# INLINE gkey #-}
src/Data/Generics/Product/Internal/List.hs+1−1
@@ -121,7 +121,7 @@ class Appending f (as :: [k]) bs cs (as' :: [k]) bs' cs' | as bs cs cs' -> as' b
121 appending :: Iso (f as, f bs) (f as', f bs') (f cs) (f cs')
121 appending :: Iso (f as, f bs) (f as', f bs') (f cs) (f cs')
122
122
123instance Appending List '[] bs bs '[] bs' bs' where
123instance Appending List '[] bs bs '[] bs' bs' where
124− appending = iso snd (Nil,)
124+ appending = iso (\(_, b) -> b) (Nil,)
125
125
126instance Appending List as bs cs as' bs' cs'
126instance Appending List as bs cs as' bs' cs'
127 => Appending List ('(f, a) ': as) bs ('(f, a) ': cs) ('(f, a') ': as') bs' ('(f, a') ': cs') where
127 => Appending List ('(f, a) ': as) bs ('(f, a) ': cs) ('(f, a') ': as') bs' ('(f, a') ': cs') where
src/Data/Generics/Product/Internal/Positions.hs+1−1
@@ -58,7 +58,7 @@ instance
58 ( IndexList (i - 1) as bs a b
58 ( IndexList (i - 1) as bs a b
59 , GIsList () f g as bs
59 , GIsList () f g as bs
60 ) => GHasPosition i (M1 C meta f) (M1 C meta g) a b where
60 ) => GHasPosition i (M1 C meta f) (M1 C meta g) a b where
61− gposition = mIso . glist @() . point @(i - 1)
61+ gposition = ravel (mIso . glist @() . point @(i - 1))
62
62
63type family Size f :: Nat where
63type family Size f :: Nat where
64 Size (l :*: r)
64 Size (l :*: r)
src/Data/Generics/Product/Positions.hs+1−1
@@ -118,7 +118,7 @@ instance -- see Note [Changing type parameters]
118 , s ~ Infer t b' a
118 , s ~ Infer t b' a
119 ) => HasPosition i s t a b where
119 ) => HasPosition i s t a b where
120
120
121− position f s = ravel (repLens . gposition @i) f s
121+ position f s = VL.ravel (repLens . gposition @i) f s
122
122
123-- See Note [Uncluttering type signatures]
123-- See Note [Uncluttering type signatures]
124instance {-# OVERLAPPING #-} HasPosition f (Void1 a) (Void1 b) a b where
124instance {-# OVERLAPPING #-} HasPosition f (Void1 a) (Void1 b) a b where
src/Data/Generics/Product/Typed.hs+1−1
@@ -112,7 +112,7 @@ instance
112 , GHasKey a (Rep s) (Rep s) a a
112 , GHasKey a (Rep s) (Rep s) a a
113 ) => HasType a s where
113 ) => HasType a s where
114
114
115− typed = ravel (repLens . gkey @a)
115+ typed f s = VL.ravel (repLens . gkey @a) f s
116
116
117-- See Note [Uncluttering type signatures]
117-- See Note [Uncluttering type signatures]
118instance {-# OVERLAPPING #-} HasType a Void where
118instance {-# OVERLAPPING #-} HasType a Void where