Skip to content

Commit fd71b08

Browse files
authored
Add INLINABLE to a bunch of stuff (#81)
Everything that `-Wall-missed-specialisations` complains about that we have control over.
2 parents db3673d + a002084 commit fd71b08

File tree

13 files changed

+18
-12
lines changed

13 files changed

+18
-12
lines changed

containers/yaya-containers.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ common defaults
141141
base ^>= {4.13.0, 4.14.0, 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.19.0, 4.20.0, 4.21.0, 4.22.0},
142142
ghc-options:
143143
-Weverything
144-
-- This one just reports unfixable things, AFAICT.
145-
-Wno-all-missed-specialisations
146144
-- Type inference good.
147145
-Wno-missing-local-signatures
148146
-- Warns even when `Unsafe` is explicit, not inferred. See

core/src/Yaya/Fold.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ recursiveShowsPrec' showsFPrec = flip . cata $
298298
\f p ->
299299
showParen (appPrec1 <= p) $
300300
showString embedOperation . showString " " . showsFPrec f appPrec1
301+
{-# INLINEABLE recursiveShowsPrec' #-}
301302

302303
-- | An implementation of `showsPrec` for any `Recursive` instance.
303304
#if MIN_VERSION_GLASGOW_HASKELL(8, 8, 0, 0) \
@@ -335,6 +336,7 @@ recursiveShowsPrec' showsFPrec = flip . cata $
335336
-- `steppableReadPrec`, which requires `Steppable` instead.
336337
recursiveShowsPrec :: (Recursive (->) t f, Show1 f) => Int -> t -> ShowS
337338
recursiveShowsPrec = recursiveShowsPrec' $ flip showsPrecF
339+
{-# INLINEABLE recursiveShowsPrec #-}
338340

339341
-- | Like `steppableReadPrec`, but allows you to provide a custom display
340342
-- function for @f@.
@@ -374,6 +376,7 @@ newtype Mu f = Mu (forall a. Algebra (->) f a -> a)
374376

375377
instance (Functor f) => Projectable (->) (Mu f) f where
376378
project = lambek
379+
{-# INLINEABLE project #-}
377380

378381
instance (Functor f) => Steppable (->) (Mu f) f where
379382
embed m = Mu (\f -> f (fmap (cata f) m))
@@ -386,6 +389,7 @@ instance DFunctor Mu where
386389

387390
instance (Functor f, Foldable f, Eq1 f) => Eq (Mu f) where
388391
(==) = recursiveEq
392+
{-# INLINEABLE (==) #-}
389393

390394
-- | @since 0.6.1.0
391395
instance (Functor f, Foldable f, Ord1 f) => Ord (Mu f) where
@@ -405,9 +409,11 @@ data Nu f where Nu :: Coalgebra (->) f a -> a -> Nu f
405409

406410
instance (Functor f) => Projectable (->) (Nu f) f where
407411
project (Nu f a) = Nu f <$> f a
412+
{-# INLINEABLE project #-}
408413

409414
instance (Functor f) => Steppable (->) (Nu f) f where
410415
embed = colambek
416+
{-# INLINEABLE embed #-}
411417

412418
instance Corecursive (->) (Nu f) f where
413419
ana = Nu

core/src/Yaya/Fold/Common.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ equalDay ::
8686
equalDay eqF (Day f1 f2 fn) =
8787
eqF (void f1) (void f2)
8888
&& and (zipWith fn (toList f1) (toList f2))
89+
{-# INLINEABLE equalDay #-}
8990

9091
-- | Provides equality over arbitrary pattern functors.
9192
equal :: (Functor f, Foldable f, Eq1 f) => Day f f Bool -> Bool
@@ -102,6 +103,7 @@ compareDay ::
102103
compareDay compareF (Day f1 f2 fn) =
103104
compareF (void f1) (void f2)
104105
<> fold (zipWith fn (toList f1) (toList f2))
106+
{-# INLINEABLE compareDay #-}
105107

106108
-- | Provides show over arbitrary pattern functors.
107109
--

core/src/Yaya/Fold/Native.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ instance Steppable (->) (Fix f) f where
5959

6060
instance (Functor f) => Recursive (->) (Fix f) f where
6161
cata ɸ = ɸ . fmap (cata ɸ) . project
62+
{-# INLINEABLE cata #-}
6263

6364
instance (Functor f, Foldable f, Eq1 f) => Eq (Fix f) where
6465
(==) = recursiveEq

core/src/Yaya/Fold/Native/Internal.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ instance Steppable (->) (Cofix f) f where
4040

4141
instance (Functor f) => Corecursive (->) (Cofix f) f where
4242
ana φ = embed . fmap (ana φ) . φ
43+
{-# INLINEABLE ana #-}
4344

4445
-- | @since 0.6.1.0
4546
instance (Read1 f) => Read (Cofix f) where

core/yaya.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ common defaults
147147
base ^>= {4.13.0, 4.14.0, 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.19.0, 4.20.0, 4.21.0, 4.22.0},
148148
ghc-options:
149149
-Weverything
150-
-- This one just reports unfixable things, AFAICT.
151-
-Wno-all-missed-specialisations
152150
-- Type inference good.
153151
-Wno-missing-local-signatures
154152
-- Warns even when `Unsafe` is explicit, not inferred. See

hedgehog/src/Yaya/Hedgehog.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ evalNonterminating ::
2525
evalNonterminating =
2626
maybe HH.success (const HH.failure <=< HH.annotateShow)
2727
<=< HH.evalIO . timeout 1_000_000 . evaluate
28+
{-# INLINEABLE evalNonterminating #-}
2829

2930
-- | Returns success if the expression doesn’t terminate, failure otherwise.
3031
-- The value passed here should termina

hedgehog/src/Yaya/Hedgehog/Fold.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ law_cataCompose Proxy φ ε =
110110
uncurry (===)
111111
. bimap (cata φ . cata (embed . ε :: f u -> u)) (cata (φ . ε))
112112
. diagonal
113+
{-# INLINEABLE law_cataCompose #-}
113114

114115
-- | Creates a generator for any `Steppable` type whose pattern functor has
115116
-- terminal cases (e.g., not `Data.Functor.Identity` or `((,) a)`). @leaf@ can
@@ -153,6 +154,7 @@ genAlgebra ::
153154
Algebra (->) Maybe (Gen t)
154155
genAlgebra leaf branch =
155156
maybe (fmap (embed . fmap absurd) leaf) (fmap embed . branch)
157+
{-# INLINEABLE genAlgebra #-}
156158

157159
-- | Creates a generator for potentially-infinite values.
158160
genCorecursive :: (Corecursive (->) t f) => (a -> f a) -> Gen a -> Gen t
@@ -178,6 +180,7 @@ corecursiveIsUnsafe Proxy x =
178180
evalNonterminating . fst . project @_ @(t (Pair a)) $ ana (\y -> y :!: y) x
179181
-- but using a lazy functor loses this property
180182
Tuple.fst (project @_ @(t ((,) a)) $ ana (\y -> (y, y)) x) === x
183+
{-# INLINEABLE corecursiveIsUnsafe #-}
181184

182185
-- | Show that using a `Corecursive` structure recursively can lead to
183186
-- non-termination.
@@ -203,3 +206,4 @@ recursiveIsUnsafe Proxy x =
203206
-- But again, if you use a lazy functor, you lose that property, and you can
204207
-- short-circuit.
205208
cata Tuple.fst (ana @_ @(t ((,) a)) (\y -> (y, y)) x) === x
209+
{-# INLINEABLE recursiveIsUnsafe #-}

hedgehog/yaya-hedgehog.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ common defaults
144144
base ^>= {4.13.0, 4.14.0, 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.19.0, 4.20.0, 4.21.0, 4.22.0},
145145
ghc-options:
146146
-Weverything
147-
-- This one just reports unfixable things, AFAICT.
148-
-Wno-all-missed-specialisations
149147
-- Type inference good.
150148
-Wno-missing-local-signatures
151149
-- Warns even when `Unsafe` is explicit, not inferred. See

lens/yaya-lens.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ common defaults
147147
base ^>= {4.13.0, 4.14.0, 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.19.0, 4.20.0, 4.21.0, 4.22.0},
148148
ghc-options:
149149
-Weverything
150-
-- This one just reports unfixable things, AFAICT.
151-
-Wno-all-missed-specialisations
152150
-- Type inference good.
153151
-Wno-missing-local-signatures
154152
-- Warns even when `Unsafe` is explicit, not inferred. See

0 commit comments

Comments
 (0)