chore: adjust instance param order
This commit is contained in:
parent
74fbca5663
commit
bfc1a16c02
16 changed files with 34 additions and 36 deletions
|
|
@ -63,19 +63,19 @@ abbrev coeFun {α : Sort u} {γ : α → Sort v} (a : α) [CoeFun α γ] : γ a
|
|||
abbrev coeSort {α : Sort u} {β : Sort v} (a : α) [CoeSort α β] : β :=
|
||||
CoeSort.coe a
|
||||
|
||||
instance coeTrans {α : Sort u} {β : Sort v} {δ : Sort w} [CoeTC α β] [Coe β δ] : CoeTC α δ where
|
||||
instance coeTrans {α : Sort u} {β : Sort v} {δ : Sort w} [Coe β δ] [CoeTC α β] : CoeTC α δ where
|
||||
coe a := coeB (coeTC a : β)
|
||||
|
||||
instance coeBase {α : Sort u} {β : Sort v} [Coe α β] : CoeTC α β where
|
||||
coe a := coeB a
|
||||
|
||||
instance coeOfHeafOfTCOfTail {α : Sort u} {β : Sort v} {δ : Sort w} {γ : Sort w'} (a : α) [CoeTC β δ] [CoeTail δ γ] [CoeHead α β] : CoeT α a γ where
|
||||
instance coeOfHeafOfTCOfTail {α : Sort u} {β : Sort v} {δ : Sort w} {γ : Sort w'} (a : α) [CoeHead α β] [CoeTail δ γ] [CoeTC β δ] : CoeT α a γ where
|
||||
coe := coeTail (coeTC (coeHead a : β) : δ)
|
||||
|
||||
instance coeOfHeadOfTC {α : Sort u} {β : Sort v} {δ : Sort w} (a : α) [CoeTC β δ] [CoeHead α β] : CoeT α a δ where
|
||||
instance coeOfHeadOfTC {α : Sort u} {β : Sort v} {δ : Sort w} (a : α) [CoeHead α β] [CoeTC β δ] : CoeT α a δ where
|
||||
coe := coeTC (coeHead a : β)
|
||||
|
||||
instance coeOfTCOfTail {α : Sort u} {β : Sort v} {δ : Sort w} (a : α) [CoeTC α β] [CoeTail β δ] : CoeT α a δ where
|
||||
instance coeOfTCOfTail {α : Sort u} {β : Sort v} {δ : Sort w} (a : α) [CoeTail β δ] [CoeTC α β] : CoeT α a δ where
|
||||
coe := coeTail (coeTC a : β)
|
||||
|
||||
instance coeOfHead {α : Sort u} {β : Sort v} (a : α) [CoeHead α β] : CoeT α a β where
|
||||
|
|
@ -116,7 +116,7 @@ instance subtypeCoe {α : Sort u} {p : α → Prop} : CoeHead { x // p x } α wh
|
|||
Remark: one may question why we use `OfNat α` instead of `Coe Nat α`.
|
||||
Reason: `OfNat` is for implementing polymorphic numeric literals, and we may
|
||||
want to have numberic literals for a type α and **no** coercion from `Nat` to `α`. -/
|
||||
instance hasOfNatOfCoe [OfNat α n] [Coe α β] : OfNat β n where
|
||||
instance hasOfNatOfCoe [Coe α β] [OfNat α n] : OfNat β n where
|
||||
ofNat := coe (OfNat.ofNat n : α)
|
||||
|
||||
@[inline] def liftCoeM {m : Type u → Type v} {n : Type u → Type w} {α β : Type u} [MonadLiftT m n] [∀ a, CoeT α a β] [Monad n] (x : m α) : n β := do
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class MonadControlT (m : Type u → Type v) (n : Type u → Type w) where
|
|||
|
||||
export MonadControlT (stM liftWith restoreM)
|
||||
|
||||
instance (m n o) [MonadControlT m n] [MonadControl n o] : MonadControlT m o where
|
||||
instance (m n o) [MonadControl n o] [MonadControlT m n] : MonadControlT m o where
|
||||
stM α := stM m n (MonadControl.stM n o α)
|
||||
liftWith f := MonadControl.liftWith fun x₂ => liftWith fun x₁ => f (x₁ ∘ x₂)
|
||||
restoreM := MonadControl.restoreM ∘ restoreM
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace ReaderT
|
|||
@[inline] protected def failure [Alternative m] : ReaderT ρ m α :=
|
||||
fun s => failure
|
||||
|
||||
instance [Monad m] [Alternative m] : Alternative (ReaderT ρ m) where
|
||||
instance [Alternative m] [Monad m] : Alternative (ReaderT ρ m) where
|
||||
failure := ReaderT.failure
|
||||
orElse := ReaderT.orElse
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ def mkFreshId {m : Type → Type} [Monad m] [MonadNameGenerator m] : m Name := d
|
|||
setNGen ngen.next
|
||||
pure r
|
||||
|
||||
instance monadNameGeneratorLift (m n : Type → Type) [MonadNameGenerator m] [MonadLift m n] : MonadNameGenerator n := {
|
||||
instance monadNameGeneratorLift (m n : Type → Type) [MonadLift m n] [MonadNameGenerator m] : MonadNameGenerator n := {
|
||||
getNGen := liftM (getNGen : m _),
|
||||
setNGen := fun ngen => liftM (setNGen ngen : m _)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1176,7 +1176,7 @@ export MonadLiftT (monadLift)
|
|||
|
||||
abbrev liftM := @monadLift
|
||||
|
||||
instance (m n o) [MonadLiftT m n] [MonadLift n o] : MonadLiftT m o where
|
||||
instance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where
|
||||
monadLift x := MonadLift.monadLift (m := n) (monadLift x)
|
||||
|
||||
instance (m) : MonadLiftT m m where
|
||||
|
|
@ -1196,7 +1196,7 @@ class MonadFunctorT (m : Type u → Type v) (n : Type u → Type w) where
|
|||
|
||||
export MonadFunctorT (monadMap)
|
||||
|
||||
instance (m n o) [MonadFunctorT m n] [MonadFunctor n o] : MonadFunctorT m o where
|
||||
instance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where
|
||||
monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)
|
||||
|
||||
instance monadFunctorRefl (m) : MonadFunctorT m m where
|
||||
|
|
@ -1324,7 +1324,7 @@ export MonadReader (read)
|
|||
instance (ρ : Type u) (m : Type u → Type v) [MonadReaderOf ρ m] : MonadReader ρ m where
|
||||
read := readThe ρ
|
||||
|
||||
instance {ρ : Type u} {m : Type u → Type v} {n : Type u → Type w} [MonadReaderOf ρ m] [MonadLift m n] : MonadReaderOf ρ n where
|
||||
instance {ρ : Type u} {m : Type u → Type v} {n : Type u → Type w} [MonadLift m n] [MonadReaderOf ρ m] : MonadReaderOf ρ n where
|
||||
read := liftM (m := m) read
|
||||
|
||||
instance {ρ : Type u} {m : Type u → Type v} [Monad m] : MonadReaderOf ρ (ReaderT ρ m) where
|
||||
|
|
@ -1344,7 +1344,7 @@ export MonadWithReader (withReader)
|
|||
instance (ρ : Type u) (m : Type u → Type v) [MonadWithReaderOf ρ m] : MonadWithReader ρ m where
|
||||
withReader := withTheReader ρ
|
||||
|
||||
instance {ρ : Type u} {m : Type u → Type v} {n : Type u → Type v} [MonadWithReaderOf ρ m] [MonadFunctor m n] : MonadWithReaderOf ρ n where
|
||||
instance {ρ : Type u} {m : Type u → Type v} {n : Type u → Type v} [MonadFunctor m n] [MonadWithReaderOf ρ m] : MonadWithReaderOf ρ n where
|
||||
withReader f := monadMap (m := m) (withTheReader ρ f)
|
||||
|
||||
instance {ρ : Type u} {m : Type u → Type v} [Monad m] : MonadWithReaderOf ρ (ReaderT ρ m) where
|
||||
|
|
@ -1396,7 +1396,7 @@ instance (σ : Type u) (m : Type u → Type v) [MonadStateOf σ m] : MonadState
|
|||
|
||||
-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer
|
||||
-- will be picked first
|
||||
instance {σ : Type u} {m : Type u → Type v} {n : Type u → Type w} [MonadStateOf σ m] [MonadLift m n] : MonadStateOf σ n where
|
||||
instance {σ : Type u} {m : Type u → Type v} {n : Type u → Type w} [MonadLift m n] [MonadStateOf σ m] : MonadStateOf σ n where
|
||||
get := liftM (m := m) MonadStateOf.get
|
||||
set := fun s => liftM (m := m) (MonadStateOf.set s)
|
||||
modifyGet := fun f => monadLift (m := m) (MonadState.modifyGet f)
|
||||
|
|
@ -1742,7 +1742,7 @@ class MonadRef (m : Type → Type) where
|
|||
|
||||
export MonadRef (getRef)
|
||||
|
||||
instance (m n : Type → Type) [MonadRef m] [MonadFunctor m n] [MonadLift m n] : MonadRef n where
|
||||
instance (m n : Type → Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where
|
||||
getRef := liftM (getRef : m _)
|
||||
withRef := fun ref x => monadMap (m := m) (MonadRef.withRef ref) x
|
||||
|
||||
|
|
@ -1786,7 +1786,7 @@ export MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)
|
|||
def MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo := do
|
||||
return { pos := (← getRef).getPos }
|
||||
|
||||
instance {m n : Type → Type} [MonadQuotation m] [MonadLift m n] [MonadFunctor m n] : MonadQuotation n where
|
||||
instance {m n : Type → Type} [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where
|
||||
getCurrMacroScope := liftM (m := m) getCurrMacroScope
|
||||
getMainModule := liftM (m := m) getMainModule
|
||||
withFreshMacroScope := monadMap (m := m) withFreshMacroScope
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ instance (σ : Type) : Monad (ST σ) := inferInstanceAs (Monad (EST _ _))
|
|||
-- Auxiliary class for inferring the "state" of `EST` and `ST` monads
|
||||
class STWorld (σ : outParam Type) (m : Type → Type)
|
||||
|
||||
instance {σ m n} [STWorld σ m] [MonadLift m n] : STWorld σ n := ⟨⟩
|
||||
instance {σ m n} [MonadLift m n] [STWorld σ m] : STWorld σ n := ⟨⟩
|
||||
instance {ε σ} : STWorld σ (EST ε σ) := ⟨⟩
|
||||
|
||||
@[noinline, nospecialize]
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ class MonadOptions (m : Type → Type) where
|
|||
|
||||
export MonadOptions (getOptions)
|
||||
|
||||
instance (m n) [MonadOptions m] [MonadLift m n] : MonadOptions n :=
|
||||
{ getOptions := liftM (getOptions : m _) }
|
||||
instance (m n) [MonadLift m n] [MonadOptions m] : MonadOptions n where
|
||||
getOptions := liftM (getOptions : m _)
|
||||
|
||||
variables {m} [Monad m] [MonadOptions m]
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class MonadInfoTree (m : Type → Type) where
|
|||
|
||||
export MonadInfoTree (getInfoState modifyInfoState)
|
||||
|
||||
instance (m n) [MonadInfoTree m] [MonadLift m n] : MonadInfoTree n where
|
||||
instance (m n) [MonadLift m n] [MonadInfoTree m] : MonadInfoTree n where
|
||||
getInfoState := liftM (getInfoState : m _)
|
||||
modifyInfoState f := liftM (modifyInfoState f : m _)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@ class MonadLog (m : Type → Type) extends MonadFileMap m where
|
|||
|
||||
export MonadLog (getFileName logMessage)
|
||||
|
||||
instance (m n) [MonadLog m] [MonadLift m n] : MonadLog n := {
|
||||
getRef := liftM (MonadLog.getRef : m _),
|
||||
getFileMap := liftM (getFileMap : m _),
|
||||
getFileName := liftM (getFileName : m _),
|
||||
instance (m n) [MonadLift m n] [MonadLog m] : MonadLog n where
|
||||
getRef := liftM (MonadLog.getRef : m _)
|
||||
getFileMap := liftM (getFileMap : m _)
|
||||
getFileName := liftM (getFileName : m _)
|
||||
logMessage := fun msg => liftM (logMessage msg : m _ )
|
||||
}
|
||||
|
||||
variables {m : Type → Type} [Monad m] [MonadLog m] [AddMessageContext m]
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class MonadMacroAdapter (m : Type → Type) where
|
|||
getNextMacroScope : m MacroScope
|
||||
setNextMacroScope : MacroScope → m Unit
|
||||
|
||||
instance (m n) [MonadMacroAdapter m] [MonadLift m n] : MonadMacroAdapter n := {
|
||||
instance (m n) [MonadLift m n] [MonadMacroAdapter m] : MonadMacroAdapter n := {
|
||||
getCurrMacroScope := liftM (MonadMacroAdapter.getCurrMacroScope : m _),
|
||||
getNextMacroScope := liftM (MonadMacroAdapter.getNextMacroScope : m _),
|
||||
setNextMacroScope := fun s => liftM (MonadMacroAdapter.setNextMacroScope s : m _)
|
||||
|
|
|
|||
|
|
@ -703,9 +703,8 @@ class MonadEnv (m : Type → Type) where
|
|||
|
||||
export MonadEnv (getEnv modifyEnv)
|
||||
|
||||
instance (m n) [MonadEnv m] [MonadLift m n] : MonadEnv n := {
|
||||
getEnv := liftM (getEnv : m Environment),
|
||||
instance (m n) [MonadLift m n] [MonadEnv m] : MonadEnv n where
|
||||
getEnv := liftM (getEnv : m Environment)
|
||||
modifyEnv := fun f => liftM (modifyEnv f : m Unit)
|
||||
}
|
||||
|
||||
end Lean
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ class MonadLCtx (m : Type → Type) where
|
|||
|
||||
export MonadLCtx (getLCtx)
|
||||
|
||||
instance (m n) [MonadLCtx m] [MonadLift m n] : MonadLCtx n where
|
||||
instance (m n) [MonadLift m n] [MonadLCtx m] : MonadLCtx n where
|
||||
getLCtx := liftM (getLCtx : m _)
|
||||
|
||||
def replaceFVarIdAtLocalDecl (fvarId : FVarId) (e : Expr) (d : LocalDecl) : LocalDecl :=
|
||||
|
|
|
|||
|
|
@ -215,8 +215,8 @@ class AddMessageContext (m : Type → Type) where
|
|||
|
||||
export AddMessageContext (addMessageContext)
|
||||
|
||||
instance (m n) [AddMessageContext m] [MonadLift m n] : AddMessageContext n :=
|
||||
{ addMessageContext := fun msg => liftM (addMessageContext msg : m _) }
|
||||
instance (m n) [MonadLift m n] [AddMessageContext m] : AddMessageContext n where
|
||||
addMessageContext := fun msg => liftM (addMessageContext msg : m _)
|
||||
|
||||
def addMessageContextPartial {m} [Monad m] [MonadEnv m] [MonadOptions m] (msgData : MessageData) : m MessageData := do
|
||||
let env ← getEnv
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ class MonadMCtx (m : Type → Type) where
|
|||
|
||||
export MonadMCtx (getMCtx modifyMCtx)
|
||||
|
||||
instance (m n) [MonadMCtx m] [MonadLift m n] : MonadMCtx n where
|
||||
instance (m n) [MonadLift m n] [MonadMCtx m] : MonadMCtx n where
|
||||
getMCtx := liftM (getMCtx : m _)
|
||||
modifyMCtx := fun f => liftM (modifyMCtx f : m _)
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class MonadResolveName (m : Type → Type) where
|
|||
|
||||
export MonadResolveName (getCurrNamespace getOpenDecls)
|
||||
|
||||
instance (m n) [MonadResolveName m] [MonadLift m n] : MonadResolveName n where
|
||||
instance (m n) [MonadLift m n] [MonadResolveName m] : MonadResolveName n where
|
||||
getCurrNamespace := liftM (m:=m) getCurrNamespace
|
||||
getOpenDecls := liftM (m:=m) getOpenDecls
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ class MonadTrace (m : Type → Type) where
|
|||
|
||||
export MonadTrace (getTraceState modifyTraceState)
|
||||
|
||||
instance (m n) [MonadTrace m] [MonadLift m n] : MonadTrace n :=
|
||||
{ modifyTraceState := fun f => liftM (modifyTraceState f : m _),
|
||||
getTraceState := liftM (getTraceState : m _) }
|
||||
instance (m n) [MonadLift m n] [MonadTrace m] : MonadTrace n where
|
||||
modifyTraceState := fun f => liftM (modifyTraceState f : m _)
|
||||
getTraceState := liftM (getTraceState : m _)
|
||||
|
||||
variables {α : Type} {m : Type → Type} [Monad m] [MonadTrace m]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue