Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
74f725d
feat: components in blog genre (#385)
david-christiansen May 8, 2025
e9bfdea
chore: bump dependencies for nightly-2025-05-08 (#386)
david-christiansen May 8, 2025
b84b44c
feat: upstream table from reference manual (#387)
david-christiansen May 9, 2025
ae75e7c
feat: generate directives for block components (#388)
david-christiansen May 9, 2025
9abbbd3
chore: document and partially enforce new procedures (#381)
david-christiansen May 8, 2025
bed7ef0
chore: bump to latest SubVerso and Lean nightly (#390)
david-christiansen May 13, 2025
2dbcc19
fix: use correct internal name for table block (#391)
david-christiansen May 13, 2025
ff98b5d
fix: allow list item contents to be on new line (#392)
david-christiansen May 13, 2025
8ecbcf1
fix: behavior of SVG tags inside the HTML (#393)
algebraic-dev May 14, 2025
0640f56
feat: manual genre can display Lean code from external projects (#394)
david-christiansen May 14, 2025
043463a
feat: allow namespace suppression when extracting external code (#395)
david-christiansen May 14, 2025
2a9cb61
chore: remove redundant error mods (#397)
david-christiansen May 15, 2025
fd08088
feat: use upstream hints infrastructure in errors (#398)
david-christiansen May 19, 2025
e6e76b8
chore: bump to nightly-2025-05-19 (#399)
david-christiansen May 19, 2025
40ce546
feat: alternative approach to incrementality (#400)
david-christiansen May 21, 2025
3139a69
feat: generalize external Lean code display (#401)
david-christiansen May 21, 2025
2b6f771
fix: also generate document when text is empty (#402)
david-christiansen May 22, 2025
67226e3
feat: bundle KaTeX and include by default in manual genre (#403)
david-christiansen May 23, 2025
fa999d4
fix: external code rebuilds and hints (#404)
david-christiansen May 23, 2025
4683bef
feat: suggest code samples based on string contents (#405)
david-christiansen May 27, 2025
1bc3b92
feat: document elaboration hooks (#406)
david-christiansen May 27, 2025
492b919
chore: bump toolchain to nightly-2025-05-27
kim-em May 28, 2025
0325484
fix: default anchor suggestions to false (#407)
david-christiansen May 28, 2025
950a1c5
fix: more reliable external module extraction (#408)
david-christiansen May 28, 2025
a8af964
fix: incorporate SubVerso improvements to error/tactic spans (#409)
david-christiansen May 29, 2025
136f897
chore: bump to 2025-06-01 (#413)
david-christiansen Jun 2, 2025
63a83d9
chore: bump to 2025-06-05 (#423)
david-christiansen Jun 5, 2025
9447236
Merge remote-tracking branch 'upstream/main' into nightly-testing
david-christiansen Jun 5, 2025
df6ff8e
feat: show hovers on closing delimiters (#428)
david-christiansen Jun 10, 2025
9849330
chore: bump to 2025-06-09
david-christiansen Jun 10, 2025
9dccd5b
chore: bump nightly-testing to 2025 06 20 and merge main (#447)
david-christiansen Jun 20, 2025
4ccf296
chore: bump to nightly-2025-06-23 and merge `main` (#452)
david-christiansen Jun 23, 2025
80a0d45
chore: bump nightly testing to 2025-06-24 and merge main (#455)
david-christiansen Jun 25, 2025
b5a40e6
chore: merge main into nightly-testing
github-actions[bot] Jun 26, 2025
f508c4d
chore: bump to nightly nightly-2025-06-26
github-actions[bot] Jun 26, 2025
b61da56
chore: bump to nightly nightly-2025-06-27
github-actions[bot] Jun 27, 2025
9cb5e1c
chore: bump to nightly nightly-2025-06-28
github-actions[bot] Jun 28, 2025
9971a71
chore: bump to nightly nightly-2025-06-29
github-actions[bot] Jun 29, 2025
eca90f1
chore: delete file that shouldn't have been committed
david-christiansen Jun 30, 2025
a362a2e
chore: merge main into nightly-testing
github-actions[bot] Jun 30, 2025
6218e55
chore: bump to nightly nightly-2025-06-30
github-actions[bot] Jun 30, 2025
24694c2
chore: merge main into nightly-testing
github-actions[bot] Jun 30, 2025
65a1348
chore: merge main into nightly-testing
github-actions[bot] Jul 1, 2025
adb84ec
chore: merge main into nightly-testing
github-actions[bot] Jul 3, 2025
db0b75a
chore: merge main into nightly-testing
github-actions[bot] Jul 4, 2025
9fcf7d8
chore: merge main into nightly-testing
github-actions[bot] Jul 4, 2025
b90b1f5
chore: bump to nightly-2025-07-04 (#468)
david-christiansen Jul 4, 2025
8440af2
chore: bump to nightly nightly-2025-07-05
github-actions[bot] Jul 5, 2025
a886817
chore: bump to nightly nightly-2025-07-06
github-actions[bot] Jul 6, 2025
0416a91
chore: bump to nightly nightly-2025-07-07
github-actions[bot] Jul 7, 2025
c486545
chore: bump to nightly nightly-2025-07-08
github-actions[bot] Jul 8, 2025
8bd2edc
chore: bump to nightly nightly-2025-07-09
github-actions[bot] Jul 9, 2025
4d78bfd
chore: bump to nightly nightly-2025-07-10
github-actions[bot] Jul 10, 2025
f3f417e
chore: bump to nightly nightly-2025-07-11
github-actions[bot] Jul 11, 2025
b8dce7f
chore: bump to nightly nightly-2025-07-12
github-actions[bot] Jul 12, 2025
a74c35c
chore: bump to nightly nightly-2025-07-13
github-actions[bot] Jul 13, 2025
02373d3
chore: bump to nightly-2025-07-19 (#470)
david-christiansen Jul 21, 2025
9cd6bd6
chore: merge main into nightly-testing
github-actions[bot] Jul 21, 2025
ada932d
chore: bump to nightly nightly-2025-07-21
github-actions[bot] Jul 21, 2025
3fdbc5c
chore: bump to nightly-2025-07-22 (#473)
david-christiansen Jul 22, 2025
0131acc
chore: merge main into nightly-testing
github-actions[bot] Jul 23, 2025
a3b5150
chore: merge main into nightly-testing
github-actions[bot] Jul 24, 2025
ed133a0
chore: bump to nightly nightly-2025-07-24
github-actions[bot] Jul 24, 2025
1e4bbba
chore: bump to nightly nightly-2025-07-25
github-actions[bot] Jul 25, 2025
29d6c48
chore: bump to nightly-2025-07-27 (#481)
david-christiansen Jul 28, 2025
3e7365d
chore: merge main into nightly-testing
github-actions[bot] Jul 28, 2025
689a5ba
chore: bump to nightly nightly-2025-07-28
github-actions[bot] Jul 28, 2025
dec08c7
chore: merge main into nightly-testing
github-actions[bot] Jul 29, 2025
a8cbc7e
chore: bump to nightly nightly-2025-07-29
github-actions[bot] Jul 29, 2025
89258d5
fix: make go-to-def work with latest nightly (#483)
david-christiansen Jul 29, 2025
ce563c6
chore: merge main into nightly-testing
github-actions[bot] Jul 29, 2025
2fa183b
chore: bump to nightly nightly-2025-07-30
github-actions[bot] Jul 30, 2025
0c69d2b
chore: merge main into nightly-testing
github-actions[bot] Jul 30, 2025
73f65a6
chore: merge main into nightly-testing
github-actions[bot] Jul 30, 2025
be129f7
chore: bump to nightly nightly-2025-07-31
github-actions[bot] Jul 31, 2025
1e004d1
chore: merge main into nightly-testing
github-actions[bot] Aug 1, 2025
4fc4cb6
chore: merge main into nightly-testing
github-actions[bot] Aug 1, 2025
0c00a34
chore: merge main into nightly-testing
github-actions[bot] Aug 2, 2025
6005cd6
chore: merge main into nightly-testing
github-actions[bot] Aug 4, 2025
8c51a3f
chore: bump to nightly-2025-08-04 (#491)
david-christiansen Aug 4, 2025
87d71bf
chore: merge main into nightly-testing
github-actions[bot] Aug 5, 2025
8f39675
chore: bump to nightly nightly-2025-08-05
github-actions[bot] Aug 5, 2025
50bacc1
chore: merge main into nightly-testing
github-actions[bot] Aug 5, 2025
d592526
chore: merge main into nightly-testing
github-actions[bot] Aug 7, 2025
9a26339
chore: bump to nightly-2025-08-07 (#496)
david-christiansen Aug 7, 2025
7d78c34
chore: switch back to main md4lean (#497)
david-christiansen Aug 7, 2025
3b2d25c
chore: bump to nightly nightly-2025-08-08
github-actions[bot] Aug 8, 2025
bd4c863
chore: bump to nightly nightly-2025-08-10
github-actions[bot] Aug 10, 2025
3a33a08
chore: bump to nightly nightly-2025-08-11
github-actions[bot] Aug 11, 2025
c285ac4
chore: bump to nightly nightly-2025-08-12
github-actions[bot] Aug 12, 2025
f1597c5
chore: bump to nightly nightly-2025-08-13
github-actions[bot] Aug 13, 2025
c946ca8
chore: bump toolchain to v4.23.0-rc1
kim-em Aug 14, 2025
b3ea75a
Merge remote-tracking branch 'origin/nightly-testing' into bump_to_v4…
kim-em Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/textbook/DemoTextbook.lean
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Expected error messages must be indicated explicitly:
#eval y
```
```leanOutput yVal
unknown identifier 'y'
Unknown identifier `y`
```

{include 1 DemoTextbook.Nat}
Expand Down
6 changes: 3 additions & 3 deletions examples/website/DemoSite/Blog/Conditionals.lean
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ Here's some hoverable info:
example : Nat := "Not a number"
```
```leanOutput typeErr
type mismatch
Type mismatch
"Not a number"
has type
String : Type
String
but is expected to have type
Nat : Type
Nat
```


Expand Down
2 changes: 1 addition & 1 deletion lake-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "git",
"subDir": null,
"scope": "",
"rev": "b16338c5c66f57ef5510d4334eb6fa4e2c6c8cd8",
"rev": "feac4e0c356b0928657bf3b54fa83ae952f53257",
"name": "MD4Lean",
"manifestFile": "lake-manifest.json",
"inputRev": "main",
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.22.0-rc4
leanprover/lean4:v4.23.0-rc1
2 changes: 1 addition & 1 deletion src/multi-verso/MultiVerso.lean
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private def RemoteInfo.structBEq (x y : RemoteInfo) : Bool :=
x1 == x2 &&
y1 == y2 &&
doms1.size == doms2.size &&
doms1.fold (init := true) fun soFar k v =>
doms1.foldl (init := true) fun soFar k v =>
soFar && (doms2.find? k).isEqSome v

private unsafe def RemoteInfo.fastBEq (x y : RemoteInfo) : Bool :=
Expand Down
172 changes: 115 additions & 57 deletions src/multi-verso/MultiVerso/Slug.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,95 @@ open Verso.Method
open Lean (ToJson FromJson)
open Std (HashSet)

private def validCharString := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"


/-- The characters allowed in slugs. -/
def Slug.validChars := HashSet.ofList "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_".toList
def Slug.validChars := HashSet.ofList validCharString.toList

/--
A slug is well-formed if all its characters are valid.
-/
def Slug.WF (str : String) : Prop :=
str.toList.all (· ∈ validChars)

open Lean Elab Command in
#eval show CommandElabM Unit from do
let mut iter := validCharString.iter
while h : iter.hasNext do
let c := iter.curr' h
iter := iter.next' h
let n := mkIdent <| `Slug ++ (.str .anonymous s!"'{c}'_mem_validChars")
let cmd ←
`(@[simp, grind] protected theorem $n : ($(quote c) ∈ Slug.validChars) := by simp [Slug.validChars, validCharString])
elabCommand cmd


private def mangle (c : Char) : String :=
match c with
| '<' => "_LT_"
| '>' => "_GT_"
| ';' => "_SEMI_"
| '‹' => "_FLQ_"
| '›' => "_FRQ_"
| '«' => "_FLQQ_"
| '»' => "_FLQQ_"
| '⟨' => "_LANGLE_"
| '⟩' => "_RANGLE_"
| '(' => "_LPAR_"
| ')' => "_RPAR_"
| '[' => "_LSQ_"
| ']' => "_RSQ_"
| '→' => "_ARR_"
| '↦' => "_MAPSTO_"
| '⊢' => "_VDASH_"
| _ => "___"
replacements.lookup c |>.getD "___"
where
replacements : List (Char × String) := [
('<', "_LT_"),
('>', "_GT_"),
(';', "_SEMI_"),
('‹', "_FLQ_"),
('›', "_FRQ_"),
('«', "_FLQQ_"),
('»', "_FLQQ_"),
('⟨', "_LANGLE_"),
('⟩', "_RANGLE_"),
('(', "_LPAR_"),
(')', "_RPAR_"),
('[', "_LSQ_"),
(']', "_RSQ_"),
('→', "_ARR_"),
('↦', "_MAPSTO_"),
('⊢', "_VDASH_")
]


@[simp, grind] theorem mangle.replacements_all_wf : (k, v) ∈ mangle.replacements → Slug.WF v := by
simp [Slug.WF, replacements]
intro
repeat (rename_i hk; cases hk; simp [*])

@[simp, grind]
private theorem mangle.replacements_wf (c : Char) : (c, s) ∈ mangle.replacements → Slug.WF (mangle c) := by
unfold mangle
generalize h : mangle.replacements = reps
have : ∀ k v, (k, v) ∈ reps → Slug.WF v := by
rw [← h]
grind only [=_ List.contains_iff_mem, mangle.replacements_all_wf]
clear h
fun_induction List.lookup <;> first | grind | simp

@[simp, grind]
private theorem mangle_wf (c : Char) : Slug.WF (mangle c) := by
unfold mangle
by_cases h : ∃ s, (c, s) ∈ mangle.replacements
. let ⟨w, p⟩ := h
apply mangle.replacements_wf _ p
. suffices List.lookup c mangle.replacements = none by
rw [this]
simp [Slug.WF]
generalize h' : mangle.replacements = xs
rw [h'] at h
clear h'
fun_induction List.lookup with try ((first | grind | simp); done)
| case2 _ _ _ _ beq =>
have := LawfulBEq.eq_of_beq beq
exfalso
apply h
simp [*]


@[simp, grind]
private theorem mangle_mem_valid (c : Char) : c ∈ (mangle c').data → c ∈ Slug.validChars := by
intro mem
have := mangle_wf c'
simp [Slug.WF] at this
apply this
assumption

/--
Converts a string to a valid slug, mangling as appropriate.
Expand All @@ -50,16 +117,13 @@ def asSlug (str : String) : String :=
else acc ++ mangle c
loop str.iter ""

/--
A slug is well-formed if all its characters are valid.
-/
def Slug.WF (str : String) : Prop :=
str.toList.all (· ∈ validChars)

instance : Decidable (c ∈ Slug.validChars) := inferInstance

instance [DecidablePred p] : Decidable (String.all s (p ·)) :=
if h : String.all s (p ·) then isTrue h else isFalse h
if h : String.all s (p ·) then
isTrue h
else
isFalse h

@[simp]
theorem String.empty_all_eq_true : "".all p = true := by
Expand All @@ -68,59 +132,53 @@ theorem String.empty_all_eq_true : "".all p = true := by
@[simp]
theorem String.Pos.add_0_eq_size {c : Char} : (0 : String.Pos) + c = ⟨c.utf8Size⟩ := by
simp only [HAdd.hAdd, String.Pos.byteIdx_zero, String.Pos.mk.injEq]
show 0 + c.utf8Size = c.utf8Size
simp
grind

instance : DecidablePred Slug.WF := fun str =>
if h : str.toList.all (· ∈ Slug.validChars) then isTrue (by unfold Slug.WF; exact h) else isFalse h

@[simp]
theorem Slug.wf_mangle : WF (mangle c) := by
unfold mangle
split <;> dsimp [WF, validChars] <;> simp
if h : str.toList.all (· ∈ Slug.validChars) then
isTrue h
else
isFalse h

@[grind]
theorem Slug.wf_push (c str) : c ∈ validChars → WF str → WF (str.push c) := by
unfold WF
cases str
intro mem wf
simp only [String.toList, List.all_eq_true, decide_eq_true_eq] at wf
simp only [String.toList, String.data_push, List.all_append, List.all_cons, List.all_nil,
Bool.and_true, Bool.and_eq_true, List.all_eq_true, decide_eq_true_eq]
and_intros <;> simp at wf <;> assumption
grind only

@[grind]
theorem Slug.wf_append (str1 str2) : WF str1 → WF str2 → WF (str1 ++ str2) := by
unfold WF
cases str1; cases str2
intro wf1 wf2
simp only [String.toList, String.data_append, List.all_append, Bool.and_eq_true, List.all_eq_true, decide_eq_true_eq]
simp only [String.toList, List.all_eq_true, decide_eq_true_eq] at wf1 wf2
and_intros <;> assumption
grind only

@[simp]
theorem Slug.decide_WF_eq_wf (s : String) : (s.toList.all (fun x => decide (x ∈ validChars)) = true) = WF s := by
rfl

@[grind, simp]
theorem Slug.wf_forall : WF s → c ∈ s.data → c ∈ validChars := by
intro wf h
simp_all [WF]

theorem Slug.asSlug_loop_valid : WF acc → WF (asSlug.loop iter acc) := by
intro wfAcc
induction iter, acc using asSlug.loop.induct <;> unfold asSlug.loop <;> simp [*]
case case2 iter acc notEnd c ih =>
fun_induction asSlug.loop with try assumption
| case2 iter acc notEnd c ih =>
apply ih
unfold WF
simp only [WF, String.toList, List.all_eq_true, decide_eq_true_eq] at wfAcc
split
. simp only [String.toList, String.data_push, List.all_append, List.all_cons, List.all_nil,
Bool.and_true, Bool.and_eq_true, List.all_eq_true, decide_eq_true_eq]
and_intros <;> assumption
. split
. simp only [String.toList, ↓Char.isValue, String.data_push, List.all_append, List.all_cons,
List.all_nil, Bool.and_true, Bool.and_eq_true, List.all_eq_true, decide_eq_true_eq]
and_intros
. assumption
. simp [validChars]
. simp only [String.toList, String.data_append, List.all_append, Bool.and_eq_true,
List.all_eq_true, decide_eq_true_eq]
and_intros
. assumption
. intro c' mem
have : WF (mangle c) := wf_mangle
simp only [WF, String.toList, List.all_eq_true, decide_eq_true_eq] at this
simp [*]
(repeat' split) <;>
simp [*] <;>
grind only [=_ List.contains_iff_mem, List.contains_eq_mem, mangle_wf, wf_forall, mangle_mem_valid, wf_append, cases Or]

@[grind]
theorem Slug.asSlug_valid : WF (asSlug str) := by
unfold asSlug
apply asSlug_loop_valid
Expand Down
1 change: 0 additions & 1 deletion src/verso-blog/VersoBlog.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Verso.Doc.Suggestion
import Verso.Hover
import Verso.WithoutAsync
open Verso.Output Html
open Lean (RBMap)

namespace Verso.Genre.Blog

Expand Down
4 changes: 2 additions & 2 deletions src/verso-blog/VersoBlog/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ structure TraverseContext where
components : Components

structure TraverseState where
usedIds : Lean.RBMap (List String) (HashSet String) compare := {}
usedIds : Std.HashMap (List String) (HashSet String) := {}
targets : Lean.NameMap Blog.Info.Target := {}
blogs : Lean.NameMap Blog.Info.ArchivesMeta := {}
refs : Lean.NameMap Blog.Info.Ref := {}
Expand Down Expand Up @@ -334,7 +334,7 @@ defmethod BlogPost.summary (post : BlogPost) : Array (Block Post) := Id.run do

partial def TraverseState.freshId (state : Blog.TraverseState) (path : List String) (hint : Lean.Name) : String := Id.run do
let mut idStr := mangle (toString hint)
match state.usedIds.find? path with
match state.usedIds[path]? with
| none => return idStr
| some used =>
while used.contains idStr do
Expand Down
4 changes: 2 additions & 2 deletions src/verso-blog/VersoBlog/Component.lean
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ deriving TypeName

open Lean in
def Components.fromLists (blocks : List (Name × BlockComponent)) (inlines : List (Name × InlineComponent)) : Components where
blocks := .fromList (blocks.map fun (x, b) => (x, Dynamic.mk b)) _
inlines := .fromList (inlines.map fun (x, b) => (x, Dynamic.mk b)) _
blocks := .ofList (blocks.map fun (x, b) => (x, Dynamic.mk b)) _
inlines := .ofList (inlines.map fun (x, b) => (x, Dynamic.mk b)) _

open Lean in
private def nameAndDef [Monad m] [MonadRef m] [MonadQuotation m] (ext : Name × Name) : m Term := do
Expand Down
4 changes: 2 additions & 2 deletions src/verso-blog/VersoBlog/Component/Ext.lean
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ initialize blockComponentExt :
addImportedFn := fun _ => pure {},
addEntryFn := fun as (src, tgt) => as.insert src tgt,
exportEntriesFn := fun es =>
es.fold (fun a src tgt => a.push (src, tgt)) #[] |>.qsort (Name.quickLt ·.1 ·.1)
es.foldl (fun a src tgt => a.push (src, tgt)) #[] |>.qsort (Name.quickLt ·.1 ·.1)
}

initialize inlineComponentExt :
Expand All @@ -25,5 +25,5 @@ initialize inlineComponentExt :
addImportedFn := fun _ => pure {},
addEntryFn := fun as (src, tgt) => as.insert src tgt,
exportEntriesFn := fun es =>
es.fold (fun a src tgt => a.push (src, tgt)) #[] |>.qsort (Name.quickLt ·.1 ·.1)
es.foldl (fun a src tgt => a.push (src, tgt)) #[] |>.qsort (Name.quickLt ·.1 ·.1)
}
19 changes: 9 additions & 10 deletions src/verso-blog/VersoBlog/Template.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import Verso.Output.Html
import Verso.Output.Html.CssVars
import Verso.Code

open Std (HashSet)
open Lean (RBMap)
open Std (HashSet TreeMap)

open Verso Doc Output Html HtmlT
open Verso.Genre Blog
Expand Down Expand Up @@ -52,9 +51,9 @@ instance : Coe Html Template.Params.Val where
| other => ⟨.mk other, #[]⟩


def Params := RBMap String Params.Val compare
def Params := TreeMap String Params.Val

instance : EmptyCollection Params := inferInstanceAs <| EmptyCollection (RBMap _ _ _)
instance : EmptyCollection Params := inferInstanceAs <| EmptyCollection (TreeMap _ _ _)

inductive Error where
| missingParam (param : String)
Expand Down Expand Up @@ -258,16 +257,16 @@ namespace Verso.Genre.Blog.Template
namespace Params

def ofList (params : List (String × Val)) : Params :=
Lean.RBMap.ofList params
Std.TreeMap.ofList params _

def toList (params : Params) : List (String × Val) :=
Lean.RBMap.toList params
Std.TreeMap.toList params

def insert (params : Params) (key : String) (val : Val) : Params :=
Lean.RBMap.insert params key val
Std.TreeMap.insert params key val

def erase (params : Params) (key : String) : Params :=
Lean.RBMap.erase params key
Std.TreeMap.erase params key


end Params
Expand All @@ -287,15 +286,15 @@ namespace Template

def param? [TypeName α] (key : String) : TemplateM (Option α) := do
let ctx ← readThe Context
match ctx.params.find? key with
match ctx.params.get? key with
| none => return none
| some val =>
if let some v := val.get? (α := α) then return (some v)
else throw <| .wrongParamType key (TypeName.typeName α)


def param [TypeName α] (key : String) : TemplateM α := do
match (← read).params.find? key with
match (← read).params.get? key with
| none => throw <| .missingParam key
| some val =>
if let some v := val.get? (α := α) then return v
Expand Down
2 changes: 1 addition & 1 deletion src/verso-manual/VersoManual/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ instance : BEq Domains where
x.all fun k v => y.find? k |>.isEqSome v

instance : GetElem Domains Name Domain (fun ds d => ds.contents.contains d) where
getElem ds d _ok := ds.contents.find! d
getElem ds d _ok := ds.contents.get! d

instance : GetElem? Domains Name Domain (fun ds d => ds.contents.contains d) where
getElem? ds d := ds.contents.find? d
Expand Down
Loading