1
Fork 0
mirror of https://git.cs.ou.nl/joshua.moerman/mealy-decompose.git synced 2025-04-30 02:07:44 +02:00
mealy-decompose/src/StateIdentifiers.hs
2024-06-14 14:43:32 +02:00

14 lines
492 B
Haskell

module StateIdentifiers where
import SplittingTree
import Trie qualified
import Data.Map.Strict qualified as Map
stateIdentifierFor :: (Ord i, Ord s) => s -> Partition s -> SplittingTree s i o -> Trie.Trie i
stateIdentifierFor state Partition{..} SplittingTree{..} = go firstNode
where
firstNode = fst <$> blockParent Map.!? (getPartition Map.! state)
getParent n = fst <$> innerParent Map.!? n
go Nothing = Trie.empty
go (Just n) = Trie.insert (label Map.! n) (go (getParent n))