on master help sign in
Fix inlining on 8.0.2
416fa83Csongor Kiss
src/Data/Generics/Internal/Families/Changing.hs+24
@@ -119,3 +119,27 @@ type family ReplaceArg (t :: k) (pos :: Peano) (to :: j) :: k where
119type family ReplaceArgs (t :: k) (subs :: [Sub]) :: k where
119type family ReplaceArgs (t :: k) (subs :: [Sub]) :: k where
120 ReplaceArgs t '[] = t
120 ReplaceArgs t '[] = t
121 ReplaceArgs t ('Sub n arg ': ss) = ReplaceArgs (ReplaceArg t n arg) ss
121 ReplaceArgs t ('Sub n arg ': ss) = ReplaceArgs (ReplaceArg t n arg) ss
122+
123+-- Note [CPP in instance constraints]
124+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125+--
126+-- In GHC 8.0.2, the calculated size of the expressions is too large for the
127+-- inliner to consider them under the default -funfolding-use-threshold value
128+-- (60).
129+--
130+-- To reduce the size, the constraints
131+--
132+-- ```
133+-- s' ~ Proxied s
134+-- t' ~ Proxied t
135+-- ```
136+--
137+-- are written as the following single equality:
138+--
139+-- ```
140+-- '(s', t') ~ '(Proxied s, Proxied t)
141+-- ```
142+--
143+-- However, for some reason, this violates the functional dependencies on 8.2.2.
144+-- Therefore, when using a newer version of the compiler, the original constraints
145+-- are used, as the expression size is smaller under 8.2.2.
src/Data/Generics/Product/Fields.hs+7−1
@@ -1,4 +1,5 @@
1{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
@@ -127,15 +128,20 @@ instance -- see Note [Changing type parameters]
127 ( Generic s
128 ( Generic s
128 , ErrorUnless field s (CollectField field (Rep s))
129 , ErrorUnless field s (CollectField field (Rep s))
129 , Generic t
130 , Generic t
131+ -- see Note [CPP in instance constraints]
132+#if __GLASGOW_HASKELL__ < 802
133+ , '(s', t') ~ '(Proxied s, Proxied t)
134+#else
130 , s' ~ Proxied s
135 , s' ~ Proxied s
131 , t' ~ Proxied t
136 , t' ~ Proxied t
137+#endif
132 , Generic s'
138 , Generic s'
133 , Generic t'
139 , Generic t'
134 , GHasField' field (Rep s) a
140 , GHasField' field (Rep s) a
135 , GHasField' field (Rep s') a'
141 , GHasField' field (Rep s') a'
142+ , GHasField' field (Rep t') b'
136 , GHasField field (Rep s) (Rep t) a b
143 , GHasField field (Rep s) (Rep t) a b
137 , t ~ Infer s a' b
144 , t ~ Infer s a' b
138− , GHasField' field (Rep t') b'
139 , s ~ Infer t b' a
145 , s ~ Infer t b' a
140 ) => HasField field s t a b where
146 ) => HasField field s t a b where
141
147
src/Data/Generics/Product/Positions.hs+6
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
@@ -99,8 +100,13 @@ instance -- see Note [Changing type parameters]
99 ( Generic s
100 ( Generic s
100 , ErrorUnless i s (0 <? i && i <=? Size (Rep s))
101 , ErrorUnless i s (0 <? i && i <=? Size (Rep s))
101 , Generic t
102 , Generic t
103+ -- see Note [CPP in instance constraints]
104+#if __GLASGOW_HASKELL__ < 802
105+ , '(s', t') ~ '(Proxied s, Proxied t)
106+#else
102 , s' ~ Proxied s
107 , s' ~ Proxied s
103 , t' ~ Proxied t
108 , t' ~ Proxied t
109+#endif
104 , Generic s'
110 , Generic s'
105 , Generic t'
111 , Generic t'
106 , GHasPosition' i (Rep s) a
112 , GHasPosition' i (Rep s) a
src/Data/Generics/Sum/Constructors.hs+7−1
@@ -1,4 +1,5 @@
1{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE CPP #-}
2{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FunctionalDependencies #-}
5{-# LANGUAGE FunctionalDependencies #-}
@@ -102,8 +103,13 @@ instance
102 ( Generic s
103 ( Generic s
103 , ErrorUnless ctor s (HasCtorP ctor (Rep s))
104 , ErrorUnless ctor s (HasCtorP ctor (Rep s))
104 , Generic t
105 , Generic t
106+ -- see Note [CPP in instance constraints]
107+#if __GLASGOW_HASKELL__ < 802
108+ , '(s', t') ~ '(Proxied s, Proxied t)
109+#else
105 , s' ~ Proxied s
110 , s' ~ Proxied s
106− , t' ~ Proxied s
111+ , t' ~ Proxied t
112+#endif
107 , Generic s'
113 , Generic s'
108 , Generic t'
114 , Generic t'
109 , GAsConstructor' ctor (Rep s) a
115 , GAsConstructor' ctor (Rep s) a