chore: style

This commit is contained in:
Sebastian Ullrich 2021-06-19 11:53:46 +02:00 committed by Leonardo de Moura
parent b8be90fa08
commit eb1e285e26
18 changed files with 28 additions and 28 deletions

View file

@ -23,7 +23,7 @@ universes u v
pure b
else match i with
| 0 => pure b
| i+1 => match ← f j b with
| i+1 => match (← f j b) with
| ForInStep.done b => pure b
| ForInStep.yield b => loop i (j + range.step) b
loop range.stop range.start init

View file

@ -54,7 +54,7 @@ partial def collectDiagnostics (waitForDiagnosticsId : RequestID := 0) (target :
: IpcM (List (Notification PublishDiagnosticsParams)) := do
writeRequest ⟨waitForDiagnosticsId, "textDocument/waitForDiagnostics", WaitForDiagnosticsParams.mk target version⟩
let rec loop : IpcM (List (Notification PublishDiagnosticsParams)) := do
match ←readMessage with
match (←readMessage) with
| Message.response id _ =>
if id == waitForDiagnosticsId then []
else loop

View file

@ -226,7 +226,7 @@ where
@[builtinMacro Lean.Parser.Term.paren] def expandParen : Macro
| `(()) => `(Unit.unit)
| `(($e : $type)) => do
match ← expandCDot? e with
match (← expandCDot? e) with
| some e => `(($e : $type))
| none => Macro.throwUnsupported
| `(($e)) => return (← expandCDot? e).getD e

View file

@ -277,7 +277,7 @@ partial def elabCommand (stx : Syntax) : CommandElabM Unit := do
else do
trace `Elab.command fun _ => stx;
let s ← get
match ← liftMacroM <| expandMacroImpl? s.env stx with
match (← liftMacroM <| expandMacroImpl? s.env stx) with
| some (decl, stxNew) =>
MonadRef.withElaborator decl do
withInfoTreeContext (mkInfoTree := mkInfoTree decl stx) do

View file

@ -27,7 +27,7 @@ def setCommandState (commandState : Command.State) : FrontendM Unit :=
let ctx ← read
let s ← get
let cmdCtx : Command.Context := { cmdPos := s.cmdPos, fileName := ctx.inputCtx.fileName, fileMap := ctx.inputCtx.fileMap }
match ← liftM <| EIO.toIO' <| (x cmdCtx).run s.commandState with
match (← liftM <| EIO.toIO' <| (x cmdCtx).run s.commandState) with
| Except.error e => throw <| IO.Error.userError s!"unexpected internal error: {← e.toMessageData.toString}"
| Except.ok (a, sNew) => setCommandState sNew; return a

View file

@ -741,7 +741,7 @@ private def elabPatterns (patternStxs : Array Syntax) (matchType : Expr) : Excep
restoreState s
match (← liftM <| commitIfNoErrors? <| withoutErrToSorry do elabTermAndSynthesize patternStx (← eraseIndices d)) with
| some pattern =>
match ← findDiscrRefinementPath pattern d |>.run with
match (← findDiscrRefinementPath pattern d |>.run) with
| some path =>
trace[Meta.debug] "refinement path: {path}"
restoreState s
@ -987,7 +987,7 @@ where
: TermElabM (Array Expr × Expr × Array (AltLHS × Expr) × Bool) := do
let s ← saveState
let (discrs', matchType', altViews', refined) ← generalize discrs matchType altViews generalizing?
match ← altViews'.mapM (fun altView => elabMatchAltView altView matchType') |>.run with
match (← altViews'.mapM (fun altView => elabMatchAltView altView matchType') |>.run) with
| Except.ok alts => return (discrs', matchType', alts, first?.isSome || refined)
| Except.error { patternIdx := patternIdx, pathToIndex := pathToIndex, ex := ex } =>
trace[Meta.debug] "pathToIndex: {toString pathToIndex}"
@ -1332,7 +1332,7 @@ builtin_initialize
@[builtinTermElab «nomatch»] def elabNoMatch : TermElab := fun stx expectedType? => do
match stx with
| `(nomatch $discrExpr) =>
match ← isLocalIdent? discrExpr with
match (← isLocalIdent? discrExpr) with
| some _ =>
let expectedType ← waitExpectedType expectedType?
let discr := Syntax.node ``Lean.Parser.Term.matchDiscr #[mkNullNode, discrExpr]

View file

@ -22,7 +22,7 @@ private def mkFnInhabitant? (xs : Array Expr) (type : Expr) : MetaM (Option Expr
| i+1, type => do
let x := xs[i]
let type ← mkForallFVars #[x] type;
match ← mkInhabitant? type with
match (← mkInhabitant? type) with
| none => loop i type
| some val => pure $ some (← mkLambdaFVars xs[0:i] val)
loop xs.size type
@ -30,13 +30,13 @@ private def mkFnInhabitant? (xs : Array Expr) (type : Expr) : MetaM (Option Expr
/- TODO: add a global IO.Ref to let users customize/extend this procedure -/
def mkInhabitantFor (declName : Name) (xs : Array Expr) (type : Expr) : MetaM Expr := do
match ← mkInhabitant? type with
match (← mkInhabitant? type) with
| some val => mkLambdaFVars xs val
| none =>
match ← findAssumption? xs type with
match (← findAssumption? xs type) with
| some x => mkLambdaFVars xs x
| none =>
match ← mkFnInhabitant? xs type with
match (← mkFnInhabitant? xs type) with
| some val => pure val
| none => throwError "failed to compile partial definition '{declName}', failed to show that type is inhabited"

View file

@ -159,13 +159,13 @@ private partial def findRecArg {α} (numFixed : Nat) (xs : Array Expr) (k : RecA
let numFixed := if indexMinPos < numFixed then indexMinPos else numFixed
let fixedParams := xs.extract 0 numFixed
let ys := xs.extract numFixed xs.size
match ← hasBadIndexDep? ys indIndices with
match (← hasBadIndexDep? ys indIndices) with
| some (index, y) =>
orelse'
(throwError "argument #{i+1} was not used because its type is an inductive family{indentExpr xType}\nand index{indentExpr index}\ndepends on the non index{indentExpr y}")
(loop (i+1))
| none =>
match ← hasBadParamDep? ys indParams with
match (← hasBadParamDep? ys indParams) with
| some (indParam, y) =>
orelse'
(throwError "argument #{i+1} was not used because its type is an inductive datatype{indentExpr xType}\nand parameter{indentExpr indParam}\ndepends on{indentExpr y}")
@ -390,7 +390,7 @@ private partial def replaceIndPredRecApps (recFnName : Name) (recArgInfo : RecAr
throwError "could not solve using backwards chaining {MessageData.ofGoal main.mvarId!}"
else
return mkAppN (← loop f) (← args.mapM loop)
match ←matchMatcherApp? e with
match (←matchMatcherApp? e) with
| some matcherApp =>
if !recArgHasLooseBVarsAt recFnName recArgInfo e then
processApp e

View file

@ -433,7 +433,7 @@ private def deduplicate (floatedLetDecls : Array Syntax) : Alt → TermElabM (Ar
-- looks simple enough/created by this function, skip
return (floatedLetDecls, (pats, rhs))
withFreshMacroScope do
match ← getPatternsVars pats.toArray with
match (← getPatternsVars pats.toArray) with
| #[] =>
-- no antiquotations => introduce Unit parameter to preserve evaluation order
let rhs' ← `(rhs Unit.unit)

View file

@ -23,7 +23,7 @@ private def checkUnusedIds (mvarId : MVarId) (unusedIds : List Name) : MetaM Uni
let fvarId ← elabAsFVar stx[1]
let ids := getInjectionNewIds stx[2]
liftMetaTactic fun mvarId => do
match ← Meta.injection mvarId fvarId ids (!ids.isEmpty) with
match (← Meta.injection mvarId fvarId ids (!ids.isEmpty)) with
| Meta.InjectionResult.solved => checkUnusedIds mvarId ids; pure []
| Meta.InjectionResult.subgoal mvarId' _ unusedIds => checkUnusedIds mvarId unusedIds; pure [mvarId']

