on master help sign in
Fix inlining on 8.0.2
commit416fa8301b29217ea4b5ff45e38174163249183d authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateFri 29 Dec 2017, 12:40 (9 years ago) parent61d338f
4 files changed+44−2
src/Data/Generics/Internal/Families/Changing.hs+24 src/Data/Generics/Product/Fields.hs+7−1 src/Data/Generics/Product/Positions.hs+6 src/Data/Generics/Sum/Constructors.hs+7−1
src/Data/Generics/Internal/Families/Changing.hs+24
@@ -119,3 +119,27 @@ type family ReplaceArg (t :: k) (pos :: Peano) (to :: j) :: k where
119119type family ReplaceArgs (t :: k) (subs :: [Sub]) :: k where
120120 ReplaceArgs t '[] = t
121121 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 @@
11{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE ConstraintKinds #-}
34{-# LANGUAGE DataKinds #-}
45{-# LANGUAGE FlexibleInstances #-}
@@ -127,15 +128,20 @@ instance -- see Note [Changing type parameters]
127128 ( Generic s
128129 , ErrorUnless field s (CollectField field (Rep s))
129130 , Generic t
131+ -- see Note [CPP in instance constraints]
132+#if __GLASGOW_HASKELL__ < 802
133+ , '(s', t') ~ '(Proxied s, Proxied t)
134+#else
130135 , s' ~ Proxied s
131136 , t' ~ Proxied t
137+#endif
132138 , Generic s'
133139 , Generic t'
134140 , GHasField' field (Rep s) a
135141 , GHasField' field (Rep s') a'
142+ , GHasField' field (Rep t') b'
136143 , GHasField field (Rep s) (Rep t) a b
137144 , t ~ Infer s a' b
138− , GHasField' field (Rep t') b'
139145 , s ~ Infer t b' a
140146 ) => HasField field s t a b where
141147
src/Data/Generics/Product/Positions.hs+6
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE AllowAmbiguousTypes #-}
23{-# LANGUAGE ConstraintKinds #-}
34{-# LANGUAGE DataKinds #-}
@@ -99,8 +100,13 @@ instance -- see Note [Changing type parameters]
99100 ( Generic s
100101 , ErrorUnless i s (0 <? i && i <=? Size (Rep s))
101102 , Generic t
103+ -- see Note [CPP in instance constraints]
104+#if __GLASGOW_HASKELL__ < 802
105+ , '(s', t') ~ '(Proxied s, Proxied t)
106+#else
102107 , s' ~ Proxied s
103108 , t' ~ Proxied t
109+#endif
104110 , Generic s'
105111 , Generic t'
106112 , GHasPosition' i (Rep s) a
src/Data/Generics/Sum/Constructors.hs+7−1
@@ -1,4 +1,5 @@
11{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE DataKinds #-}
34{-# LANGUAGE FlexibleInstances #-}
45{-# LANGUAGE FunctionalDependencies #-}
@@ -102,8 +103,13 @@ instance
102103 ( Generic s
103104 , ErrorUnless ctor s (HasCtorP ctor (Rep s))
104105 , Generic t
106+ -- see Note [CPP in instance constraints]
107+#if __GLASGOW_HASKELL__ < 802
108+ , '(s', t') ~ '(Proxied s, Proxied t)
109+#else
105110 , s' ~ Proxied s
106− , t' ~ Proxied s
111+ , t' ~ Proxied t
112+#endif
107113 , Generic s'
108114 , Generic t'
109115 , GAsConstructor' ctor (Rep s) a