perf: restore monad instance specialization hack

This commit is contained in:
Sebastian Ullrich 2021-08-12 21:09:09 +02:00
parent a6b6d61b39
commit 16026e9edd
5 changed files with 5 additions and 5 deletions

View file

@ -45,7 +45,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`.
instance : Monad CoreM := { inferInstanceAs (Monad CoreM) with }
instance : Monad CoreM := let i := inferInstanceAs (Monad CoreM); { pure := i.pure, bind := i.bind }
instance : Inhabited (CoreM α) where
default := fun _ _ => throw arbitrary

View file

@ -56,7 +56,7 @@ 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 }
instance : Monad CommandElabM := let i := inferInstanceAs (Monad CommandElabM); { pure := i.pure, bind := i.bind }
def mkState (env : Environment) (messages : MessageLog := {}) (opts : Options := {}) : State := {
env := env

View file

@ -53,7 +53,7 @@ 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 }
instance : Monad TacticM := let i := inferInstanceAs (Monad TacticM); { pure := i.pure, bind := i.bind }
def getGoals : TacticM (List MVarId) :=
return (← get).goals

View file

@ -181,7 +181,7 @@ abbrev TermElab := Syntax → Option Expr → TermElabM Expr
-- 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 TermElabM := { inferInstanceAs (Monad TermElabM) with }
instance : Monad TermElabM := let i := inferInstanceAs (Monad TermElabM); { pure := i.pure, bind := i.bind }
open Meta

View file

@ -174,7 +174,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`.
instance : Monad MetaM := { inferInstanceAs (Monad MetaM) with }
instance : Monad MetaM := let i := inferInstanceAs (Monad MetaM); { pure := i.pure, bind := i.bind }
instance : Inhabited (MetaM α) where
default := fun _ _ => arbitrary