dawg-ord-0.4.0.1: Directed acyclic word graphs

Safe HaskellNone
LanguageHaskell98

Data.DAWG.Ord

Contents

Description

A version of Int adapted to keys and values with Ord instances.

Synopsis

DAWG type

data DAWG a b Source

A directed acyclic word graph (DAWG) with type a representing the type of alphabet symbols (over which keys are constructued) and type b -- the type of values.

A DAWG is, semantically, a map from keys (sequences of as) to values b.

Instances

(Eq a, Eq b) => Eq (DAWG a b) Source 
(Ord a, Ord b) => Ord (DAWG a b) Source 
(Show a, Show b) => Show (DAWG a b) Source 

type ID = Int Source

Node identifier.

root :: DAWG a b -> ID Source

Root of the DAWG.

Query

lookup :: (Ord a, Ord b) => [a] -> DAWG a b -> Maybe b Source

Find value associated with the key.

numStates :: DAWG a b -> Int Source

Number of states in the automaton.

numEdges :: DAWG a b -> Int Source

Number of edges in the automaton.

Traversal

value :: ID -> DAWG a b -> Maybe b Source

Value stored in the given node.

edges :: ID -> DAWG a b -> [(a, ID)] Source

A list of outgoing edges.

follow :: Ord a => ID -> a -> DAWG a b -> Maybe ID Source

Follow the given transition from the given state.

Construction

empty :: DAWG a b Source

Empty DAWG.

fromList :: (Ord a, Ord b) => [([a], b)] -> DAWG a b Source

Construct DAWG from the list of (word, value) pairs.

fromLang :: Ord a => [[a]] -> DAWG a () Source

Make DAWG from the list of words. Annotate each word with the () value.

Insertion

insert :: (Ord a, Ord b) => [a] -> b -> DAWG a b -> DAWG a b Source

Insert the (key, value) pair into the DAWG.

Conversion

assocs :: DAWG a b -> [([a], b)] Source

Return all key/value pairs in the DAWG in ascending key order.

keys :: DAWG a b -> [[a]] Source

Return all keys of the DAWG in ascending order.

elems :: DAWG a b -> [b] Source

Return all elements of the DAWG in the ascending order of their keys.