on master help sign in
Hide equality constraints (hack)

Inlining was still broken on 8.0.2, hopefully this hack fixes it.

commit238b01d36061ffc2e81f83bfacdbbba1d3ed9f04 authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateSat 1 Sep 2018, 23:40 (8 years ago) parentae45fc5
2 files changed+20−10
src/Data/Generics/Product/Fields.hs+9−5 src/Data/Generics/Product/Positions.hs+11−5
src/Data/Generics/Product/Fields.hs+9−5
@@ -133,15 +133,19 @@ instance
133133 ) => HasField' field s a where
134134 field' f s = VL.ravel (repLens . glens @(HasTotalFieldPSym field)) f s
135135
136+class (~~) a b | a -> b, b -> a
137+instance (a ~ b) => (~~) a b
138+
136139instance -- see Note [Changing type parameters]
137140 ( Generic s
138141 , Generic t
139142 , ErrorUnless field s (CollectField field (Rep s))
140− , HasTotalFieldP field (Rep s) ~ 'Just a
141− , HasTotalFieldP field (Rep (Indexed s)) ~ 'Just a'
142− , HasTotalFieldP field (Rep (Indexed t)) ~ 'Just b'
143− , t ~ Infer s a' b
144− , s ~ Infer t b' a
143+ , HasTotalFieldP field (Rep s) ~~ 'Just a
144+ , HasTotalFieldP field (Rep t) ~~ 'Just b
145+ , HasTotalFieldP field (Rep (Indexed s)) ~~ 'Just a'
146+ , HasTotalFieldP field (Rep (Indexed t)) ~~ 'Just b'
147+ , t ~~ Infer s a' b
148+ , s ~~ Infer t b' a
145149 , GLens (HasTotalFieldPSym field) (Rep s) (Rep t) a b
146150 ) => HasField field s t a b where
147151 field f s = VL.ravel (repLens . glens @(HasTotalFieldPSym field)) f s
src/Data/Generics/Product/Positions.hs+11−5
@@ -112,16 +112,22 @@ instance
112112 position' f s = VL.ravel (repLens . coerced @cs @cs . glens @(HasTotalPositionPSym i)) f s
113113 {-# INLINE position' #-}
114114
115+-- this is to 'hide' the equality constraints which interfere with inlining
116+-- pre 8.4.3
117+class (~~) a b | a -> b, b -> a
118+instance (a ~ b) => (~~) a b
119+
115120instance -- see Note [Changing type parameters]
116121 ( Generic s
117122 , Generic t
118123 , ErrorUnless i s (0 <? i && i <=? Size (Rep s))
119124 , GLens (HasTotalPositionPSym i) (CRep s) (CRep t) a b
120− , HasTotalPositionP i (CRep s) ~ 'Just a
121− , HasTotalPositionP i (CRep (Indexed s)) ~ 'Just a'
122− , HasTotalPositionP i (CRep (Indexed t)) ~ 'Just b'
123− , t ~ Infer s a' b
124− , s ~ Infer t b' a
125+ , HasTotalPositionP i (CRep s) ~~ 'Just a
126+ , HasTotalPositionP i (CRep t) ~~ 'Just b
127+ , HasTotalPositionP i (CRep (Indexed s)) ~~ 'Just a'
128+ , HasTotalPositionP i (CRep (Indexed t)) ~~ 'Just b'
129+ , t ~~ Infer s a' b
130+ , s ~~ Infer t b' a
125131 , Coercible (CRep s) (Rep s)
126132 , Coercible (CRep t) (Rep t)
127133 ) => HasPosition i s t a b where