View file

@ -1135,7 +1135,7 @@ private partial def elabTermAux (expectedType? : Option Expr) (catchExPostpone :
checkMaxHeartbeats "elaborator"
withNestedTraces do
let env ← getEnv
match ← liftMacroM (expandMacroImpl? env stx) with
match (← liftMacroM (expandMacroImpl? env stx)) with
| some (decl, stxNew) =>
MonadRef.withElaborator decl <|
withInfoContext' (mkInfo := mkTermInfo (expectedType? := expectedType?) stx) <|

View file

@ -139,7 +139,7 @@ def liftMacroM {α} {m : Type → Type} [Monad m] [MonadMacroAdapter m] [MonadEn
let methods := Macro.mkMethods {
-- TODO: record recursive expansions in info tree?
expandMacro? := fun stx => do
match ← expandMacroImpl? env stx with
match (← expandMacroImpl? env stx) with
| some (_, stx) => some stx
| none => none
hasDecl := fun declName => return env.contains declName

View file

@ -16,7 +16,7 @@ def synthesizeArgs (lemmaName : Name) (xs : Array Expr) (bis : Array BinderInfo)
return false
else if (← instantiateMVars x).isMVar then
if (← isProp type) then
match ← discharge? type with
match (← discharge? type) with
| some proof =>
unless (← isDefEq x proof) do
trace[Meta.Tactic.simp.discharge] "{lemmaName}, failed to assign proof{indentExpr type}"
@ -30,7 +30,7 @@ def synthesizeArgs (lemmaName : Name) (xs : Array Expr) (bis : Array BinderInfo)
return true
where
synthesizeInstance (x type : Expr) : SimpM Bool := do
match ← trySynthInstance type with
match (← trySynthInstance type) with
| LOption.some val =>
if (← isDefEq x val) then
return true

View file

@ -39,7 +39,7 @@ def setReducibleAttribute {m} [Monad m] [MonadEnv m] (declName : Name) : m Unit
setReducibilityStatus declName ReducibilityStatus.reducible
def isReducible {m} [Monad m] [MonadEnv m] (declName : Name) : m Bool := do
match ← getReducibilityStatus declName with
match (← getReducibilityStatus declName) with
| ReducibilityStatus.reducible => true
| _ => false

View file

@ -146,7 +146,7 @@ section Initialization
let opts := {} -- TODO
let inputCtx := Parser.mkInputContext m.text.source "<input>"
let (headerStx, headerParserState, msgLog) ← Parser.parseHeader inputCtx
let leanpkgPath ← match ← IO.getEnv "LEAN_SYSROOT" with
let leanpkgPath ← match (← IO.getEnv "LEAN_SYSROOT") with
| some path => pure <| System.FilePath.mk path / "bin" / "leanpkg"
| _ => pure <| (← appDir) / "leanpkg"
let leanpkgPath := leanpkgPath.withExtension System.FilePath.exeExtension

View file

@ -75,7 +75,7 @@ def mapTask (t : Task α) (f : α → RequestM β) : RequestM (RequestTask β) :
def bindTask (t : Task α) (f : α → RequestM (RequestTask β)) : RequestM (RequestTask β) := fun rc => do
let t ← IO.bindTask t fun a => do
match ← f a rc with
match (← f a rc) with
| Except.error e => return Task.pure <| Except.ok <| Except.error e
| Except.ok t => return t.map Except.ok
return t.map fun

View file

@ -185,7 +185,7 @@ def topDown (stx : Syntax) (firstChoiceOnly := false) : TopDown := ⟨firstChoic
partial instance : ForIn m TopDown Syntax where
forIn := fun ⟨firstChoiceOnly, stx⟩ init f => do
let rec @[specialize] loop stx b [Inhabited (typeOf% b)] := do
match ← f stx b with
match (← f stx b) with
| ForInStep.yield b' =>
let mut b := b'
if let Syntax.node k args := stx then
@ -193,12 +193,12 @@ partial instance : ForIn m TopDown Syntax where
return ← loop args[0] b
else
for arg in args do
match ← loop arg b with
match (← loop arg b) with
| ForInStep.yield b' => b := b'
| ForInStep.done b' => return ForInStep.done b'
return ForInStep.yield b
| ForInStep.done b => return ForInStep.done b
match ← @loop stx init ⟨init⟩ with
match (← @loop stx init ⟨init⟩) with
| ForInStep.yield b => return b
| ForInStep.done b => return b

View file

@ -53,7 +53,7 @@ protected def max : RBNode α β → Option (Sigma (fun k => β k))
match (← f k v b) with
| r@(ForInStep.done _) => return r
| ForInStep.yield b => visit r b
match ← visit as init with
match (← visit as init) with
| ForInStep.done b => pure b
| ForInStep.yield b => pure b