dawg-ord 0.3 → 0.3.1
raw patch · 5 files changed
+23/−14 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- dawg-ord.cabal +1/−1
- src/Data/DAWG/Int.hs +10/−0
- src/Data/DAWG/Int/Dynamic.hs +5/−7
- src/Data/DAWG/Int/Dynamic/Internal.hs +1/−0
- src/Data/DAWG/Ord/Dynamic.hs +6/−6
dawg-ord.cabal view
@@ -1,5 +1,5 @@ name: dawg-ord-version: 0.3+version: 0.3.1 synopsis: Directed acyclic word graphs description: The library implements /directed acyclic word graphs/ (DAWGs)
src/Data/DAWG/Int.hs view
@@ -1,3 +1,13 @@+-- | The module implements /directed acyclic word graphs/ (DAWGs)+-- internaly represented as /minimal acyclic deterministic+-- finite-state automata/.+-- The implementation provides a fast insert operation which can be+-- used to build the DAWG structure incrementaly.+--+-- Alphabet symbols must have an `Enum` instance; see `Data.DAWG.Ord`+-- if you look for a more generic solution.++ module Data.DAWG.Int ( -- * DAWG type
src/Data/DAWG/Int/Dynamic.hs view
@@ -27,8 +27,6 @@ , fromList -- ** Insertion , insert--- ** Deletion--- , delete -- * Conversion , keys@@ -189,7 +187,7 @@ numEdges = sum . map (length . N.edges) . G.nodes . graph --- | Insert the (key, value) pair into the DAWG.+-- | Insert the word into the DAWG. insert :: Enum a => [a] -> DAWG a -> DAWG a insert xs' d = let xs = map fromEnum xs'@@ -207,7 +205,7 @@ -- {-# SPECIALIZE delete :: String -> DAWG Char -> DAWG Char #-} --- | Find value associated with the key.+-- | Is the word a member of the DAWG? member :: Enum a => [a] -> DAWG a -> Bool member xs' d = let xs = map fromEnum xs'@@ -228,7 +226,7 @@ -- -> [(String, b)] #-} --- | Return all key/value pairs in the DAWG in ascending key order.+-- | Return all keys in the DAWG in ascending key order. keys :: Enum a => DAWG a -> [[a]] keys = map (map toEnum)@@ -236,7 +234,7 @@ {-# SPECIALIZE keys :: DAWG Char -> [String] #-} --- | Construct DAWG from the list of (word, value) pairs.+-- | Construct DAWG from the list of words. fromList :: Enum a => [[a]] -> DAWG a fromList xs = let update t x = insert x t@@ -259,7 +257,7 @@ {-# SPECIALIZE edges :: ID -> DAWG Int -> [(Int, ID)] #-} --- | Value stored in the given state.+-- | Does the identifer represent an accepting state? accept :: ID -> DAWG a -> Bool accept i = N.accept . G.nodeBy i . graph
src/Data/DAWG/Int/Dynamic/Internal.hs view
@@ -20,6 +20,7 @@ -- representing the type of alphabet elements. data DAWG a = DAWG { graph :: !(Graph N.Node)+ -- | Foot of the DAWG. , root :: !ID } deriving (Show, Eq, Ord)
src/Data/DAWG/Ord/Dynamic.hs view
@@ -48,7 +48,7 @@ ------------------------------------------------------------ --- | A directed acyclic word graph with type @a@ representing the+-- | A directed acyclic word graph with type `a` representing the -- type of alphabet elements. data DAWG a = DAWG { intDAWG :: D.DAWG Sym@@ -114,7 +114,7 @@ numEdges = D.numEdges . intDAWG --- | Insert the (key, value) pair into the DAWG.+-- | Insert the word into the DAWG. insert :: (Ord a) => [a] -> DAWG a -> DAWG a insert xs0 dag0 = snd $ flip runDM dag0 $ do xs <- addKey xs0@@ -143,14 +143,14 @@ -- {-# SPECIALIZE delete :: Ord b => String -> DAWG Char b -> DAWG Char b #-} --- | Find value associated with the key.+-- | Is the word a member of the DAWG? member :: (Ord a) => [a] -> DAWG a -> Bool member xs0 DAWG{..} = justTrue $ do xs <- mapM (`M.lookup` symMap) xs0 return $ D.member xs intDAWG --- | Return all key/value pairs in the DAWG in ascending key order.+-- | Return all keys in the DAWG in ascending key order. keys :: DAWG a -> [[a]] keys DAWG{..} = [ decodeKey xs@@ -160,7 +160,7 @@ decodeSym x = symMapR M.! x --- | Construct DAWG from the list of (word, value) pairs.+-- | Construct DAWG from the list of words. fromList :: (Ord a) => [[a]] -> DAWG a fromList xs = let update t x = insert x t@@ -172,7 +172,7 @@ ------------------------------------------------------------ --- | Value stored in the given node.+-- | Does the identifer represent an accepting state? accept :: ID -> DAWG a -> Bool accept i DAWG{..} = D.accept i intDAWG