Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type MultiMapPathTrie a k v = Trie (PathComponent a) (MultiMap k v)
- data PathComponent a
- = PathLiteral a
- | PathParam
- data MatchResult a k v
- = MatchAmbiguous
- | MatchFound v [a]
- | MatchMissingKey (NonEmpty k)
- | MatchNotFound
- lookupPath :: (Eq a, Hashable a) => [a] -> Trie (PathComponent a) v -> [(v, [a])]
- matchPath :: (Eq a, Eq k, Hashable k, Hashable a) => k -> [a] -> MultiMapPathTrie a k v -> MatchResult a k v
- ambiguousPathsGrouped :: (Hashable a, Eq k, Hashable k, Ord v, Ord a) => MultiMapPathTrie a k v -> [(Set [PathComponent a], Set v)]
- groupAmbiguousPaths :: (Ord a, Ord v) => [(Set [PathComponent a], Set v)] -> [(Set [PathComponent a], Set v)]
- ambiguousPaths :: (Eq a, Hashable a, Eq k, Hashable k, Ord v) => MultiMapPathTrie a k v -> [([PathComponent a], Set v)]
Documentation
type MultiMapPathTrie a k v = Trie (PathComponent a) (MultiMap k v) Source #
Trie from PathComponent
s to MultiMap
s
data PathComponent a Source #
A component in a URL path: either a literal or a wildcard parameter
Instances
data MatchResult a k v Source #
Result of matching a path [
and key PathComponent
] ak
in a MultiMapPathTrie
.
MatchResult
is a lattice where MatchNotFound
is the bottom element and
MatchAmbiguous
is the top element:
MatchAmbiguous / MatchFound v0 as0 MatchFound v1 as1 / MatchMissingKey (ks0 <> ks1) / MatchMissingKey ks0 MatchMissingKey ks1 / MatchNotFound
MatchAmbiguous | Multiple results. |
MatchFound v [a] | A single unambiguous result. Returns the value found and a list of parameter bindings. |
MatchMissingKey (NonEmpty k) | A path was found, but not a key. Returns a list of keys found. |
MatchNotFound | Path was not found in the |
Instances
lookupPath :: (Eq a, Hashable a) => [a] -> Trie (PathComponent a) v -> [(v, [a])] Source #
Look up the value at a path.
PathParam
matches any path component.
Returns a list of pairs containing the value found and bindings for any PathParam
s.
matchPath :: (Eq a, Eq k, Hashable k, Hashable a) => k -> [a] -> MultiMapPathTrie a k v -> MatchResult a k v Source #
Match a key k
and path [a]
against a MultiMapPathTrie a k v
ambiguousPathsGrouped :: (Hashable a, Eq k, Hashable k, Ord v, Ord a) => MultiMapPathTrie a k v -> [(Set [PathComponent a], Set v)] Source #
A version of ambiguousPaths that attempts to group all ambiguous paths that have overlapping endpoints
groupAmbiguousPaths :: (Ord a, Ord v) => [(Set [PathComponent a], Set v)] -> [(Set [PathComponent a], Set v)] Source #
ambiguousPaths :: (Eq a, Hashable a, Eq k, Hashable k, Ord v) => MultiMapPathTrie a k v -> [([PathComponent a], Set v)] Source #
Detect and return all ambiguous paths in the MultiMapPathTrie
A path p
is ambiguous if matchPath k p
can return MatchAmbiguous
for some k
.