Safe Haskell | Safe-Inferred |
---|---|
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
- matchPath :: (Hashable k, Hashable a) => k -> [a] -> MultiMapPathTrie a k v -> MatchResult a k v
- ambiguousPathsGrouped :: (Hashable a, Hashable k, Ord v, Ord a) => MultiMapPathTrie a k v -> [(Set [PathComponent a], Set v)]
- ambiguousPaths :: (Hashable a, 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
matchPath :: (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, 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
ambiguousPaths :: (Hashable a, 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
.