chore: fix stdlib
This commit is contained in:
parent
4cb98c60d1
commit
33a10130cf
25 changed files with 101 additions and 102 deletions
|
|
@ -18,8 +18,7 @@ instance alternativeHasOrelse (f : Type u → Type v) (α : Type u) [Alternative
|
|||
section
|
||||
variables {f : Type u → Type v} [Alternative f] {α : Type u}
|
||||
|
||||
@[inline] def failure : f α :=
|
||||
Alternative.failure f
|
||||
export Alternative (failure)
|
||||
|
||||
@[inline] def guard {f : Type → Type v} [Alternative f] (p : Prop) [Decidable p] : f Unit :=
|
||||
if p then pure () else failure
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ open Function
|
|||
universes u v
|
||||
|
||||
class HasPure (f : Type u → Type v) :=
|
||||
(pure {} {α : Type u} : α → f α)
|
||||
(pure {α : Type u} : α → f α)
|
||||
|
||||
export HasPure (pure)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ universes u v
|
|||
namespace EStateM
|
||||
|
||||
inductive Result (ε σ α : Type u)
|
||||
| ok {} : α → σ → Result
|
||||
| error {} : ε → σ → Result
|
||||
| ok : α → σ → Result
|
||||
| error : ε → σ → Result
|
||||
|
||||
variables {ε σ α : Type u}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import Init.Data.ToString
|
|||
universes u v w
|
||||
|
||||
inductive Except (ε : Type u) (α : Type v)
|
||||
| error {} : ε → Except
|
||||
| ok {} : α → Except
|
||||
| error : ε → Except
|
||||
| ok : α → Except
|
||||
|
||||
attribute [unbox] Except
|
||||
|
||||
|
|
@ -127,8 +127,8 @@ end ExceptT
|
|||
|
||||
/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/
|
||||
class MonadExcept (ε : outParam (Type u)) (m : Type v → Type w) :=
|
||||
(throw {} {α : Type v} : ε → m α)
|
||||
(catch {} {α : Type v} : m α → (ε → m α) → m α)
|
||||
(throw {α : Type v} : ε → m α)
|
||||
(catch {α : Type v} : m α → (ε → m α) → m α)
|
||||
|
||||
namespace MonadExcept
|
||||
variables {ε : Type u} {m : Type v → Type w}
|
||||
|
|
@ -164,7 +164,7 @@ instance (ε) : MonadExcept ε (Except ε) :=
|
|||
```
|
||||
-/
|
||||
class MonadExceptAdapter (ε ε' : outParam (Type u)) (m m' : Type u → Type v) :=
|
||||
(adaptExcept {} {α : Type u} : (ε → ε') → m α → m' α)
|
||||
(adaptExcept {α : Type u} : (ε → ε') → m α → m' α)
|
||||
export MonadExceptAdapter (adaptExcept)
|
||||
|
||||
section
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ universes u v w
|
|||
but `n` does not have to be a monad transformer.
|
||||
Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/
|
||||
class HasMonadLift (m : Type u → Type v) (n : Type u → Type w) :=
|
||||
(monadLift {} : ∀ {α}, m α → n α)
|
||||
(monadLift : ∀ {α}, m α → n α)
|
||||
|
||||
/-- The reflexive-transitive closure of `HasMonadLift`.
|
||||
`monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.
|
||||
Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/
|
||||
class HasMonadLiftT (m : Type u → Type v) (n : Type u → Type w) :=
|
||||
(monadLift {} : ∀ {α}, m α → n α)
|
||||
(monadLift : ∀ {α}, m α → n α)
|
||||
|
||||
export HasMonadLiftT (monadLift)
|
||||
|
||||
|
|
@ -53,13 +53,13 @@ theorem monadLiftRefl {m : Type u → Type v} {α} : (monadLift : m α → m α)
|
|||
Remark: other libraries equate `m` and `m'`, and `n` and `n'`. We need to distinguish them to be able to implement
|
||||
gadgets such as `MonadStateAdapter` and `MonadReaderAdapter`. -/
|
||||
class MonadFunctor (m m' : Type u → Type v) (n n' : Type u → Type w) :=
|
||||
(monadMap {} {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
(monadMap {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
|
||||
/-- The reflexive-transitive closure of `MonadFunctor`.
|
||||
`monadMap` is used to transitively lift Monad morphisms such as `StateT.zoom`.
|
||||
A generalization of [MonadLiftFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadLiftFunctor), which can only lift endomorphisms (i.e. m = m', n = n'). -/
|
||||
class MonadFunctorT (m m' : Type u → Type v) (n n' : Type u → Type w) :=
|
||||
(monadMap {} {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
(monadMap {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
|
||||
export MonadFunctorT (monadMap)
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ end ReaderT
|
|||
```
|
||||
-/
|
||||
class MonadReader (ρ : outParam (Type u)) (m : Type u → Type v) :=
|
||||
(read {} : m ρ)
|
||||
(read : m ρ)
|
||||
|
||||
export MonadReader (read)
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ instance {ρ : Type u} {m : Type u → Type v} [Monad m] : MonadReader ρ (Reade
|
|||
```
|
||||
-/
|
||||
class MonadReaderAdapter (ρ ρ' : outParam (Type u)) (m m' : Type u → Type v) :=
|
||||
(adaptReader {} {α : Type u} : (ρ' → ρ) → m α → m' α)
|
||||
(adaptReader {α : Type u} : (ρ' → ρ) → m α → m' α)
|
||||
export MonadReaderAdapter (adaptReader)
|
||||
|
||||
section
|
||||
|
|
@ -121,7 +121,7 @@ instance (ρ : Type u) (m out) [MonadRun out m] : MonadRun (fun α => ρ → out
|
|||
⟨fun α x => run ∘ x⟩
|
||||
|
||||
class MonadReaderRunner (ρ : Type u) (m m' : Type u → Type u) :=
|
||||
(runReader {} {α : Type u} : m α → ρ → m' α)
|
||||
(runReader {α : Type u} : m α → ρ → m' α)
|
||||
export MonadReaderRunner (runReader)
|
||||
|
||||
section
|
||||
|
|
|
|||
|
|
@ -91,14 +91,14 @@ end StateT
|
|||
automatically from `monadLift`. -/
|
||||
class MonadState (σ : outParam (Type u)) (m : Type u → Type v) :=
|
||||
/- Obtain the top-most State of a Monad stack. -/
|
||||
(get {} : m σ)
|
||||
(get : m σ)
|
||||
/- Set the top-most State of a Monad stack. -/
|
||||
(set {} : σ → m PUnit)
|
||||
(set : σ → m PUnit)
|
||||
/- Map the top-most State of a Monad stack.
|
||||
|
||||
Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`
|
||||
because the latter does not use the State linearly (without sufficient inlining). -/
|
||||
(modifyGet {} {α : Type u} : (σ → α × σ) → m α)
|
||||
(modifyGet {α : Type u} : (σ → α × σ) → m α)
|
||||
|
||||
export MonadState (get set modifyGet)
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ end
|
|||
```
|
||||
-/
|
||||
class MonadStateAdapter (σ σ' : outParam (Type u)) (m m' : Type u → Type v) :=
|
||||
(adaptState {} {σ'' α : Type u} (split : σ' → σ × σ'') (join : σ → σ'' → σ') : m α → m' α)
|
||||
(adaptState {σ'' α : Type u} (split : σ' → σ × σ'') (join : σ → σ'' → σ') : m α → m' α)
|
||||
export MonadStateAdapter (adaptState)
|
||||
|
||||
section
|
||||
|
|
@ -180,7 +180,7 @@ instance (σ : Type u) (m out : Type u → Type v) [MonadRun out m] [Functor m]
|
|||
⟨fun α x => run ∘ StateT.run' x⟩
|
||||
|
||||
class MonadStateRunner (σ : Type u) (m m' : Type u → Type u) :=
|
||||
(runState {} {α : Type u} : m α → σ → m' α)
|
||||
(runState {α : Type u} : m α → σ → m' α)
|
||||
export MonadStateRunner (runState)
|
||||
|
||||
section
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ def Not (a : Prop) : Prop := a → False
|
|||
prefix `¬` := Not
|
||||
|
||||
inductive Eq {α : Sort u} (a : α) : α → Prop
|
||||
| refl : Eq a
|
||||
| refl {} : Eq a
|
||||
|
||||
@[elabAsEliminator, inline, reducible]
|
||||
def Eq.ndrec.{u1, u2} {α : Sort u2} {a : α} {C : α → Sort u1} (m : C a) {b : α} (h : Eq a b) : C b :=
|
||||
|
|
@ -206,7 +206,7 @@ constant Quot.ind {α : Sort u} {r : α → α → Prop} {β : Quot r → Prop}
|
|||
init_quot
|
||||
|
||||
inductive HEq {α : Sort u} (a : α) : ∀ {β : Sort u}, β → Prop
|
||||
| refl : HEq a
|
||||
| refl {} : HEq a
|
||||
|
||||
structure Prod (α : Type u) (β : Type v) :=
|
||||
(fst : α) (snd : β)
|
||||
|
|
@ -254,16 +254,16 @@ show (Eq.ndrecOn (Eq.refl α) a : α) = a' from
|
|||
this α a' h (Eq.refl α)
|
||||
|
||||
inductive Sum (α : Type u) (β : Type v)
|
||||
| inl {} (val : α) : Sum
|
||||
| inr {} (val : β) : Sum
|
||||
| inl (val : α) : Sum
|
||||
| inr (val : β) : Sum
|
||||
|
||||
inductive PSum (α : Sort u) (β : Sort v)
|
||||
| inl {} (val : α) : PSum
|
||||
| inr {} (val : β) : PSum
|
||||
| inl (val : α) : PSum
|
||||
| inr (val : β) : PSum
|
||||
|
||||
inductive Or (a b : Prop) : Prop
|
||||
| inl {} (h : a) : Or
|
||||
| inr {} (h : b) : Or
|
||||
| inl (h : a) : Or
|
||||
| inr (h : b) : Or
|
||||
|
||||
def Or.introLeft {a : Prop} (b : Prop) (ha : a) : Or a b :=
|
||||
Or.inl ha
|
||||
|
|
@ -307,7 +307,7 @@ def decEq {α : Sort u} [s : DecidableEq α] (a b : α) : Decidable (a = b) :=
|
|||
s a b
|
||||
|
||||
inductive Option (α : Type u)
|
||||
| none {} : Option
|
||||
| none : Option
|
||||
| some (val : α) : Option
|
||||
|
||||
attribute [unbox] Option
|
||||
|
|
@ -316,7 +316,7 @@ export Option (none some)
|
|||
export Bool (false true)
|
||||
|
||||
inductive List (T : Type u)
|
||||
| nil {} : List
|
||||
| nil : List
|
||||
| cons (hd : T) (tl : List) : List
|
||||
|
||||
infixr `::` := List.cons
|
||||
|
|
@ -332,8 +332,8 @@ axiom sorryAx (α : Sort u) (synthetic := true) : α
|
|||
|
||||
/- Declare builtin and reserved notation -/
|
||||
|
||||
class HasZero (α : Type u) := (zero : α)
|
||||
class HasOne (α : Type u) := (one : α)
|
||||
class HasZero (α : Type u) := mk {} :: (zero : α)
|
||||
class HasOne (α : Type u) := mk {} :: (one : α)
|
||||
class HasAdd (α : Type u) := (add : α → α → α)
|
||||
class HasMul (α : Type u) := (mul : α → α → α)
|
||||
class HasNeg (α : Type u) := (neg : α → α)
|
||||
|
|
@ -365,7 +365,7 @@ infix `≤` := HasLessEq.LessEq
|
|||
infix `<` := HasLess.Less
|
||||
infix `==` := HasBeq.beq
|
||||
infix `++` := HasAppend.append
|
||||
notation `∅` := HasEmptyc.emptyc _
|
||||
notation `∅` := HasEmptyc.emptyc
|
||||
infix `≈` := HasEquiv.Equiv
|
||||
infixr `^` := HasPow.pow
|
||||
infixr `/\` := And
|
||||
|
|
@ -446,7 +446,7 @@ inductive PNonScalar : Type u
|
|||
|
||||
/- For numeric literals notation -/
|
||||
class HasOfNat (α : Type u) :=
|
||||
(ofNat : Nat → α)
|
||||
mk {} :: (ofNat : Nat → α)
|
||||
|
||||
export HasOfNat (ofNat)
|
||||
|
||||
|
|
@ -1080,7 +1080,7 @@ structure PointedType :=
|
|||
/- Inhabited -/
|
||||
|
||||
class Inhabited (α : Sort u) :=
|
||||
(default : α)
|
||||
mk {} :: (default : α)
|
||||
|
||||
constant arbitrary (α : Sort u) [Inhabited α] : α :=
|
||||
Inhabited.default α
|
||||
|
|
@ -1353,7 +1353,7 @@ fun a b => isTrue (punitEq a b)
|
|||
/- Setoid -/
|
||||
|
||||
class Setoid (α : Sort u) :=
|
||||
(r : α → α → Prop) (iseqv : Equivalence r)
|
||||
mk {} :: (r : α → α → Prop) (iseqv : Equivalence r)
|
||||
|
||||
instance setoidHasEquiv {α : Sort u} [Setoid α] : HasEquiv α :=
|
||||
⟨Setoid.r⟩
|
||||
|
|
@ -1600,10 +1600,10 @@ variable {α : Type u}
|
|||
variable (r : α → α → Prop)
|
||||
|
||||
inductive EqvGen : α → α → Prop
|
||||
| rel {} : ∀ x y, r x y → EqvGen x y
|
||||
| refl {} : ∀ x, EqvGen x x
|
||||
| symm {} : ∀ x y, EqvGen x y → EqvGen y x
|
||||
| trans {} : ∀ x y z, EqvGen x y → EqvGen y z → EqvGen x z
|
||||
| rel : ∀ x y, r x y → EqvGen x y
|
||||
| refl : ∀ x, EqvGen x x
|
||||
| symm : ∀ x y, EqvGen x y → EqvGen y x
|
||||
| trans : ∀ x y z, EqvGen x y → EqvGen y z → EqvGen x z
|
||||
|
||||
theorem EqvGen.isEquivalence : Equivalence (@EqvGen α r) :=
|
||||
mkEquivalence _ EqvGen.refl EqvGen.symm EqvGen.trans
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ universes u v w
|
|||
|
||||
/- List-like type to avoid extra level of indirection -/
|
||||
inductive AssocList (α : Type u) (β : Type v)
|
||||
| nil {} : AssocList
|
||||
| nil : AssocList
|
||||
| cons (key : α) (value : β) (tail : AssocList) : AssocList
|
||||
|
||||
namespace AssocList
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ structure HeapNodeAux (α : Type u) (h : Type u) :=
|
|||
(val : α) (rank : Nat) (children : List h)
|
||||
|
||||
inductive Heap (α : Type u) : Type u
|
||||
| empty {} : Heap
|
||||
| empty : Heap
|
||||
| heap (ns : List (HeapNodeAux α Heap)) : Heap
|
||||
|
||||
abbrev HeapNode (α) := HeapNodeAux α (Heap α)
|
||||
|
|
@ -94,8 +94,8 @@ partial def toList (lt : α → α → Bool) : Heap α → List α
|
|||
| some a => a :: toList (tail lt h)
|
||||
|
||||
inductive WellFormed (lt : α → α → Bool) : Heap α → Prop
|
||||
| emptyWff : WellFormed Heap.empty
|
||||
| singletonWff (a : α) : WellFormed (singleton a)
|
||||
| emptyWff {} : WellFormed Heap.empty
|
||||
| singletonWff {} (a : α) : WellFormed (singleton a)
|
||||
| mergeWff (h₁ h₂ : Heap α) : WellFormed h₁ → WellFormed h₂ → WellFormed (merge lt h₁ h₂)
|
||||
| tailWff (h : Heap α) : WellFormed h → WellFormed (tail lt h)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ universes u v w w'
|
|||
namespace PersistentHashMap
|
||||
|
||||
inductive Entry (α : Type u) (β : Type v) (σ : Type w)
|
||||
| entry {} (key : α) (val : β) : Entry
|
||||
| ref {} (node : σ) : Entry
|
||||
| null {} : Entry
|
||||
| entry (key : α) (val : β) : Entry
|
||||
| ref (node : σ) : Entry
|
||||
| null : Entry
|
||||
|
||||
instance Entry.inhabited {α β σ} : Inhabited (Entry α β σ) := ⟨Entry.null⟩
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ inductive Rbcolor
|
|||
| red | black
|
||||
|
||||
inductive RBNode (α : Type u) (β : α → Type v)
|
||||
| leaf {} : RBNode
|
||||
| leaf : RBNode
|
||||
| node (color : Rbcolor) (lchild : RBNode) (key : α) (val : β key) (rchild : RBNode) : RBNode
|
||||
|
||||
namespace RBNode
|
||||
|
|
@ -199,7 +199,7 @@ variable (lt : α → α → Bool)
|
|||
end Membership
|
||||
|
||||
inductive WellFormed (lt : α → α → Bool) : RBNode α β → Prop
|
||||
| leafWff : WellFormed leaf
|
||||
| leafWff {} : WellFormed leaf
|
||||
| insertWff {n n' : RBNode α β} {k : α} {v : β k} : WellFormed n → n' = insert lt n k v → WellFormed n'
|
||||
| eraseWff {n n' : RBNode α β} {k : α} : WellFormed n → n' = erase lt k n → WellFormed n'
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Lean
|
|||
universes u
|
||||
|
||||
class HasFromJson (α : Type u) :=
|
||||
(fromJson? {} : Json → Option α)
|
||||
(fromJson? : Json → Option α)
|
||||
export HasFromJson (fromJson?)
|
||||
|
||||
class HasToJson (α : Type u) :=
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import Init.Control.Except
|
|||
namespace Lean
|
||||
|
||||
inductive Quickparse.Result (α : Type)
|
||||
| success {} (pos : String.Iterator) (res : α) : Quickparse.Result
|
||||
| error {} (pos : String.Iterator) (err : String) : Quickparse.Result
|
||||
| success (pos : String.Iterator) (res : α) : Quickparse.Result
|
||||
| error (pos : String.Iterator) (err : String) : Quickparse.Result
|
||||
|
||||
def Quickparse (α : Type) : Type := String.Iterator → Quickparse.Result α
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ protected def pure {α : Type} (a : α) : Quickparse α | it =>
|
|||
success it a
|
||||
|
||||
@[inline]
|
||||
protected def bind {α β : Type} (f : Quickparse α) (g : α → Quickparse β) : Quickparse β | it =>
|
||||
protected def bind {α β : Type} (f : Quickparse α) (g : α → Quickparse β) : Quickparse β | it =>
|
||||
match f it with
|
||||
| success rem a => g a rem
|
||||
| error pos msg => error pos msg
|
||||
|
|
@ -137,7 +137,7 @@ else do
|
|||
ec ←
|
||||
if c = '\\' then
|
||||
escapedChar
|
||||
-- as to whether c.val > 0xffff should be split up and encoded with multiple \u,
|
||||
-- as to whether c.val > 0xffff should be split up and encoded with multiple \u,
|
||||
-- the JSON standard is not definite: both directly printing the character
|
||||
-- and encoding it with multiple \u is allowed. we choose the former.
|
||||
else if 0x0020 ≤ c.val ∧ c.val ≤ 0x10ffff then
|
||||
|
|
|
|||
|
|
@ -149,9 +149,9 @@ subset m₁ m₂ && subset m₂ m₁
|
|||
instance : HasBeq KVMap := ⟨eqv⟩
|
||||
|
||||
class isKVMapVal (α : Type) :=
|
||||
(defVal : α)
|
||||
(set : KVMap → Name → α → KVMap)
|
||||
(get : KVMap → Name → α → α)
|
||||
(defVal {} : α)
|
||||
(set : KVMap → Name → α → KVMap)
|
||||
(get : KVMap → Name → α → α)
|
||||
|
||||
export isKVMapVal (set)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ universes u
|
|||
namespace Lean
|
||||
|
||||
inductive LOption (α : Type u)
|
||||
| none {} : LOption
|
||||
| some : α → LOption
|
||||
| undef {} : LOption
|
||||
| none : LOption
|
||||
| some : α → LOption
|
||||
| undef : LOption
|
||||
|
||||
namespace LOption
|
||||
variables {α : Type u}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ namespace Lean
|
|||
namespace Elab
|
||||
|
||||
class MonadPosInfo (m : Type → Type) :=
|
||||
(getFileMap {} : m FileMap)
|
||||
(getFileName {} : m String)
|
||||
(getCmdPos {} : m String.Pos)
|
||||
(addContext {} : MessageData → m MessageData)
|
||||
(getFileMap : m FileMap)
|
||||
(getFileName : m String)
|
||||
(getCmdPos : m String.Pos)
|
||||
(addContext : MessageData → m MessageData)
|
||||
|
||||
export MonadPosInfo (getFileMap getFileName getCmdPos)
|
||||
|
||||
class MonadLog (m : Type → Type) extends MonadPosInfo m :=
|
||||
(logMessage {} : Message → m Unit)
|
||||
(logMessage : Message → m Unit)
|
||||
|
||||
export MonadLog (logMessage)
|
||||
|
||||
|
|
|
|||
|
|
@ -220,9 +220,9 @@ instance FieldLHS.hasFormat : HasFormat FieldLHS :=
|
|||
| FieldLHS.modifyOp _ i => "[" ++ i.prettyPrint ++ "]"⟩
|
||||
|
||||
inductive FieldVal (σ : Type)
|
||||
| term {} (stx : Syntax) : FieldVal
|
||||
| nested (s : σ) : FieldVal
|
||||
| default {} : FieldVal -- mark that field must be synthesized using default value
|
||||
| term (stx : Syntax) : FieldVal
|
||||
| nested (s : σ) : FieldVal
|
||||
| default : FieldVal -- mark that field must be synthesized using default value
|
||||
|
||||
structure Field (σ : Type) :=
|
||||
mk {} :: (ref : Syntax) (lhs : List FieldLHS) (val : FieldVal σ) (expr? : Option Expr := none)
|
||||
|
|
|
|||
|
|
@ -106,12 +106,12 @@ fun stx =>
|
|||
| none => throw Macro.Exception.unsupportedSyntax
|
||||
|
||||
class MonadMacroAdapter (m : Type → Type) :=
|
||||
(getEnv {} : m Environment)
|
||||
(getCurrMacroScope {} : m MacroScope)
|
||||
(getNextMacroScope {} : m MacroScope)
|
||||
(setNextMacroScope {} : MacroScope → m Unit)
|
||||
(throwError {} {α : Type} : Syntax → MessageData → m α)
|
||||
(throwUnsupportedSyntax {} {α : Type} : m α)
|
||||
(getEnv : m Environment)
|
||||
(getCurrMacroScope : m MacroScope)
|
||||
(getNextMacroScope : m MacroScope)
|
||||
(setNextMacroScope : MacroScope → m Unit)
|
||||
(throwError {α : Type} : Syntax → MessageData → m α)
|
||||
(throwUnsupportedSyntax {α : Type} : m α)
|
||||
|
||||
@[inline] def liftMacroM {α} {m : Type → Type} [Monad m] [MonadMacroAdapter m] (x : MacroM α) : m α := do
|
||||
scp ← MonadMacroAdapter.getCurrMacroScope;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import Init.Data.HashMap
|
|||
namespace Lean
|
||||
/-- Interface for caching results. -/
|
||||
class MonadCache (α β : Type) (m : Type → Type) :=
|
||||
(findCached? {} : α → m (Option β))
|
||||
(cache {} : α → β → m Unit)
|
||||
(findCached? : α → m (Option β))
|
||||
(cache : α → β → m Unit)
|
||||
|
||||
/-- If entry `a := b` is already in the cache, then return `b`.
|
||||
Otherwise, execute `b ← f a`, store `a := b` in the cache and return `b`. -/
|
||||
|
|
@ -36,8 +36,8 @@ instance exceptLift {α β ε : Type} {m : Type → Type} [MonadCache α β m] [
|
|||
/-- Adapter for implementing `MonadCache` interface using `HashMap`s.
|
||||
We just have to specify how to extract/modify the `HashMap`. -/
|
||||
class MonadHashMapCacheAdapter (α β : Type) (m : Type → Type) [HasBeq α] [Hashable α] :=
|
||||
(getCache {} : m (HashMap α β))
|
||||
(modifyCache {} : (HashMap α β → HashMap α β) → m Unit)
|
||||
(getCache : m (HashMap α β))
|
||||
(modifyCache : (HashMap α β → HashMap α β) → m Unit)
|
||||
|
||||
namespace MonadHashMapCacheAdapter
|
||||
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ namespace Lean
|
|||
|
||||
class MonadTracer (m : Type → Type u) :=
|
||||
(traceCtx {α} : Name → m α → m α)
|
||||
(trace {} : Name → (Unit → MessageData) → m PUnit)
|
||||
(traceM {} : Name → m MessageData → m PUnit)
|
||||
(trace : Name → (Unit → MessageData) → m PUnit)
|
||||
(traceM : Name → m MessageData → m PUnit)
|
||||
|
||||
class MonadTracerAdapter (m : Type → Type) :=
|
||||
(isTracingEnabledFor {} : Name → m Bool)
|
||||
(addContext {} : MessageData → m MessageData)
|
||||
(enableTracing {} : Bool → m Bool)
|
||||
(getTraces {} : m (PersistentArray MessageData))
|
||||
(modifyTraces {} : (PersistentArray MessageData → PersistentArray MessageData) → m Unit)
|
||||
(isTracingEnabledFor : Name → m Bool)
|
||||
(addContext : MessageData → m MessageData)
|
||||
(enableTracing : Bool → m Bool)
|
||||
(getTraces : m (PersistentArray MessageData))
|
||||
(modifyTraces : (PersistentArray MessageData → PersistentArray MessageData) → m Unit)
|
||||
|
||||
private def checkTraceOptionAux (opts : Options) : Name → Bool
|
||||
| n@(Name.str p _ _) => opts.getBool n || (!opts.contains n && checkTraceOptionAux p)
|
||||
|
|
@ -128,10 +128,10 @@ instance : HasToString TraceState := ⟨toString ∘ fmt⟩
|
|||
end TraceState
|
||||
|
||||
class SimpleMonadTracerAdapter (m : Type → Type) :=
|
||||
(getOptions {} : m Options)
|
||||
(modifyTraceState {} : (TraceState → TraceState) → m Unit)
|
||||
(getTraceState {} : m TraceState)
|
||||
(addContext {} : MessageData → m MessageData)
|
||||
(getOptions : m Options)
|
||||
(modifyTraceState : (TraceState → TraceState) → m Unit)
|
||||
(getTraceState : m TraceState)
|
||||
(addContext : MessageData → m MessageData)
|
||||
|
||||
namespace SimpleMonadTracerAdapter
|
||||
variables {m : Type → Type} [Monad m] [SimpleMonadTracerAdapter m]
|
||||
|
|
|
|||
|
|
@ -175,10 +175,10 @@ abbrev SyntaxNodeKind := Name
|
|||
/- Syntax AST -/
|
||||
|
||||
inductive Syntax
|
||||
| missing {} : Syntax
|
||||
| missing : Syntax
|
||||
| node (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax
|
||||
| atom {} (info : Option SourceInfo) (val : String) : Syntax
|
||||
| ident {} (info : Option SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Name × List String)) : Syntax
|
||||
| atom (info : Option SourceInfo) (val : String) : Syntax
|
||||
| ident (info : Option SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Name × List String)) : Syntax
|
||||
|
||||
instance Syntax.inhabited : Inhabited Syntax :=
|
||||
⟨Syntax.missing⟩
|
||||
|
|
@ -247,8 +247,8 @@ def firstFrontendMacroScope := reservedMacroScope + 1
|
|||
elaboration). -/
|
||||
class MonadQuotation (m : Type → Type) :=
|
||||
-- Get the fresh scope of the current macro invocation
|
||||
(getCurrMacroScope {} : m MacroScope)
|
||||
(getMainModule {} : m Name)
|
||||
(getCurrMacroScope : m MacroScope)
|
||||
(getMainModule : m Name)
|
||||
/- Execute action in a new macro invocation context. This transformer should be
|
||||
used at all places that morally qualify as the beginning of a "macro call",
|
||||
e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ def PersistentState.shareCommon {α} (s : PersistentState) (a : α) : α × Pers
|
|||
end ShareCommon
|
||||
|
||||
class MonadShareCommon (m : Type u → Type v) :=
|
||||
(withShareCommon {} {α : Type u} : α → m α)
|
||||
(withShareCommon {α : Type u} : α → m α)
|
||||
|
||||
export MonadShareCommon (withShareCommon)
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ k (ptrAddrUnsafe a)
|
|||
if ptrAddrUnsafe a == ptrAddrUnsafe b then true else k ()
|
||||
|
||||
inductive PtrEqResult {α : Type u} (x y : α) : Type
|
||||
| unknown {} : PtrEqResult
|
||||
| unknown : PtrEqResult
|
||||
| yesEqual (h : x = y) : PtrEqResult
|
||||
|
||||
@[inline] unsafe def withPtrEqResultUnsafe {α : Type u} {β : Type v} [Subsingleton β] (a b : α) (k : PtrEqResult a b → β) : β :=
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ variable (rb : β → β → Prop)
|
|||
|
||||
-- Lexicographical order based on ra and rb
|
||||
inductive Lex : α × β → α × β → Prop
|
||||
| left {a₁} (b₁) {a₂} (b₂) (h : ra a₁ a₂) : Lex (a₁, b₁) (a₂, b₂)
|
||||
| right (a) {b₁ b₂} (h : rb b₁ b₂) : Lex (a, b₁) (a, b₂)
|
||||
| left {} {a₁} (b₁) {a₂} (b₂) (h : ra a₁ a₂) : Lex (a₁, b₁) (a₂, b₂)
|
||||
| right {} (a) {b₁ b₂} (h : rb b₁ b₂) : Lex (a, b₁) (a, b₂)
|
||||
|
||||
-- relational product based on ra and rb
|
||||
inductive Rprod : α × β → α × β → Prop
|
||||
|
|
@ -262,8 +262,8 @@ variables {α : Sort u} {β : Sort v}
|
|||
|
||||
-- Reverse lexicographical order based on r and s
|
||||
inductive RevLex (r : α → α → Prop) (s : β → β → Prop) : @PSigma α (fun a => β) → @PSigma α (fun a => β) → Prop
|
||||
| left : ∀ {a₁ a₂ : α} (b : β), r a₁ a₂ → RevLex ⟨a₁, b⟩ ⟨a₂, b⟩
|
||||
| right : ∀ (a₁ : α) {b₁ : β} (a₂ : α) {b₂ : β}, s b₁ b₂ → RevLex ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
|
||||
| left {} : ∀ {a₁ a₂ : α} (b : β), r a₁ a₂ → RevLex ⟨a₁, b⟩ ⟨a₂, b⟩
|
||||
| right {} : ∀ (a₁ : α) {b₁ : β} (a₂ : α) {b₂ : β}, s b₁ b₂ → RevLex ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
|
||||
end
|
||||
|
||||
section
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue