M repoint-lock.json +2 -2
@@ 7,10 7,10 @@
"pin": "45d450aedb1f"
},
"sml-trie": {
- "pin": "f78215386849"
+ "pin": "2d2572df578d"
},
"sml-stringinterpolate": {
- "pin": "b2ef1dd1d62b"
+ "pin": "7aeea879e5af"
},
"sml-log": {
"pin": "0084064e40bf"
M src/parse-serialise/prefix-table.sml +25 -54
@@ 1,51 1,19 @@
-
-structure IriTrie :> TRIE where type entry = Iri.t = struct
- structure WordVectorTrie
- = TrieFn (VectorMTrieMapFn(struct
+structure IriTrieArg : TRIE_MAP_KEYADAPTER_FN_ARG = struct
+
+ structure T = VectorMTrieMapFn(struct
type t = word
val compare = Word.compare
- end))
-
- type t = WordVectorTrie.trie
-
- (*!!! should be wrapper fn in trie for this *)
-
- type trie = t
- type entry = Iri.t
-
- val empty = WordVectorTrie.empty
- val isEmpty = WordVectorTrie.isEmpty
-
- fun explode iri = WdString.toVector (Iri.toWideString iri)
- fun implode ws = Iri.fromWideString (WdString.fromVector ws)
-
- fun add (trie, s) =
- WordVectorTrie.add (trie, explode s)
+ end)
- fun contains (trie, s) =
- WordVectorTrie.contains (trie, explode s)
-
- fun remove (trie, s) =
- WordVectorTrie.remove (trie, explode s)
-
- fun foldl f acc trie =
- WordVectorTrie.foldl (fn (e, acc) => f (implode e, acc)) acc trie
-
- fun enumerate trie =
- List.map implode (WordVectorTrie.enumerate trie)
+ type key = T.key
+ type external_key = Iri.t
+ fun enkey iri = WdString.toVector (Iri.toWideString iri)
+ fun dekey ws = Iri.fromWideString (WdString.fromVector ws)
+
+end
- fun foldlPrefixMatch f acc (trie, s) =
- WordVectorTrie.foldlPrefixMatch (fn (e, acc) => f (implode e, acc))
- acc (trie, explode s)
-
- fun prefixMatch (trie, s) =
- List.map implode (WordVectorTrie.prefixMatch (trie, explode s))
-
- fun prefixOf (trie, s) =
- implode (WordVectorTrie.prefixOf (trie, explode s))
-
-end
+structure IriTrie = TrieFn (TrieMapKeyAdapterFn (IriTrieArg))
structure PrefixTable :> PREFIX_TABLE = struct
@@ 111,21 79,24 @@ structure PrefixTable :> PREFIX_TABLE =
WdString.fromUtf8 (String.concatWith ":" rest))
fun abbreviate ((_, reverse, trie) : t, iri) =
- let val prefix = IriTrie.prefixOf (trie, iri)
+ let val prefixOpt = IriTrie.prefixOf (trie, iri)
open WdString
fun dropPrefix (iri, n) =
implode (List.drop (explode (Iri.toWideString iri), n))
in
- if Iri.isEmpty prefix
- then NONE
- else
- case IriMap.find (reverse, prefix) of
- NONE => raise Fail ("internal error: prefix <" ^
- Iri.toString prefix ^
- "> found in trie " ^
- "but not in reverse map")
- | SOME abbr =>
- SOME (abbr, toUtf8 (dropPrefix (iri, Iri.size prefix)))
+ case prefixOpt of
+ NONE => NONE
+ | SOME prefix =>
+ if Iri.isEmpty prefix
+ then NONE
+ else
+ case IriMap.find (reverse, prefix) of
+ NONE => raise Fail ("internal error: prefix <" ^
+ Iri.toString prefix ^
+ "> found in trie " ^
+ "but not in reverse map")
+ | SOME abbr =>
+ SOME (abbr, toUtf8 (dropPrefix (iri, Iri.size prefix)))
end
end
M src/store/index.sml +1 -1
@@ 60,7 60,7 @@ structure Index :> INDEX = struct
(ord, NodeTrie.remove (ix, decompose (ord, triple)))
fun foldlMatch f acc ((ord, ix) : t, pattern) =
- NodeTrie.foldlPatternMatch
+ NodeTrie.foldlPattern
(fn (e, acc) => f (recompose (ord, e), acc))
acc
(ix, decompose (ord, pattern))