perf: specialize more monad instances

This commit is contained in:
Sebastian Ullrich 2021-06-17 11:25:34 +02:00
parent 380c6c285a
commit b4e9ba1500
2 changed files with 8 additions and 0 deletions

View file

@ -55,6 +55,10 @@ abbrev CommandElabM := CommandElabCoreM Exception
abbrev CommandElab := Syntax → CommandElabM Unit
abbrev Linter := Syntax → CommandElabM Unit
-- 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`.
instance : Monad CommandElabM := { inferInstanceAs (Monad CommandElabM) with }
def mkState (env : Environment) (messages : MessageLog := {}) (opts : Options := {}) : State := {
env := env
messages := messages

View file

@ -49,6 +49,10 @@ structure SavedState where
abbrev TacticM := ReaderT Context $ StateRefT State TermElabM
abbrev Tactic := Syntax → TacticM Unit
-- 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`.
instance : Monad TacticM := { inferInstanceAs (Monad TacticM) with }
def getGoals : TacticM (List MVarId) :=
return (← get).goals