on master help sign in
Fix optimisation on 8.4.1 (#43)
b642151Csongor Kiss
src/Data/Generics/Sum/Constructors.hs+2−2
@@ -112,7 +112,7 @@ instance
112 , GAsConstructor' ctor (Rep s) a
112 , GAsConstructor' ctor (Rep s) a
113 ) => AsConstructor' ctor s a where
113 ) => AsConstructor' ctor s a where
114 _Ctor' eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
114 _Ctor' eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
115− {-# INLINE _Ctor' #-}
115+ {-# INLINE[2] _Ctor' #-}
116
116
117instance
117instance
118 ( Generic s
118 ( Generic s
@@ -136,7 +136,7 @@ instance
136 ) => AsConstructor ctor s t a b where
136 ) => AsConstructor ctor s t a b where
137
137
138 _Ctor eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
138 _Ctor eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
139− {-# INLINE _Ctor #-}
139+ {-# INLINE[2] _Ctor #-}
140
140
141-- See Note [Uncluttering type signatures]
141-- See Note [Uncluttering type signatures]
142instance {-# OVERLAPPING #-} AsConstructor ctor (Void1 a) (Void1 b) a b where
142instance {-# OVERLAPPING #-} AsConstructor ctor (Void1 a) (Void1 b) a b where
src/Data/Generics/Sum/Internal/Constructors.hs+5−5
@@ -54,24 +54,24 @@ instance
54 ) => GAsConstructor ctor (M1 C ('MetaCons ctor fixity fields) f) (M1 C ('MetaCons ctor fixity fields) g) a b where
54 ) => GAsConstructor ctor (M1 C ('MetaCons ctor fixity fields) f) (M1 C ('MetaCons ctor fixity fields) g) a b where
55
55
56 _GCtor = prism (M1 . view (fromIso (glist @Type)) . tupleToList) (Right . listToTuple . view (glist @Type) . unM1)
56 _GCtor = prism (M1 . view (fromIso (glist @Type)) . tupleToList) (Right . listToTuple . view (glist @Type) . unM1)
57− {-# INLINE _GCtor #-}
57+ {-# INLINE[0] _GCtor #-}
58
58
59
59
60instance GSumAsConstructor ctor (HasCtorP ctor l) l r l' r' a b => GAsConstructor ctor (l :+: r) (l' :+: r') a b where
60instance GSumAsConstructor ctor (HasCtorP ctor l) l r l' r' a b => GAsConstructor ctor (l :+: r) (l' :+: r') a b where
61 _GCtor = _GSumCtor @ctor @(HasCtorP ctor l)
61 _GCtor = _GSumCtor @ctor @(HasCtorP ctor l)
62− {-# INLINE _GCtor #-}
62+ {-# INLINE[0] _GCtor #-}
63
63
64instance GAsConstructor ctor f f' a b => GAsConstructor ctor (M1 D meta f) (M1 D meta f') a b where
64instance GAsConstructor ctor f f' a b => GAsConstructor ctor (M1 D meta f) (M1 D meta f') a b where
65 _GCtor = mIso . _GCtor @ctor
65 _GCtor = mIso . _GCtor @ctor
66− {-# INLINE _GCtor #-}
66+ {-# INLINE[0] _GCtor #-}
67
67
68class GSumAsConstructor (ctor :: Symbol) (contains :: Bool) l r l' r' a b | ctor l r -> a, ctor l' r' -> b where
68class GSumAsConstructor (ctor :: Symbol) (contains :: Bool) l r l' r' a b | ctor l r -> a, ctor l' r' -> b where
69 _GSumCtor :: Prism ((l :+: r) x) ((l' :+: r') x) a b
69 _GSumCtor :: Prism ((l :+: r) x) ((l' :+: r') x) a b
70
70
71instance GAsConstructor ctor l l' a b => GSumAsConstructor ctor 'True l r l' r a b where
71instance GAsConstructor ctor l l' a b => GSumAsConstructor ctor 'True l r l' r a b where
72 _GSumCtor = left . _GCtor @ctor
72 _GSumCtor = left . _GCtor @ctor
73− {-# INLINE _GSumCtor #-}
73+ {-# INLINE[0] _GSumCtor #-}
74
74
75instance GAsConstructor ctor r r' a b => GSumAsConstructor ctor 'False l r l r' a b where
75instance GAsConstructor ctor r r' a b => GSumAsConstructor ctor 'False l r l r' a b where
76 _GSumCtor = right . _GCtor @ctor
76 _GSumCtor = right . _GCtor @ctor
77− {-# INLINE _GSumCtor #-}
77+ {-# INLINE[0] _GSumCtor #-}
src/Data/Generics/Sum/Internal/Subtype.hs+8−1
@@ -57,15 +57,18 @@ class GSplash (sub :: Type -> Type) (sup :: Type -> Type) where
57instance (GSplash a sup, GSplash b sup) => GSplash (a :+: b) sup where
57instance (GSplash a sup, GSplash b sup) => GSplash (a :+: b) sup where
58 _GSplash (L1 rep) = _GSplash rep
58 _GSplash (L1 rep) = _GSplash rep
59 _GSplash (R1 rep) = _GSplash rep
59 _GSplash (R1 rep) = _GSplash rep
60+ {-# INLINE[0] _GSplash #-}
60
61
61instance
62instance
62 ( GIsList () subf subf as as
63 ( GIsList () subf subf as as
63 , GAsType supf as
64 , GAsType supf as
64 ) => GSplash (C1 meta subf) supf where
65 ) => GSplash (C1 meta subf) supf where
65 _GSplash p = build ((_GTyped . fromIso (glist @()) . fromIso mIso)) p
66 _GSplash p = build ((_GTyped . fromIso (glist @()) . fromIso mIso)) p
67+ {-# INLINE[0] _GSplash #-}
66
68
67instance GSplash sub sup => GSplash (D1 c sub) sup where
69instance GSplash sub sup => GSplash (D1 c sub) sup where
68 _GSplash (M1 m) = _GSplash m
70 _GSplash (M1 m) = _GSplash m
71+ {-# INLINE[0] _GSplash #-}
69
72
70--------------------------------------------------------------------------------
73--------------------------------------------------------------------------------
71
74
@@ -79,6 +82,7 @@ instance
79 _GDowncast (M1 m) = case _GDowncastC @(HasPartialTypeP as sub) m of
82 _GDowncast (M1 m) = case _GDowncastC @(HasPartialTypeP as sub) m of
80 Left _ -> Left (M1 m)
83 Left _ -> Left (M1 m)
81 Right r -> Right r
84 Right r -> Right r
85+ {-# INLINE[0] _GDowncast #-}
82
86
83instance (GDowncast sub l, GDowncast sub r) => GDowncast sub (l :+: r) where
87instance (GDowncast sub l, GDowncast sub r) => GDowncast sub (l :+: r) where
84 _GDowncast (L1 x) = case _GDowncast x of
88 _GDowncast (L1 x) = case _GDowncast x of
@@ -87,22 +91,25 @@ instance (GDowncast sub l, GDowncast sub r) => GDowncast sub (l :+: r) where
87 _GDowncast (R1 x) = case _GDowncast x of
91 _GDowncast (R1 x) = case _GDowncast x of
88 Left _ -> Left (R1 x)
92 Left _ -> Left (R1 x)
89 Right r -> Right r
93 Right r -> Right r
94+ {-# INLINE[0] _GDowncast #-}
90
95
91instance GDowncast sub sup => GDowncast sub (D1 m sup) where
96instance GDowncast sub sup => GDowncast sub (D1 m sup) where
92 _GDowncast (M1 m) = case _GDowncast m of
97 _GDowncast (M1 m) = case _GDowncast m of
93 Left _ -> Left (M1 m)
98 Left _ -> Left (M1 m)
94 Right r -> Right r
99 Right r -> Right r
100+ {-# INLINE[0] _GDowncast #-}
95
101
96class GDowncastC (contains :: Bool) sub sup where
102class GDowncastC (contains :: Bool) sub sup where
97 _GDowncastC :: sup x -> Either (sup x) (sub x)
103 _GDowncastC :: sup x -> Either (sup x) (sub x)
98
104
99instance GDowncastC 'False sub sup where
105instance GDowncastC 'False sub sup where
100 _GDowncastC sup = Left sup
106 _GDowncastC sup = Left sup
107+ {-# INLINE[0] _GDowncastC #-}
101
108
102instance
109instance
103 ( GAsType sub subl
110 ( GAsType sub subl
104 , GIsList () sup sup subl subl
111 , GIsList () sup sup subl subl
105 ) => GDowncastC 'True sub sup where
112 ) => GDowncastC 'True sub sup where
106 _GDowncastC sup = Right (build (_GTyped . fromIso (glist @())) sup)
113 _GDowncastC sup = Right (build (_GTyped . fromIso (glist @())) sup)
107− {-# INLINE _GDowncastC #-}
114+ {-# INLINE[0] _GDowncastC #-}
108
115
src/Data/Generics/Sum/Internal/Typed.hs+5
@@ -50,18 +50,23 @@ instance
50 ( GIsList () f f as as
50 ( GIsList () f f as as
51 ) => GAsType (M1 C meta f) as where
51 ) => GAsType (M1 C meta f) as where
52 _GTyped = mIso . glist @()
52 _GTyped = mIso . glist @()
53+ {-# INLINE[0] _GTyped #-}
53
54
54instance GSumAsType (HasPartialTypeP a l) l r a => GAsType (l :+: r) a where
55instance GSumAsType (HasPartialTypeP a l) l r a => GAsType (l :+: r) a where
55 _GTyped = _GSumTyped @(HasPartialTypeP a l)
56 _GTyped = _GSumTyped @(HasPartialTypeP a l)
57+ {-# INLINE[0] _GTyped #-}
56
58
57instance GAsType f a => GAsType (M1 D meta f) a where
59instance GAsType f a => GAsType (M1 D meta f) a where
58 _GTyped = mIso . _GTyped
60 _GTyped = mIso . _GTyped
61+ {-# INLINE[0] _GTyped #-}
59
62
60class GSumAsType (contains :: Bool) l r (a :: [((), Type)]) where
63class GSumAsType (contains :: Bool) l r (a :: [((), Type)]) where
61 _GSumTyped :: Prism ((l :+: r) x) ((l :+: r) x) (List a) (List a)
64 _GSumTyped :: Prism ((l :+: r) x) ((l :+: r) x) (List a) (List a)
62
65
63instance GAsType l a => GSumAsType 'True l r a where
66instance GAsType l a => GSumAsType 'True l r a where
64 _GSumTyped = left . _GTyped
67 _GSumTyped = left . _GTyped
68+ {-# INLINE[0] _GSumTyped #-}
65
69
66instance GAsType r a => GSumAsType 'False l r a where
70instance GAsType r a => GSumAsType 'False l r a where
67 _GSumTyped = right . _GTyped
71 _GSumTyped = right . _GTyped
72+ {-# INLINE[0] _GSumTyped #-}
src/Data/Generics/Sum/Subtype.hs+1
@@ -90,6 +90,7 @@ class AsSubtype sub sup where
90 -- Nothing
90 -- Nothing
91 _Sub :: Prism' sup sub
91 _Sub :: Prism' sup sub
92 _Sub = prism injectSub (\i -> maybe (Left i) Right (projectSub i))
92 _Sub = prism injectSub (\i -> maybe (Left i) Right (projectSub i))
93+ {-# INLINE[2] _Sub #-}
93
94
94 -- |Injects a subtype into a supertype (upcast).
95 -- |Injects a subtype into a supertype (upcast).
95 injectSub :: sub -> sup
96 injectSub :: sub -> sup
src/Data/Generics/Sum/Typed.hs+2−1
@@ -89,6 +89,7 @@ class AsType a s where
89 -- ...
89 -- ...
90 _Typed :: Prism' s a
90 _Typed :: Prism' s a
91 _Typed = prism injectTyped (\i -> maybe (Left i) Right (projectTyped i))
91 _Typed = prism injectTyped (\i -> maybe (Left i) Right (projectTyped i))
92+ {-# INLINE[2] _Typed #-}
92
93
93 -- |Inject by type.
94 -- |Inject by type.
94 injectTyped :: a -> s
95 injectTyped :: a -> s
@@ -111,7 +112,7 @@ instance
111 ) => AsType a s where
112 ) => AsType a s where
112
113
113 _Typed eta = prismRavel (prismPRavel (repIso . _GTyped @_ @as . tupled)) eta
114 _Typed eta = prismRavel (prismPRavel (repIso . _GTyped @_ @as . tupled)) eta
114− {-# INLINE _Typed #-}
115+ {-# INLINE[2] _Typed #-}
115
116
116-- See Note [Uncluttering type signatures]
117-- See Note [Uncluttering type signatures]
117instance {-# OVERLAPPING #-} AsType a Void where
118instance {-# OVERLAPPING #-} AsType a Void where