Equations
- Function.comp f g x = f (g x)
Equations
- Function.const β a x = a
Auxiliary unsafe constant used by the Compiler to mark unreachable code.
Equations
- False.elim h = False.rec (fun x => C) h
Equations
- namedPattern x a h = a
Auxiliary Declaration used to implement the named patterns x@h:p
- default : α
Instances
- instInhabited
- instInhabitedSort
- instInhabitedForAll_1
- instInhabitedProp
- IO.instInhabitedError
- Nat.SOM.instInhabitedExpr
- Lean.Macro.instInhabitedMethods
- ExceptCpsT.instInhabitedExceptCpsT
- ByteArray.instInhabitedByteArray
- instInhabitedUInt32
- Lean.Meta.Simp.instInhabitedConfig
- instInhabitedUInt8
- instInhabitedForInStep
- instInhabitedEIO
- instInhabitedSubstring
- instInhabitedStdGen
- IO.FS.instInhabitedStream
- Socket.instInhabitedShutdownHow
- instInhabitedExceptT
- Std.instInhabitedFormat
- Lean.instInhabitedSourceInfo
- EStateM.instInhabitedResult
- Subtype.instInhabitedSubtype
- IO.FS.instInhabitedSystemTime
- instInhabitedPUnit
- instInhabitedOption
- Lean.Macro.instInhabitedMethodsRef
- Lean.instInhabitedSyntax
- instInhabitedUInt64
- Nat.Linear.instInhabitedExpr
- Lean.Meta.instInhabitedEtaStructMode
- instInhabitedUInt16
- Std.Format.instInhabitedFlattenBehavior
- Lean.Meta.DSimp.instInhabitedConfig
- Lean.instInhabitedNameGenerator
- Lean.Data.AC.instInhabitedExpr
- instInhabitedTrue
- instInhabitedList
- instInhabitedReaderT
- Sum.inhabitedLeft
- Sum.inhabitedRight
- EStateM.instInhabitedEStateM
- instInhabitedFloat
- instInhabitedNat
- Std.Format.instInhabitedSpaceResult
- Lean.Meta.instInhabitedTransparencyMode
- instInhabitedEST
- Lean.Macro.instInhabitedState
- Socket.instInhabitedSockType
- instInhabitedPNonScalar
- Lean.instInhabitedParserDescr
- Socket.instInhabitedAddressFamily
- Array.instInhabitedArray
- instInhabitedProd
- System.instInhabitedFilePath
- instInhabitedBool
- FloatArray.instInhabitedFloatArray
- Lean.instInhabitedMacroScopesView
- instInhabitedExcept
- instInhabitedNonemptyType
- instInhabitedOrdering
- instInhabitedPos
- Lean.instInhabitedName
- String.instInhabitedString
- instInhabitedTask
- instInhabitedUSize
- instInhabitedNonScalar
- Char.instInhabitedChar
- Fin.instInhabitedFinHAddNatInstHAddInstAddNatOfNat
- Int.instInhabitedInt
- instInhabitedForAll
- instInhabitedForAll_2
- intro: ∀ {α : Sort u}, α → Nonempty α
Equations
Equations
Equations
- Classical.ofNonempty = Classical.choice (_ : Nonempty α)
Equations
Equations
- instInhabitedSort = { default := PUnit }
Equations
- instInhabitedForAll α = { default := fun x => default }
Equations
- instInhabitedForAll_1 α = { default := fun x => default }
Equations
- instInhabitedBool = { default := false }
Equations
- NonemptyType.type type = type.val
Equations
- instInhabitedNonemptyType = { default := { val := PUnit, property := (_ : Nonempty PUnit) } }
Instances
- instDecidableDitePropNot
- instDecidableIff
- instDecidableIteProp
- instDecidableRelLtLtOfOrd
- instDecidableLtUInt32InstLTUInt32
- instDecidableLtUInt8InstLTUInt8
- instDecidableLtUInt64InstLTUInt64
- instDecidableLtUInt16InstLTUInt16
- List.hasDecidableLt
- floatDecLt
- Nat.decLt
- prodHasDecidableLt
- instDecidableLtPosInstLTPos
- String.decLt
- instDecidableLtUSizeInstLTUSize
- Char.instDecidableLtCharInstLTChar
- Fin.decLt
- Int.decLt
- instDecidableEqProp
- instDecidableEqQuotient
- instDecidableEqUInt32
- instDecidableEqUInt8
- Subtype.instDecidableEqSubtype
- instDecidableEqPUnit
- instDecidableEqOption
- instDecidableEqUInt64
- instDecidableEqUInt16
- String.instDecidableEqIterator
- instDecidableEqList
- instDecidableEqSum
- instDecidableEqNat
- Array.instDecidableEqArray
- instDecidableEqProd
- System.instDecidableEqFilePath
- instDecidableEqBool
- instDecidableEqPos
- instDecidableEqString
- instDecidableEqUSize
- instDecidableEqChar
- instDecidableEqFin
- Int.instDecidableEqInt
- List.instDecidableMemListInstMembershipList
- instDecidableTrue
- instDecidableNot
- instDecidableFalse
- instDecidableRelLeLeOfOrd
- instDecidableLeUInt32InstLEUInt32
- instDecidableLeUInt8InstLEUInt8
- instDecidableLeUInt64InstLEUInt64
- instDecidableLeUInt16InstLEUInt16
- List.instForAllListDecidableLeInstLEList
- floatDecLe
- Nat.decLe
- instDecidableLePosInstLEPos
- instDecidableLeUSizeInstLEUSize
- Char.instDecidableLeCharInstLEChar
- Fin.decLe
- Int.decLe
- Option.instDecidableRelOptionLt
- instDecidableAnd
- instDecidableOr
- instDecidableForAll
Equations
- decide p = Decidable.casesOn h (fun x => false) fun x => true
Equations
- DecidablePred r = ((a : α) → Decidable (r a))
Equations
- DecidableRel r = ((a b : α) → Decidable (r a b))
Equations
- DecidableEq α = ((a b : α) → Decidable (a = b))
- beq : α → α → Bool
Instances
- instBEq
- Lean.Meta.Simp.instBEqConfig
- Substring.hasBeq
- IO.FS.instBEqFileType
- IO.FS.instBEqSystemTime
- instBEqOption
- Lean.Syntax.instBEqSyntax
- Lean.Meta.instBEqEtaStructMode
- Std.Format.instBEqFlattenBehavior
- Lean.Meta.DSimp.instBEqConfig
- Lean.Data.AC.instBEqExpr
- List.instBEqList
- Nat.Linear.instBEqPolyCnstr
- instBEqFloat
- instBEqNat
- Lean.Meta.instBEqTransparencyMode
- Array.instBEqArray
- instBEqProd
- instBEqOrdering
- Lean.Name.instBEqName
Equations
- (if c then t else e) = Decidable.casesOn h (fun x => e) fun x => t
Equations
- instInhabitedNat = { default := Nat.zero }
- ofNat : α
Equations
- instOfNatNat n = { ofNat := n }
- le : α → α → Prop
- lt : α → α → Prop
Equations
- instTransEq r = { trans := @instTransEq.proof_1 α γ r }
Equations
- instTransEq_1 r = { trans := @instTransEq_1.proof_1 α β r }
- hAdd : α → β → γ
Instances
- hSub : α → β → γ
Instances
- hDiv : α → β → γ
- hMod : α → β → γ
- hPow : α → β → γ
Instances
- hAppend : α → β → γ
Instances
- hOrElse : α → (Unit → β) → γ
Instances
- hAndThen : α → (Unit → β) → γ
Instances
- hShiftLeft : α → β → γ
Instances
- hShiftRight : α → β → γ
Instances
- add : α → α → α
- sub : α → α → α
- mul : α → α → α
- div : α → α → α
- mod : α → α → α
- pow : α → β → α
Instances
- append : α → α → α
- orElse : α → (Unit → α) → α
- and : α → α → α
- xor : α → α → α
- or : α → α → α
- complement : α → α
- shiftLeft : α → α → α
- shiftRight : α → α → α
Equations
- instHAppend = { hAppend := fun a b => Append.append a b }
Equations
- instHOrElse = { hOrElse := fun a b => OrElse.orElse a b }
Equations
- instHAndThen = { hAndThen := fun a b => AndThen.andThen a b }
Equations
- instHShiftLeft = { hShiftLeft := fun a b => ShiftLeft.shiftLeft a b }
Equations
- instHShiftRight = { hShiftRight := fun a b => ShiftRight.shiftRight a b }
- mem : α → γ → Prop
Equations
Equations
Equations
- UInt8.ofNatCore n h = { val := { val := n, isLt := h } }
Equations
Equations
- instInhabitedUInt8 = { default := UInt8.ofNatCore 0 instInhabitedUInt8.proof_1 }
Equations
- UInt16.ofNatCore n h = { val := { val := n, isLt := h } }
Equations
Equations
- instInhabitedUInt16 = { default := UInt16.ofNatCore 0 instInhabitedUInt16.proof_1 }
Equations
- UInt32.ofNatCore n h = { val := { val := n, isLt := h } }
Equations
- UInt32.toNat n = n.val.val
Equations
Equations
- instInhabitedUInt32 = { default := UInt32.ofNatCore 0 instInhabitedUInt32.proof_1 }
Equations
- instLTUInt32 = { lt := fun a b => a.val < b.val }
Equations
- instLEUInt32 = { le := fun a b => a.val ≤ b.val }
Equations
- UInt32.decLt a b = match a, b with | { val := n }, { val := m } => inferInstanceAs (Decidable (n < m))
Equations
- UInt32.decLe a b = match a, b with | { val := n }, { val := m } => inferInstanceAs (Decidable (n ≤ m))
Equations
Equations
Equations
- UInt64.ofNatCore n h = { val := { val := n, isLt := h } }
Equations
Equations
- instInhabitedUInt64 = { default := UInt64.ofNatCore 0 instInhabitedUInt64.proof_1 }
Equations
- USize.ofNatCore n h = { val := { val := n, isLt := h } }
Equations
Equations
- instInhabitedUSize = { default := USize.ofNatCore 0 instInhabitedUSize.proof_1 }
Equations
- USize.ofNat32 n h = { val := { val := n, isLt := (_ : n < USize.size) } }
Equations
- val : UInt32
- valid : UInt32.isValidChar val
The Char
Type represents an unicode scalar value.
See http://www.unicode.org/glossary/#unicode_scalar_value).
Equations
- Char.ofNatAux n h = { val := { val := { val := n, isLt := (_ : n < UInt32.size) } }, valid := h }
Equations
- Char.ofNat n = if h : Nat.isValidChar n then Char.ofNatAux n h else { val := { val := { val := 0, isLt := Char.ofNat.proof_1 } }, valid := Char.ofNat.proof_2 }
Equations
- Char.utf8Size c = let v := c.val; if v ≤ UInt32.ofNatCore 127 Char.utf8Size.proof_1 then UInt32.ofNatCore 1 Char.utf8Size.proof_2 else if v ≤ UInt32.ofNatCore 2047 Char.utf8Size.proof_3 then UInt32.ofNatCore 2 Char.utf8Size.proof_4 else if v ≤ UInt32.ofNatCore 65535 Char.utf8Size.proof_5 then UInt32.ofNatCore 3 Char.utf8Size.proof_6 else UInt32.ofNatCore 4 Char.utf8Size.proof_7
Equations
- instInhabitedOption = { default := none }
Equations
- Option.getD _fun_discr _fun_discr = match _fun_discr, _fun_discr with | some x, x_1 => x | none, e => e
Equations
- instInhabitedList = { default := [] }
Equations
- List.hasDecEq [] [] = isTrue (_ : [] = [])
- List.hasDecEq (head :: tail) [] = isFalse (_ : head :: tail = [] → List.noConfusionType False (head :: tail) [])
- List.hasDecEq [] (head :: tail) = isFalse (_ : [] = head :: tail → List.noConfusionType False [] (head :: tail))
- List.hasDecEq (a :: as) (b :: bs) = match decEq a b with | isTrue hab => match List.hasDecEq as bs with | isTrue habs => isTrue (_ : a :: as = b :: bs) | isFalse nabs => isFalse (_ : a :: as = b :: bs → False) | isFalse nab => isFalse (_ : a :: as = b :: bs → False)
Equations
- instDecidableEqList = List.hasDecEq
Equations
- List.foldl f _fun_discr [] = _fun_discr
- List.foldl f _fun_discr (b :: l) = List.foldl f (f _fun_discr b) l
Equations
- List.length [] = 0
- List.length (head :: as) = List.length as + 1
Equations
- List.lengthTRAux [] _fun_discr = _fun_discr
- List.lengthTRAux (head :: as) _fun_discr = List.lengthTRAux as (Nat.succ _fun_discr)
Equations
- List.lengthTR as = List.lengthTRAux as 0
Equations
- List.concat [] _fun_discr = [_fun_discr]
- List.concat (a :: as) _fun_discr = a :: List.concat as _fun_discr
Equations
- byteIdx : Nat
A byte position in a String
. Internally, String
s are UTF-8 encoded.
Codepoint positions (counting the Unicode codepoints rather than bytes)
are represented by plain Nat
s instead.
Indexing a String
by a byte position is constant-time, while codepoint
positions need to be translated internally to byte positions in linear-time.
Equations
- instInhabitedPos = { default := { byteIdx := 0 } }
Equations
- instInhabitedSubstring = { default := { str := "", startPos := { byteIdx := 0 }, stopPos := { byteIdx := 0 } } }
Equations
- Substring.bsize _fun_discr = match _fun_discr with | { str := str, startPos := b, stopPos := e } => Nat.sub e.byteIdx b.byteIdx
Equations
- String.utf8ByteSize _fun_discr = match _fun_discr with | { data := s } => String.utf8ByteSize.go s
Equations
- String.utf8ByteSize.go [] = 0
- String.utf8ByteSize.go (c :: cs) = String.utf8ByteSize.go cs + String.csize c
Equations
- instHAddPos = { hAdd := fun p₁ p₂ => { byteIdx := p₁.byteIdx + p₂.byteIdx } }
Equations
- instHSubPos = { hSub := fun p₁ p₂ => { byteIdx := p₁.byteIdx - p₂.byteIdx } }
Equations
- instHAddPosChar = { hAdd := fun p c => { byteIdx := p.byteIdx + String.csize c } }
Equations
- instHAddPosString = { hAdd := fun p s => { byteIdx := p.byteIdx + String.utf8ByteSize s } }
Equations
- instDecidableLePosInstLEPos p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx ≤ p₂.byteIdx))
Equations
- instDecidableLtPosInstLTPos p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx < p₂.byteIdx))
Equations
- String.endPos s = { byteIdx := String.utf8ByteSize s }
Equations
- String.toSubstring s = { str := s, startPos := { byteIdx := 0 }, stopPos := String.endPos s }
Equations
- Array.mkEmpty c = { data := [] }
Equations
- Array.size a = List.length a.data
Equations
- Array.getD a i v₀ = if h : i < Array.size a then Array.get a { val := i, isLt := h } else v₀
Equations
- Array.get! a i = Array.getD a i default
Equations
- Array.getOp self idx = Array.get! self idx
Equations
- Array.push a v = { data := List.concat a.data v }
Equations
- Array.setD a i v = if h : i < Array.size a then Array.set a { val := i, isLt := h } v else a
Equations
- Array.set! a i v = Array.setD a i v
Equations
- Array.appendCore as bs = Array.appendCore.loop bs (Array.size bs) 0 as
Equations
- Array.appendCore.loop bs 0 j as = if hlt : j < Array.size bs then as else as
- Array.appendCore.loop bs (Nat.succ i') j as = if hlt : j < Array.size bs then Array.appendCore.loop bs i' (j + 1) (Array.push as (Array.get bs { val := j, isLt := hlt })) else as
Equations
- List.toArrayAux [] _fun_discr = _fun_discr
- List.toArrayAux (a :: as) _fun_discr = List.toArrayAux as (Array.push _fun_discr a)
Equations
- List.redLength [] = 0
- List.redLength (head :: as) = Nat.succ (List.redLength as)
Equations
- List.toArray as = List.toArrayAux as (Array.mkEmpty (List.redLength as))
- bind : {α β : Type u} → m α → (α → m β) → m β
Instances
- pure : {α : Type u} → α → f α
Instances
- map : {α β : Type u} → (α → β) → f α → f β
- mapConst : {α β : Type u} → α → f β → f α
- seq : {α β : Type u} → f (α → β) → (Unit → f α) → f β
Instances
- seqLeft : {α β : Type u} → f α → (Unit → f β) → f α
Instances
- seqRight : {α β : Type u} → f α → (Unit → f β) → f β
Instances
Instances
- ExceptCpsT.instMonadExceptCpsT
- instMonadEIO
- ExceptT.instMonadExceptT
- Id.instMonadId
- instMonadBaseIO
- instMonadOption
- StateRefT'.instMonadStateRefT'
- StateT.instMonadStateT
- StateCpsT.instMonadStateCpsT
- ReaderT.instMonadReaderT
- EStateM.instMonadEStateM
- instMonadEST
- instMonadST
- Except.instMonadExcept
- OptionT.instMonadOptionT
Equations
- instInhabitedForAll_2 = { default := pure }
Equations
- Array.sequenceMap as f = Array.sequenceMap.loop as f (Array.size as) 0 Array.empty
Equations
- Array.sequenceMap.loop as f 0 j bs = if hlt : j < Array.size as then pure bs else pure bs
- Array.sequenceMap.loop as f (Nat.succ i') j bs = if hlt : j < Array.size as then do let b ← f (Array.get as { val := j, isLt := hlt }) Array.sequenceMap.loop as f i' (j + 1) (Array.push bs b) else pure bs
- monadLift : {α : Type u} → m α → n α
A Function for lifting a computation from an inner Monad to an outer Monad.
Like MonadTrans,
but n
does not have to be a monad transformer.
Alternatively, an implementation of MonadLayer without layerInvmap
(so far).
Instances
- ExceptCpsT.instMonadLiftExceptCpsT
- ExceptT.instMonadLiftExceptT
- StateRefT'.instMonadLiftStateRefT'
- StateT.instMonadLiftStateT
- StateCpsT.instMonadLiftStateCpsT
- ReaderT.instMonadLiftReaderT
- OptionT.instMonadLiftOptionT
- instMonadLiftBaseIOEIO
- instMonadLiftSTEST
- IO.instMonadLiftSTRealWorldBaseIO
- ExceptT.instMonadLiftExceptExceptT
- monadLift : {α : Type u} → m α → n α
The reflexive-transitive closure of MonadLift
.
monadLift
is used to transitively lift monadic computations such as StateT.get
or StateT.puts
.
Corresponds to MonadLift.
Instances
Equations
- instMonadLiftT m n o = { monadLift := fun {α} x => MonadLift.monadLift (monadLift x) }
Equations
- instMonadLiftT_1 m = { monadLift := fun {α} x => x }
- monadMap : {α : Type u} → ({β : Type u} → m β → m β) → n α → n α
A functor in the category of monads. Can be used to lift monad-transforming functions. Based on pipes' MFunctor, but not restricted to monad transformers. Alternatively, an implementation of MonadTransFunctor.
- monadMap : {α : Type u} → ({β : Type u} → m β → m β) → n α → n α
The reflexive-transitive closure of MonadFunctor
.
monadMap
is used to transitively lift Monad morphisms
Instances
Equations
- instMonadFunctorT m n o = { monadMap := fun {α} f => MonadFunctor.monadMap fun {β} => monadMap fun {β} => f β }
Equations
- monadFunctorRefl m = { monadMap := fun {α} f => f α }
Equations
- instInhabitedExcept = { default := Except.error default }
- throw : {α : Type v} → ε → m α
- tryCatch : {α : Type v} → m α → (ε → m α) → m α
An implementation of MonadError
Instances
- ExceptCpsT.instMonadExceptOfExceptCpsT
- instMonadExceptOfEIO
- instMonadExceptOfExceptT
- instMonadExceptOfExceptT_1
- StateRefT'.instMonadExceptOfStateRefT'
- StateT.instMonadExceptOfStateT
- ReaderT.instMonadExceptOfReaderT
- EStateM.instMonadExceptOfEStateM
- instMonadExceptOfEST
- instMonadExceptOfExcept
- OptionT.instMonadExceptOfOptionT
- instMonadExceptOfUnitOption
- OptionT.instMonadExceptOfUnitOptionT
Equations
- throwThe ε e = MonadExceptOf.throw e
Equations
- tryCatchThe ε x handle = MonadExceptOf.tryCatch x handle
- throw : {α : Type v} → ε → m α
- tryCatch : {α : Type v} → m α → (ε → m α) → m α
Similar to MonadExceptOf
, but ε
is an outParam for convenience
Instances
Equations
- instMonadExcept ε m = { throw := fun {α} => throwThe ε, tryCatch := fun {α} => tryCatchThe ε }
Equations
- MonadExcept.orElse t₁ t₂ = tryCatch t₁ fun x => t₂ ()
Equations
- MonadExcept.instOrElse = { orElse := MonadExcept.orElse }
Equations
- instInhabitedReaderT ρ m α = { default := fun x => default }
Equations
- ReaderT.run x r = x r
Equations
- ReaderT.instMonadLiftReaderT = { monadLift := fun {α} x x_1 => x }
Equations
- ReaderT.instMonadExceptOfReaderT ε = { throw := fun {α} e => liftM (throw e), tryCatch := fun {α} x c r => tryCatchThe ε (x r) fun e => c e r }
Equations
- ReaderT.read = pure
Equations
- ReaderT.pure a x = pure a
Equations
- ReaderT.bind x f r = do let a ← x r f a r
Equations
- ReaderT.map f x r = f <$> x r
Equations
- ReaderT.instMonadFunctorReaderT ρ m = { monadMap := fun {α} f x ctx => f α (x ctx) }
Equations
- ReaderT.adapt f x r = x (f r)
- read : m ρ
An implementation of MonadReader.
It does not contain local
because this Function cannot be lifted using monadLift
.
Instead, the MonadReaderAdapter
class provides the more general adaptReader
Function.
Note: This class can be seen as a simplification of the more "principled" definition
```
class MonadReader (ρ : outParam (Type u)) (n : Type u → Type u) where
lift {α : Type u} : ({m : Type u → Type u} → [Monad m] → ReaderT ρ m α) → n α
```
Instances
Equations
- instMonadReader ρ m = { read := readThe ρ }
Equations
- instMonadReaderOfReaderT = { read := ReaderT.read }
- withReader : {α : Type u} → (ρ → ρ) → m α → m α
Equations
- withTheReader ρ f x = MonadWithReaderOf.withReader f x
- withReader : {α : Type u} → (ρ → ρ) → m α → m α
Instances
Equations
- instMonadWithReader ρ m = { withReader := fun {α} => withTheReader ρ }
Equations
- instMonadWithReaderOf = { withReader := fun {α} f => monadMap fun {β} => withTheReader ρ f }
Equations
- instMonadWithReaderOfReaderT = { withReader := fun {α} f x ctx => x (f ctx) }
An implementation of MonadState.
In contrast to the Haskell implementation, we use overlapping instances to derive instances
automatically from monadLift
.
Equations
- modifyThe σ f = MonadStateOf.modifyGet fun s => (PUnit.unit, f s)
Equations
Similar to MonadStateOf
, but σ
is an outParam for convenience
Instances
Equations
- instMonadState σ m = { get := getThe σ, set := set, modifyGet := fun {α} f => MonadStateOf.modifyGet f }
Equations
- modify f = modifyGet fun s => (PUnit.unit, f s)
- ok: {ε σ α : Type u} → α → σ → EStateM.Result ε σ α
- error: {ε σ α : Type u} → ε → σ → EStateM.Result ε σ α
Equations
- EStateM.instInhabitedResult = { default := EStateM.Result.error default default }
Equations
- EStateM ε σ α = (σ → EStateM.Result ε σ α)
Equations
- EStateM.instInhabitedEStateM = { default := fun s => EStateM.Result.error default s }
Equations
- EStateM.pure a s = EStateM.Result.ok a s
Equations
Equations
- EStateM.get s = EStateM.Result.ok s s
Equations
- EStateM.modifyGet f s = match f s with | (a, s) => EStateM.Result.ok a s
Equations
- EStateM.throw e s = EStateM.Result.error e s
- save : σ → δ
- restore : σ → δ → σ
Auxiliary instance for saving/restoring the "backtrackable" part of the state.
Instances
Equations
- EStateM.tryCatch x handle s = let d := EStateM.Backtrackable.save s; match x s with | EStateM.Result.error e s => handle e (EStateM.Backtrackable.restore s d) | ok => ok
Equations
- EStateM.orElse x₁ x₂ s = let d := EStateM.Backtrackable.save s; match x₁ s with | EStateM.Result.error a s => x₂ () (EStateM.Backtrackable.restore s d) | ok => ok
Equations
- EStateM.adaptExcept f x s = match x s with | EStateM.Result.error e s => EStateM.Result.error (f e) s | EStateM.Result.ok a s => EStateM.Result.ok a s
Equations
- EStateM.bind x f s = match x s with | EStateM.Result.ok a s => f a s | EStateM.Result.error e s => EStateM.Result.error e s
Equations
- EStateM.map f x s = match x s with | EStateM.Result.ok a s => EStateM.Result.ok (f a) s | EStateM.Result.error e s => EStateM.Result.error e s
Equations
- EStateM.seqRight x y s = match x s with | EStateM.Result.ok a s => y () s | EStateM.Result.error e s => EStateM.Result.error e s
Equations
- EStateM.instMonadEStateM = Monad.mk
Equations
- EStateM.instOrElseEStateM = { orElse := EStateM.orElse }
Equations
- EStateM.instMonadStateOfEStateM = { get := EStateM.get, set := EStateM.set, modifyGet := fun {α} => EStateM.modifyGet }
Equations
- EStateM.instMonadExceptOfEStateM = { throw := fun {α} => EStateM.throw, tryCatch := fun {α} => EStateM.tryCatch }
Equations
- EStateM.run x s = x s
Equations
- EStateM.run' x s = match EStateM.run x s with | EStateM.Result.ok v a => some v | EStateM.Result.error a a_1 => none
Equations
Equations
- EStateM.dummyRestore s x = s
Equations
- EStateM.nonBacktrackable = { save := EStateM.dummySave, restore := EStateM.dummyRestore }
- hash : α → UInt64
Instances
- instHashable
- instHashableUInt32
- instHashableUInt8
- instHashableOption
- instHashableUInt64
- instHashableUInt16
- instHashableList
- instHashableNat
- instHashableArray
- instHashableProd
- System.instHashableFilePath
- instHashableBool
- instHashablePos
- Lean.instHashableName
- instHashableString
- instHashableUSize
- instHashableFin
- instHashableInt
Equations
- instHashableString = { hash := String.hash }
Equations
- Lean.instInhabitedName = { default := Lean.Name.anonymous }
Equations
- Lean.Name.hash _fun_discr = match _fun_discr with | Lean.Name.anonymous => UInt64.ofNatCore 1723 Lean.Name.hash.proof_1 | Lean.Name.str a a_1 h => h | Lean.Name.num a a_1 h => h
Equations
- Lean.instHashableName = { hash := Lean.Name.hash }
Equations
- Lean.Name.mkStr p s = Lean.Name.str p s (mixHash (hash p) (hash s))
Equations
- Lean.Name.mkNum p v = Lean.Name.num p v (mixHash (hash p) (if h : v < UInt64.size then UInt64.ofNatCore v h else UInt64.ofNatCore 17 Lean.Name.mkNum.proof_1))
Equations
Equations
- Lean.Name.beq Lean.Name.anonymous Lean.Name.anonymous = true
- Lean.Name.beq (Lean.Name.str p₁ s₁ a) (Lean.Name.str p₂ s₂ a_1) = (s₁ == s₂ && Lean.Name.beq p₁ p₂)
- Lean.Name.beq (Lean.Name.num p₁ n₁ a) (Lean.Name.num p₂ n₂ a_1) = (n₁ == n₂ && Lean.Name.beq p₁ p₂)
- Lean.Name.beq _fun_discr _fun_discr = false
Equations
- Lean.Name.instBEqName = { beq := Lean.Name.beq }
Equations
- Lean.Name.append _fun_discr Lean.Name.anonymous = _fun_discr
- Lean.Name.append _fun_discr (Lean.Name.str p s a) = Lean.Name.mkStr (Lean.Name.append _fun_discr p) s
- Lean.Name.append _fun_discr (Lean.Name.num p d a) = Lean.Name.mkNum (Lean.Name.append _fun_discr p) d
Equations
- Lean.Name.instAppendName = { append := Lean.Name.append }
- original: Substring → String.Pos → Substring → String.Pos → Lean.SourceInfo
- synthetic: String.Pos → String.Pos → Lean.SourceInfo
- none: Lean.SourceInfo
Source information of tokens.
Equations
- Lean.instInhabitedSourceInfo = { default := Lean.SourceInfo.none }
Equations
- Lean.SourceInfo.getPos? info originalOnly = match info, originalOnly with | Lean.SourceInfo.original leading pos trailing endPos, x => some pos | Lean.SourceInfo.synthetic pos endPos, false => some pos | x, x_1 => none
- missing: Lean.Syntax
- node: Lean.SourceInfo → Lean.SyntaxNodeKind → Array Lean.Syntax → Lean.Syntax
- atom: Lean.SourceInfo → String → Lean.Syntax
- ident: Lean.SourceInfo → Substring → Lean.Name → List (Lean.Name × List String) → Lean.Syntax
Syntax objects used by the parser, macro expander, delaborator, etc.
Equations
- Lean.instInhabitedSyntax = { default := Lean.Syntax.missing }
Equations
- Lean.scientificLitKind = `scientific
Equations
- Lean.interpolatedStrLitKind = `interpolatedStrLitKind
Equations
- Lean.interpolatedStrKind = `interpolatedStrKind
Equations
- Lean.Syntax.getKind stx = match stx with | Lean.Syntax.node info k args => k | Lean.Syntax.missing => `missing | Lean.Syntax.atom info v => Lean.Name.mkSimple v | Lean.Syntax.ident info rawVal val preresolved => Lean.identKind
Equations
- Lean.Syntax.setKind stx k = match stx with | Lean.Syntax.node info kind args => Lean.Syntax.node info k args | x => stx
Equations
- Lean.Syntax.isOfKind stx k = (Lean.Syntax.getKind stx == k)
Equations
- Lean.Syntax.getArg stx i = match stx with | Lean.Syntax.node info kind args => Array.getD args i Lean.Syntax.missing | x => Lean.Syntax.missing
Equations
- Lean.Syntax.getOp self idx = Lean.Syntax.getArg self idx
Equations
- Lean.Syntax.getArgs stx = match stx with | Lean.Syntax.node info kind args => args | x => Array.empty
Equations
- Lean.Syntax.getNumArgs stx = match stx with | Lean.Syntax.node info kind args => Array.size args | x => 0
Equations
- Lean.Syntax.isMissing _fun_discr = match _fun_discr with | Lean.Syntax.missing => true | x => false
Equations
- Lean.Syntax.isNodeOf stx k n = (Lean.Syntax.isOfKind stx k && Lean.Syntax.getNumArgs stx == n)
Equations
- Lean.Syntax.isIdent _fun_discr = match _fun_discr with | Lean.Syntax.ident info rawVal val preresolved => true | x => false
Equations
- Lean.Syntax.getId _fun_discr = match _fun_discr with | Lean.Syntax.ident info rawVal val preresolved => val | x => Lean.Name.anonymous
Equations
- Lean.Syntax.setArgs stx args = match stx with | Lean.Syntax.node info k args => Lean.Syntax.node info k args | stx => stx
Equations
- Lean.Syntax.setArg stx i arg = match stx with | Lean.Syntax.node info k args => Lean.Syntax.node info k (Array.setD args i arg) | stx => stx
Retrieve the left-most node or leaf's info in the Syntax tree.
Equations
- Lean.Syntax.getHeadInfo stx = match Lean.Syntax.getHeadInfo? stx with | some info => info | none => Lean.SourceInfo.none
Retrieve the left-most leaf's info in the Syntax tree, or none
if there is no token.
Equations
- Lean.Syntax.getPos? stx originalOnly = Lean.SourceInfo.getPos? (Lean.Syntax.getHeadInfo stx) originalOnly
- elemsAndSeps : Array Lean.Syntax
An array of syntax elements interspersed with separators. Can be coerced to/from ArraySyntax
to automatically
remove/insert the separators.
Equations
- Lean.SourceInfo.fromRef ref = let _discr := Lean.Syntax.getTailPos? ref; match Lean.Syntax.getPos? ref, Lean.Syntax.getTailPos? ref with | some pos, some tailPos => Lean.SourceInfo.synthetic pos tailPos | x, x_1 => Lean.SourceInfo.none
Equations
Equations
- Lean.mkAtomFrom src val = Lean.Syntax.atom (Lean.SourceInfo.fromRef src) val
- const: Lean.Name → Lean.ParserDescr
- unary: Lean.Name → Lean.ParserDescr → Lean.ParserDescr
- binary: Lean.Name → Lean.ParserDescr → Lean.ParserDescr → Lean.ParserDescr
- node: Lean.SyntaxNodeKind → Nat → Lean.ParserDescr → Lean.ParserDescr
- trailingNode: Lean.SyntaxNodeKind → Nat → Nat → Lean.ParserDescr → Lean.ParserDescr
- symbol: String → Lean.ParserDescr
- nonReservedSymbol: String → Bool → Lean.ParserDescr
- cat: Lean.Name → Nat → Lean.ParserDescr
- parser: Lean.Name → Lean.ParserDescr
- nodeWithAntiquot: String → Lean.SyntaxNodeKind → Lean.ParserDescr → Lean.ParserDescr
- sepBy: Lean.ParserDescr → String → Lean.ParserDescr → optParam Bool false → Lean.ParserDescr
- sepBy1: Lean.ParserDescr → String → Lean.ParserDescr → optParam Bool false → Lean.ParserDescr
Equations
- Lean.instInhabitedParserDescr = { default := Lean.ParserDescr.symbol "" }
Equations
Equations
Macro scope used internally. It is not available for our frontend.
Equations
First macro scope available for our frontend
- getRef : m Lean.Syntax
- withRef : {α : Type} → Lean.Syntax → m α → m α
Equations
- Lean.instMonadRef m n = { getRef := liftM Lean.getRef, withRef := fun {α} ref x => monadMap (fun {β} => Lean.MonadRef.withRef ref) x }
Equations
- Lean.replaceRef ref oldRef = match Lean.Syntax.getPos? ref with | some val => ref | x => oldRef
Equations
- Lean.withRef ref x = do let oldRef ← Lean.getRef let ref : Lean.Syntax := Lean.replaceRef ref oldRef Lean.MonadRef.withRef ref x
- getCurrMacroScope : m Lean.MacroScope
- getMainModule : m Lean.Name
- withFreshMacroScope : {α : Type} → m α → m α
A monad that supports syntax quotations. Syntax quotations (in term
position) are monadic values that when executed retrieve the current "macro
scope" from the monad and apply it to every identifier they introduce
(independent of whether this identifier turns out to be a reference to an
existing declaration, or an actually fresh binding during further
elaboration). We also apply the position of the result of getRef
to each
introduced symbol, which results in better error positions than not applying
any position.
Equations
- Lean.MonadRef.mkInfoFromRefPos = do let a ← Lean.getRef pure (Lean.SourceInfo.fromRef a)
Equations
- Lean.instMonadQuotation = Lean.MonadQuotation.mk (liftM Lean.getCurrMacroScope) (liftM Lean.getMainModule) fun {α} => monadMap fun {β} => Lean.withFreshMacroScope
Equations
- Lean.Name.hasMacroScopes (Lean.Name.str a s a_1) = (s == "_hyg")
- Lean.Name.hasMacroScopes (Lean.Name.num p a a_1) = Lean.Name.hasMacroScopes p
- Lean.Name.hasMacroScopes _fun_discr = false
Equations
- Lean.Name.eraseMacroScopes n = match Lean.Name.hasMacroScopes n with | true => Lean.eraseMacroScopesAux n | false => n
Equations
- Lean.Name.simpMacroScopes n = match Lean.Name.hasMacroScopes n with | true => Lean.simpMacroScopesAux n | false => n
- name : Lean.Name
- imported : Lean.Name
- mainModule : Lean.Name
- scopes : List Lean.MacroScope
Equations
- Lean.instInhabitedMacroScopesView = { default := { name := default, imported := default, mainModule := default, scopes := default } }
Equations
- Lean.MacroScopesView.review view = match view.scopes with | [] => view.name | head :: tail => let base := Lean.Name.mkStr (Lean.Name.mkStr view.name "_@" ++ view.imported ++ view.mainModule) "_hyg"; List.foldl Lean.Name.mkNum base view.scopes
Equations
- Lean.extractMacroScopes n = match Lean.Name.hasMacroScopes n with | true => Lean.extractMacroScopesAux n [] | false => { name := n, imported := Lean.Name.anonymous, mainModule := Lean.Name.anonymous, scopes := [] }
Revert all addMacroScope
calls. v=extractMacroScopesn→n=v.review
.
This operation is useful for analyzing/transforming the original identifiers, then adding back
the scopes (via MacroScopesView.review
).
Equations
- Lean.addMacroScope mainModule n scp = match Lean.Name.hasMacroScopes n with | true => let view := Lean.extractMacroScopes n; match view.mainModule == mainModule with | true => Lean.Name.mkNum n scp | false => Lean.MacroScopesView.review { name := view.name, imported := List.foldl Lean.Name.mkNum (view.imported ++ view.mainModule) view.scopes, mainModule := mainModule, scopes := [scp] } | false => Lean.Name.mkNum (Lean.Name.mkStr (Lean.Name.mkStr n "_@" ++ mainModule) "_hyg") scp
Equations
- Lean.MonadQuotation.addMacroScope n = do let mainModule ← Lean.getMainModule let scp ← Lean.getCurrMacroScope pure (Lean.addMacroScope mainModule n scp)
Equations
-
Lean.maxRecDepthErrorMessage = "maximum recursion depth has been reached (use `set_option maxRecDepth
` to increase limit)"
Equations
- Lean.Syntax.matchesNull stx n = Lean.Syntax.isNodeOf stx Lean.nullKind n
Equations
Function used for determining whether a syntax pattern `(id)
is matched.
There are various conceivable notions of when two syntactic identifiers should be regarded as identical,
but semantic definitions like whether they refer to the same global name cannot be implemented without
context information (i.e. MonadResolveName
). Thus in patterns we default to the structural solution
of comparing the identifiers' Name
values, though we at least do so modulo macro scopes so that
identifiers that "look" the same match. This is particularly useful when dealing with identifiers that
do not actually refer to Lean bindings, e.g. in the stx
pattern `(many($p))
.
Equations
- Lean.Syntax.matchesLit stx k val = match stx with | Lean.Syntax.node info k' args => k == k' && match Array.getD args 0 Lean.Syntax.missing with | Lean.Syntax.atom info val' => val == val' | x => false | x => false
- methods : Lean.Macro.MethodsRef
- mainModule : Lean.Name
- currMacroScope : Lean.MacroScope
- currRecDepth : Nat
- maxRecDepth : Nat
- ref : Lean.Syntax
- error: Lean.Syntax → String → Lean.Macro.Exception
- unsupportedSyntax: Lean.Macro.Exception
- macroScope : Lean.MacroScope
- traceMsgs : List (Lean.Name × String)
Equations
- Lean.Macro.instInhabitedState = { default := { macroScope := default, traceMsgs := default } }
Equations
Equations
- Lean.Macro.instMonadRefMacroM = { getRef := do let ctx ← read pure ctx.ref, withRef := fun {α} ref x => withReader (fun ctx => { methods := ctx.methods, mainModule := ctx.mainModule, currMacroScope := ctx.currMacroScope, currRecDepth := ctx.currRecDepth, maxRecDepth := ctx.maxRecDepth, ref := ref }) x }
Equations
- Lean.Macro.addMacroScope n = do let ctx ← read pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)
Equations
- Lean.Macro.throwUnsupported = throw Lean.Macro.Exception.unsupportedSyntax
Equations
- Lean.Macro.throwError msg = do let ref ← Lean.getRef throw (Lean.Macro.Exception.error ref msg)
Equations
- Lean.Macro.throwErrorAt ref msg = Lean.withRef ref (Lean.Macro.throwError msg)
Equations
- Lean.Macro.withFreshMacroScope x = do let fresh ← modifyGet fun s => (s.macroScope, { macroScope := s.macroScope + 1, traceMsgs := s.traceMsgs }) withReader (fun ctx => { methods := ctx.methods, mainModule := ctx.mainModule, currMacroScope := fresh, currRecDepth := ctx.currRecDepth, maxRecDepth := ctx.maxRecDepth, ref := ctx.ref }) x
Equations
- Lean.Macro.withIncRecDepth ref x = do let ctx ← read match ctx.currRecDepth == ctx.maxRecDepth with | true => throw (Lean.Macro.Exception.error ref Lean.maxRecDepthErrorMessage) | false => withReader (fun ctx => { methods := ctx.methods, mainModule := ctx.mainModule, currMacroScope := ctx.currMacroScope, currRecDepth := ctx.currRecDepth + 1, maxRecDepth := ctx.maxRecDepth, ref := ctx.ref }) x
Equations
- Lean.Macro.instMonadQuotationMacroM = Lean.MonadQuotation.mk (fun ctx => pure ctx.currMacroScope) (fun ctx => pure ctx.mainModule) fun {α} => Lean.Macro.withFreshMacroScope
- expandMacro? : Lean.Syntax → Lean.MacroM (Option Lean.Syntax)
- getCurrNamespace : Lean.MacroM Lean.Name
- hasDecl : Lean.Name → Lean.MacroM Bool
- resolveNamespace? : Lean.Name → Lean.MacroM (Option Lean.Name)
- resolveGlobalName : Lean.Name → Lean.MacroM (List (Lean.Name × List String))
Equations
- Lean.Macro.instInhabitedMethods = { default := { expandMacro? := default, getCurrNamespace := default, hasDecl := default, resolveNamespace? := default, resolveGlobalName := default } }
Equations
- Lean.Macro.mkMethodsImp methods = unsafeCast methods
Equations
- Lean.Macro.instInhabitedMethodsRef = { default := Lean.Macro.mkMethods default }
Equations
- Lean.Macro.getMethodsImp = do let ctx ← read pure (unsafeCast ctx.methods)
Equations
- Lean.expandMacro? stx = do let a ← Lean.Macro.getMethods Lean.Macro.Methods.expandMacro? a stx
expandMacro?stx
return somestxNew
if stx
is a macro, and stxNew
is its expansion.
Equations
- Lean.Macro.hasDecl declName = do let a ← Lean.Macro.getMethods Lean.Macro.Methods.hasDecl a declName
Return true
if the environment contains a declaration with name declName
Equations
- Lean.Macro.getCurrNamespace = do let a ← Lean.Macro.getMethods a.getCurrNamespace
Equations
Equations
Equations
- Lean.Macro.trace clsName msg = modify fun s => { macroScope := s.macroScope, traceMsgs := (clsName, msg) :: s.traceMsgs }
Equations
Function that tries to reverse macro expansions as a post-processing step of delaboration.
While less general than an arbitrary delaborator, it can be declared without importing Lean
.
Used by the [appUnexpander]
attribute.
Equations
- Lean.PrettyPrinter.instMonadQuotationUnexpandM = Lean.MonadQuotation.mk (pure 0) (pure `_fakeMod) fun {α} => id