Skip to content

Commit 6bd4bfc

Browse files
INLINABLE more things (#2164)
* INLINABLE more things I found these by building dhall with -Wall-missing-specialisations. I suspect that at least some of these might be useful, but I didn't do any benchmarking. * INLINABLE Dhall.Eval.toVHPi Co-authored-by: Gabriel Gonzalez <[email protected]>
1 parent 190b518 commit 6bd4bfc

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

dhall/src/Dhall/Core.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ censorSrc (Src { srcText = oldText, .. }) = Src { srcText = newText, .. }
142142
throws :: (Exception e, MonadIO io) => Either e a -> io a
143143
throws (Left e) = liftIO (Control.Exception.throwIO e)
144144
throws (Right r) = return r
145+
{-# INLINABLE throws #-}
145146

146147
{- $setup
147148
>>> import qualified Codec.Serialise

dhall/src/Dhall/Eval.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ toVHPi :: Eq a => Val a -> Maybe (Text, Val a, Val a -> Val a)
144144
toVHPi (VPi a b@(Closure x _ _)) = Just (x, a, instantiate b)
145145
toVHPi (VHPi x a b ) = Just (x, a, b)
146146
toVHPi _ = Nothing
147+
{-# INLINABLE toVHPi #-}
147148

148149
data Val a
149150
= VConst !Const
@@ -1025,6 +1026,7 @@ conv !env t0 t0' =
10251026
judgmentallyEqual :: Eq a => Expr s a -> Expr t a -> Bool
10261027
judgmentallyEqual (Syntax.denote -> t) (Syntax.denote -> u) =
10271028
conv Empty (eval Empty t) (eval Empty u)
1029+
{-# INLINABLE judgmentallyEqual #-}
10281030

10291031
data Names
10301032
= EmptyNames
@@ -1226,6 +1228,7 @@ nf !env = Syntax.renote . quote (envNames env) . eval env . Syntax.denote
12261228

12271229
normalize :: Eq a => Expr s a -> Expr t a
12281230
normalize = nf Empty
1231+
{-# INLINABLE normalize #-}
12291232

12301233
alphaNormalize :: Expr s a -> Expr s a
12311234
alphaNormalize = goEnv EmptyNames

dhall/src/Dhall/Import.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ instance Show ImportResolutionDisabled where
12541254
assertNoImports :: MonadIO io => Expr Src Import -> io (Expr Src Void)
12551255
assertNoImports expression =
12561256
Core.throws (traverse (\_ -> Left ImportResolutionDisabled) expression)
1257+
{-# INLINABLE assertNoImports #-}
12571258

12581259
{-| This function is used by the @--transitive@ option of the
12591260
@dhall {freeze,format,lint}@ subcommands to determine which dependencies

dhall/src/Dhall/Normalize.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ normalize = Eval.normalize
160160
normalizeWith :: Eq a => Maybe (ReifiedNormalizer a) -> Expr s a -> Expr t a
161161
normalizeWith (Just ctx) t = runIdentity (normalizeWithM (getReifiedNormalizer ctx) t)
162162
normalizeWith _ t = Eval.normalize t
163+
{-# INLINABLE normalizeWith #-}
163164

164165
{-| This function generalizes `normalizeWith` by allowing the custom normalizer
165166
to use an arbitrary `Monad`
@@ -940,6 +941,7 @@ variable@(V var i) `freeIn` expression =
940941
denote' = Syntax.denote
941942

942943
strippedExpression = denote' expression
944+
{-# INLINABLE freeIn #-}
943945

944946
{- $setup
945947
>>> import Dhall.Syntax (Const(..))

dhall/src/Dhall/Syntax.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ recordFieldExprs f (RecordField s0 e s1 s2) =
890890
<*> f e
891891
<*> pure s1
892892
<*> pure s2
893+
{-# INLINABLE recordFieldExprs #-}
893894

894895
{-| Traverse over the immediate 'Expr' children in a 'FunctionBinding'.
895896
-}
@@ -904,6 +905,7 @@ functionBindingExprs f (FunctionBinding s0 label s1 s2 type_) =
904905
<*> pure s1
905906
<*> pure s2
906907
<*> f type_
908+
{-# INLINABLE functionBindingExprs #-}
907909

908910
-- | A traversal over the immediate sub-expressions in 'Chunks'.
909911
chunkExprs

0 commit comments

Comments
 (0)