Copyright | (c) 2015 Athan Clark |
---|---|
License | BSD-style |
Maintainer | athan.clark@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
- class Singleton chunks a trie | chunks a -> trie where
- singleton :: chunks -> a -> trie
- class Extend eitherUrlChunk child result | eitherUrlChunk child -> result where
- extend :: eitherUrlChunk -> child -> result
- class Extrude chunks start result | chunks start -> result where
- extrude :: chunks -> start -> result
- type ExtrudeSoundly k cleanxs xs c r = (cleanxs ~ CatMaybes xs, ArityTypeListIso c cleanxs r, Extrude (PathChunks k xs) (RootedPredTrie k c) (RootedPredTrie k r))
- type family CatMaybes xs :: [*]
- only :: k -> PathChunk k Nothing
- pred :: k -> (k -> Maybe r) -> PathChunk k (Just r)
- (./) :: PathChunk k mx -> PathChunks k xs -> PathChunks k (mx : xs)
- nil :: PathChunks k `[]`
- data PathChunk k mx
- data PathChunks k xs
Heterogenous Construction
class Singleton chunks a trie | chunks a -> trie where Source
Creates a string of nodes - a trie with a width of 1.
(Singleton (PathChunks k xs) new trie0, Extend (PathChunk k x) trie0 trie1) => Singleton (PathChunks k ((:) (Maybe *) x xs)) new trie1 Source | |
Singleton (PathChunks k ([] (Maybe *))) a (RootedPredTrie k a) Source |
class Extend eitherUrlChunk child result | eitherUrlChunk child -> result where Source
Turn a list of tries (Rooted
) into a node with those children
(Eq k, Hashable k, Typeable * r) => Extend (PathChunk k (Just * r)) (RootedPredTrie k (r -> a)) (RootedPredTrie k a) Source | Existentially quantified case |
(Eq k, Hashable k) => Extend (PathChunk k (Nothing *)) (RootedPredTrie k a) (RootedPredTrie k a) Source | Literal case |
class Extrude chunks start result | chunks start -> result where Source
FoldR Extend start chunks ~ result
(Extrude (PathChunks k xs) trie0 trie1, Extend (PathChunk k x) trie1 trie2) => Extrude (PathChunks k ((:) (Maybe *) x xs)) trie0 trie2 Source | |
Extrude (PathChunks k ([] (Maybe *))) (RootedPredTrie k a) (RootedPredTrie k a) Source |
type ExtrudeSoundly k cleanxs xs c r = (cleanxs ~ CatMaybes xs, ArityTypeListIso c cleanxs r, Extrude (PathChunks k xs) (RootedPredTrie k c) (RootedPredTrie k r)) Source
A simple proof showing that the list version and function version are interchangable.
type family CatMaybes xs :: [*] Source
Convenience type-level function for removing Nothing
s from a type list.
Path Construction
pred :: k -> (k -> Maybe r) -> PathChunk k (Just r) Source
Match with a predicate against the url chunk directly.
(./) :: PathChunk k mx -> PathChunks k xs -> PathChunks k (mx : xs) infixr 9 Source
The cons-cell for building a query path.
nil :: PathChunks k `[]` Source
The basis, equivalent to []
Path Types
Constrained to AttoParsec, Regex-Compat and T.Text
IsString k => IsString (PathChunk k (Nothing *)) Source | Use raw strings instead of prepending |
(Eq k, Hashable k, Typeable * r) => Extend (PathChunk k (Just * r)) (RootedPredTrie k (r -> a)) (RootedPredTrie k a) Source | Existentially quantified case |
(Eq k, Hashable k) => Extend (PathChunk k (Nothing *)) (RootedPredTrie k a) (RootedPredTrie k a) Source | Literal case |
data PathChunks k xs Source
Container when defining route paths
(Extrude (PathChunks k xs) trie0 trie1, Extend (PathChunk k x) trie1 trie2) => Extrude (PathChunks k ((:) (Maybe *) x xs)) trie0 trie2 Source | |
(Singleton (PathChunks k xs) new trie0, Extend (PathChunk k x) trie0 trie1) => Singleton (PathChunks k ((:) (Maybe *) x xs)) new trie1 Source | |
Singleton (PathChunks k ([] (Maybe *))) a (RootedPredTrie k a) Source | |
Extrude (PathChunks k ([] (Maybe *))) (RootedPredTrie k a) (RootedPredTrie k a) Source |