Skip to content

Commit 84eb71b

Browse files
mars0iMarshall Abrams
andauthored
Added AVL.Map suggestion, explanation of MkValue args. (#2447)
* Added AVL.Map suggestion, explanation of MkValue args. * Added AVL.Map suggestion, explanation of MkValue args. * Added backticks, other formatting, clarified (Vec String) as function. As suggested by @MatthewDaggit. I also lowercased the initial letter after colon in third new paragraph. --------- Co-authored-by: Marshall Abrams <[email protected]>
1 parent 61e7707 commit 84eb71b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/README/Data/Tree/AVL.agda

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ open import Relation.Binary.PropositionalEquality
2828
open Data.Tree.AVL <-strictTotalOrder renaming (Tree to Tree′)
2929
Tree = Tree′ (MkValue (Vec String) (subst (Vec String)))
3030

31+
-- The first argument to `MkValue` should be a function from a key
32+
-- (a `ℕ` in this case) to a value type (a `String` vector type).
33+
-- Since `(Vec String)` is missing `Vec`'s second parameter, a `ℕ`,
34+
-- it's equivalent to `λ n → Vec String n`.
35+
36+
-- The second argument to `MkValue` is a function that can accept
37+
-- a proof that two keys are equal, and then substitute a unique key
38+
-- for an equivalent key that is passed in. Applying `subst` to the
39+
-- key-to-value-type function passed as `MkValue`'s first argument is
40+
-- a normal way to create such a function.
41+
42+
-- Note that there is no need to define the type of keys separately:
43+
-- passing a key-to-value-type function to `MkValue` and providing
44+
-- the result of `MkValue` to `Data.Tree.AVL.Tree` is enough.
45+
3146
------------------------------------------------------------------------
3247
-- Construction of trees
3348

@@ -127,6 +142,10 @@ v₉ = refl
127142

128143
-- Variations of the AVL tree module are available:
129144

145+
-- • Finite maps in which types of values don't depend on keys.
146+
147+
import Data.Tree.AVL.Map
148+
130149
-- • Finite maps with indexed keys and values.
131150

132151
import Data.Tree.AVL.IndexedMap

0 commit comments

Comments
 (0)