Skip to content

Commit

Permalink
Reintroduce some 'INLINE' pragmas
Browse files Browse the repository at this point in the history
  • Loading branch information
effectfully committed Feb 20, 2022
1 parent 669a4e3 commit 695c053
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plutus-core/plutus-core/src/PlutusCore/Builtin/Meaning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ class KnownMonotype val args res a | args res -> a, a -> res where
-- | Once we've run out of term-level arguments, we return a 'TypeSchemeResult'.
instance (res ~ res', KnownType val res) => KnownMonotype val '[] res res' where
knownMonotype = TypeSchemeResult
{-# INLINE knownMonotype #-}

-- | Every term-level argument becomes as 'TypeSchemeArrow'.
instance (KnownType val arg, KnownMonotype val args res a) =>
KnownMonotype val (arg ': args) res (arg -> a) where
-- The call to 'inline' was added because without it 'readKnown' was not getting inlined for
-- certain types (in particular, 'Int' and 'Opaque').
knownMonotype = TypeSchemeArrow (inline readKnown) knownMonotype
{-# INLINE knownMonotype #-}

-- | A class that allows us to derive a polytype for a builtin.
class KnownPolytype (binds :: [Some TyNameRep]) val args res a | args res -> a, a -> res where
Expand All @@ -143,6 +145,7 @@ class KnownPolytype (binds :: [Some TyNameRep]) val args res a | args res -> a,
-- | Once we've run out of type-level arguments, we start handling term-level ones.
instance KnownMonotype val args res a => KnownPolytype '[] val args res a where
knownPolytype = knownMonotype
{-# INLINE knownPolytype #-}

-- Here we unpack an existentially packed @kind@ and constrain it afterwards!
-- So promoted existentials are true sigmas! If we were at the term level, we'd have to pack
Expand All @@ -152,6 +155,7 @@ instance KnownMonotype val args res a => KnownPolytype '[] val args res a where
instance (KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res a) =>
KnownPolytype ('Some ('TyNameRep @kind name uniq) ': binds) val args res a where
knownPolytype = TypeSchemeAll @name @uniq @kind Proxy $ knownPolytype @binds
{-# INLINE knownPolytype #-}

-- See Note [Automatic derivation of type schemes]
-- | Construct the meaning for a built-in function by automatically deriving its
Expand All @@ -166,3 +170,4 @@ makeBuiltinMeaning
)
=> a -> (cost -> FoldArgsEx args) -> BuiltinMeaning val cost
makeBuiltinMeaning = BuiltinMeaning $ knownPolytype @binds @val @args @res
{-# INLINE makeBuiltinMeaning #-}

0 comments on commit 695c053

Please sign in to comment.