Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A trie from Text
keys to values.
Synopsis
- data Trie a
- elems :: Trie a -> [a]
- empty :: Trie a
- fromList :: [(Text, a)] -> Trie a
- insert :: Text -> a -> Trie a -> Trie a
- keys :: Trie a -> [Text]
- lookup :: Text -> Trie a -> Maybe a
- member :: Text -> Trie a -> Bool
- mergeBy :: (a -> a -> Maybe a) -> Trie a -> Trie a -> Trie a
- null :: Trie a -> Bool
- singleton :: Text -> a -> Trie a
- size :: Trie a -> Int
- toList :: Trie a -> [(Text, a)]
- unionL :: Trie a -> Trie a -> Trie a
- unionR :: Trie a -> Trie a -> Trie a
Documentation
A trie from Text
keys to a
values.
Instances
Foldable Trie Source # | |
Defined in Text.Seonbi.Trie fold :: Monoid m => Trie m -> m # foldMap :: Monoid m => (a -> m) -> Trie a -> m # foldMap' :: Monoid m => (a -> m) -> Trie a -> m # foldr :: (a -> b -> b) -> b -> Trie a -> b # foldr' :: (a -> b -> b) -> b -> Trie a -> b # foldl :: (b -> a -> b) -> b -> Trie a -> b # foldl' :: (b -> a -> b) -> b -> Trie a -> b # foldr1 :: (a -> a -> a) -> Trie a -> a # foldl1 :: (a -> a -> a) -> Trie a -> a # elem :: Eq a => a -> Trie a -> Bool # maximum :: Ord a => Trie a -> a # | |
Traversable Trie Source # | |
Applicative Trie Source # | |
Functor Trie Source # | |
Monad Trie Source # | |
Monoid a => Monoid (Trie a) Source # | |
Semigroup a => Semigroup (Trie a) Source # | |
IsList (Trie a) Source # | |
Show a => Show (Trie a) Source # | |
Eq a => Eq (Trie a) Source # | |
type Item (Trie a) Source # | |
Defined in Text.Seonbi.Trie |
elems :: Trie a -> [a] Source #
Lists all values in the trie. Values are ordered by their associated keys.
fromList :: [(Text, a)] -> Trie a Source #
Converts a list of associated pairs into a trie. For duplicate keys, values earlier in the list shadow later ones.
:: Text | A new key to insert. If there is already the same key in the trie, the existing value is overwritten by the new value. |
-> a | A value associated to the key. |
-> Trie a | An existing trie. |
-> Trie a | The new trie with the inserted key. |
Inserts a new key into the trie.
mergeBy :: (a -> a -> Maybe a) -> Trie a -> Trie a -> Trie a Source #
Combines two tries, using a function to resolve collisions. This can only define the space of functions between union and symmetric difference but, with those two, all set operations can be defined (albeit inefficiently).
toList :: Trie a -> [(Text, a)] Source #
Converts a trie into a list of associated pairs. Keys will be ordered.