pred-trie-0.5.1.2: Predicative tries

Copyright(c) 2015 Athan Clark
LicenseBSD-style
Maintainerathan.clark@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Data.Trie.Pred.Interface.Types

Contents

Description

 

Synopsis

Heterogenous Construction

class Singleton chunks a trie | chunks a -> trie where #

Creates a string of nodes - a trie with a width of 1.

Minimal complete definition

singleton

Methods

singleton :: chunks -> a -> trie #

Instances

(Singleton (PathChunks k xs) new trie0, Extend (PathChunk k x) trie0 trie1) => Singleton (PathChunks k ((:) (Maybe *) x xs)) new trie1 # 

Methods

singleton :: PathChunks k ((Maybe * ': x) xs) -> new -> trie1 #

Singleton (PathChunks k ([] (Maybe *))) a (RootedPredTrie k a) # 

Methods

singleton :: PathChunks k [Maybe *] -> a -> RootedPredTrie k a #

class Extend eitherUrlChunk child result | eitherUrlChunk child -> result where #

Turn a list of tries (Rooted) into a node with those children

Minimal complete definition

extend

Methods

extend :: eitherUrlChunk -> child -> result #

Instances

(Eq k, Hashable k, Typeable * r) => Extend (PathChunk k (Just * r)) (RootedPredTrie k (r -> a)) (RootedPredTrie k a) #

Existentially quantified case

Methods

extend :: PathChunk k (Just * r) -> RootedPredTrie k (r -> a) -> RootedPredTrie k a #

(Eq k, Hashable k) => Extend (PathChunk k (Nothing *)) (RootedPredTrie k a) (RootedPredTrie k a) #

Literal case

class Extrude chunks start result | chunks start -> result where #

FoldR Extend start chunks ~ result

Minimal complete definition

extrude

Methods

extrude :: chunks -> start -> result #

Instances

(Extrude (PathChunks k xs) trie0 trie1, Extend (PathChunk k x) trie1 trie2) => Extrude (PathChunks k ((:) (Maybe *) x xs)) trie0 trie2 # 

Methods

extrude :: PathChunks k ((Maybe * ': x) xs) -> trie0 -> trie2 #

Extrude (PathChunks k ([] (Maybe *))) (RootedPredTrie k a) (RootedPredTrie k a) # 

type ExtrudeSoundly k cleanxs xs c r = (cleanxs ~ CatMaybes xs, ArityTypeListIso c cleanxs r, Extrude (PathChunks k xs) (RootedPredTrie k c) (RootedPredTrie k r)) #

A simple proof showing that the list version and function version are interchangable.

type family CatMaybes (xs :: [Maybe *]) :: [*] where ... #

Convenience type-level function for removing Nothings from a type list.

Equations

CatMaybes '[] = '[] 
CatMaybes (Nothing ': xs) = CatMaybes xs 
CatMaybes (Just x ': xs) = x ': CatMaybes xs 

Path Construction

only :: k -> PathChunk k Nothing #

Match a literal key

pred :: k -> (k -> Maybe r) -> PathChunk k (Just r) #

Match with a predicate against the url chunk directly.

(./) :: PathChunk k mx -> PathChunks k xs -> PathChunks k (mx ': xs) infixr 9 #

The cons-cell for building a query path.

nil :: PathChunks k '[] #

The basis, equivalent to []

Path Types

data PathChunk k (mx :: Maybe *) #

Constrained to AttoParsec, Regex-Compat and T.Text

Instances

IsString k => IsString (PathChunk k (Nothing *)) #

Use raw strings instead of prepending l

(Eq k, Hashable k, Typeable * r) => Extend (PathChunk k (Just * r)) (RootedPredTrie k (r -> a)) (RootedPredTrie k a) #

Existentially quantified case

Methods

extend :: PathChunk k (Just * r) -> RootedPredTrie k (r -> a) -> RootedPredTrie k a #

(Eq k, Hashable k) => Extend (PathChunk k (Nothing *)) (RootedPredTrie k a) (RootedPredTrie k a) #

Literal case

data PathChunks k (xs :: [Maybe *]) #

Container when defining route paths

Instances

(Extrude (PathChunks k xs) trie0 trie1, Extend (PathChunk k x) trie1 trie2) => Extrude (PathChunks k ((:) (Maybe *) x xs)) trie0 trie2 # 

Methods

extrude :: PathChunks k ((Maybe * ': x) xs) -> trie0 -> trie2 #

(Singleton (PathChunks k xs) new trie0, Extend (PathChunk k x) trie0 trie1) => Singleton (PathChunks k ((:) (Maybe *) x xs)) new trie1 # 

Methods

singleton :: PathChunks k ((Maybe * ': x) xs) -> new -> trie1 #

Singleton (PathChunks k ([] (Maybe *))) a (RootedPredTrie k a) # 

Methods

singleton :: PathChunks k [Maybe *] -> a -> RootedPredTrie k a #

Extrude (PathChunks k ([] (Maybe *))) (RootedPredTrie k a) (RootedPredTrie k a) #