seonbi-0.4.0: SmartyPants for Korean language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Seonbi.Trie

Description

A trie from Text keys to values.

Synopsis

Documentation

data Trie a Source #

A trie from Text keys to a values.

Instances

Instances details
Foldable Trie Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

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 #

toList :: Trie a -> [a] #

null :: Trie a -> Bool #

length :: Trie a -> Int #

elem :: Eq a => a -> Trie a -> Bool #

maximum :: Ord a => Trie a -> a #

minimum :: Ord a => Trie a -> a #

sum :: Num a => Trie a -> a #

product :: Num a => Trie a -> a #

Traversable Trie Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

traverse :: Applicative f => (a -> f b) -> Trie a -> f (Trie b) #

sequenceA :: Applicative f => Trie (f a) -> f (Trie a) #

mapM :: Monad m => (a -> m b) -> Trie a -> m (Trie b) #

sequence :: Monad m => Trie (m a) -> m (Trie a) #

Applicative Trie Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

pure :: a -> Trie a #

(<*>) :: Trie (a -> b) -> Trie a -> Trie b #

liftA2 :: (a -> b -> c) -> Trie a -> Trie b -> Trie c #

(*>) :: Trie a -> Trie b -> Trie b #

(<*) :: Trie a -> Trie b -> Trie a #

Functor Trie Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

fmap :: (a -> b) -> Trie a -> Trie b #

(<$) :: a -> Trie b -> Trie a #

Monad Trie Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

(>>=) :: Trie a -> (a -> Trie b) -> Trie b #

(>>) :: Trie a -> Trie b -> Trie b #

return :: a -> Trie a #

Monoid a => Monoid (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

mempty :: Trie a #

mappend :: Trie a -> Trie a -> Trie a #

mconcat :: [Trie a] -> Trie a #

Semigroup a => Semigroup (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

(<>) :: Trie a -> Trie a -> Trie a #

sconcat :: NonEmpty (Trie a) -> Trie a #

stimes :: Integral b => b -> Trie a -> Trie a #

IsList (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

Associated Types

type Item (Trie a) #

Methods

fromList :: [Item (Trie a)] -> Trie a #

fromListN :: Int -> [Item (Trie a)] -> Trie a #

toList :: Trie a -> [Item (Trie a)] #

Show a => Show (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

showsPrec :: Int -> Trie a -> ShowS #

show :: Trie a -> String #

showList :: [Trie a] -> ShowS #

Eq a => Eq (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

Methods

(==) :: Trie a -> Trie a -> Bool #

(/=) :: Trie a -> Trie a -> Bool #

type Item (Trie a) Source # 
Instance details

Defined in Text.Seonbi.Trie

type Item (Trie a) = (Text, a)

elems :: Trie a -> [a] Source #

Lists all values in the trie. Values are ordered by their associated keys.

empty :: Trie a Source #

The empty trie.

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.

insert Source #

Arguments

:: 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.

keys :: Trie a -> [Text] Source #

Lists all keys in the trie. Keys will be ordered.

lookup :: Text -> Trie a -> Maybe a Source #

Gets the value associated with a key if it exists.

member :: Text -> Trie a -> Bool Source #

Checks if a key has a value in 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).

null :: Trie a -> Bool Source #

Checks if the trie is empty.

singleton :: Text -> a -> Trie a Source #

Constructs a singleton trie.

size :: Trie a -> Int Source #

Gets the number of elements in the trie.

toList :: Trie a -> [(Text, a)] Source #

Converts a trie into a list of associated pairs. Keys will be ordered.

unionL :: Trie a -> Trie a -> Trie a Source #

Combines two tries, resolving conflicts by choosing the value from the left (former) trie.

unionR :: Trie a -> Trie a -> Trie a Source #

Combines two tries, resolving conflicts by choosing the value from the right (latter) trie.