module Data.DAWG.Trans.Map
( Trans (unTrans)
) where
import Prelude hiding (lookup)
import Data.Binary (Binary)
import qualified Data.Map as M
import Data.DAWG.Types
import qualified Data.DAWG.Trans as C
newtype Trans = Trans { unTrans :: M.Map Sym ID }
deriving (Show, Eq, Ord, Binary)
instance C.Trans Trans where
empty = Trans M.empty
lookup x = M.lookup x . unTrans
index x = M.lookupIndex x . unTrans
byIndex i (Trans m) =
let n = M.size m
in if i >= 0 && i < n
then Just (M.elemAt i m)
else Nothing
insert x y (Trans m) = Trans (M.insert x y m)
fromList = Trans . M.fromList
toList = M.toList . unTrans