perf: missing annotations and helper instances

This commit is contained in:
Leonardo de Moura 2022-10-14 08:41:59 -07:00
parent 0a126b7702
commit 3f076fc836
4 changed files with 8 additions and 0 deletions

View file

@ -42,6 +42,9 @@ structure CompilerM.Context where
abbrev CompilerM := ReaderT CompilerM.Context $ StateRefT CompilerM.State CoreM
@[alwaysInline]
instance : Monad CompilerM := let i := inferInstanceAs (Monad CompilerM); { pure := i.pure, bind := i.bind }
@[inline] def withPhase (phase : Phase) (x : CompilerM α) : CompilerM α :=
withReader (fun ctx => { ctx with phase }) x

View file

@ -75,6 +75,9 @@ structure State where
abbrev SimpM := ReaderT Context $ StateRefT State DiscrM
@[alwaysInline]
instance : Monad SimpM := let i := inferInstanceAs (Monad SimpM); { pure := i.pure, bind := i.bind }
instance : MonadFVarSubst SimpM false where
getSubst := return (← get).subst

View file

@ -76,6 +76,7 @@ abbrev CoreM := ReaderT Context <| StateRefT State (EIO Exception)
-- Make the compiler generate specialized `pure`/`bind` so we do not have to optimize through the
-- whole monad stack at every use site. May eventually be covered by `deriving`.
@[alwaysInline]
instance : Monad CoreM := let i := inferInstanceAs (Monad CoreM); { pure := i.pure, bind := i.bind }
instance : Inhabited (CoreM α) where

View file

@ -300,6 +300,7 @@ abbrev MetaM := ReaderT Context $ StateRefT State CoreM
-- Make the compiler generate specialized `pure`/`bind` so we do not have to optimize through the
-- whole monad stack at every use site. May eventually be covered by `deriving`.
@[alwaysInline]
instance : Monad MetaM := let i := inferInstanceAs (Monad MetaM); { pure := i.pure, bind := i.bind }
instance : Inhabited (MetaM α) where