-- Transform NFADefs over String labels into arbitrary other labels, using the
-- provided function.
modifyNFADef :: (String -> Either String a) -> NFADef String
             -> Either String (NFADef a)
modifyNFADef f (NFADef is ts fs) =
    (\ts' -> NFADef is ts' fs) <$> DT.mapM transform ts
  where
    transform (NFATransDef src lbls tgt) =
        (\lbls' -> NFATransDef src lbls' tgt) <$> DT.mapM f lbls
modifyNFADef :: (String -> Either String a) -> NFADef String
             -> Either String (NFADef a)
modifyNFADef f (NFADef is ts fs) =
    (\ts' -> NFADef is ts' fs) <$> DT.mapM transform ts
  where
    transform (NFATransDef src lbls tgt) =
        (\lbls' -> NFATransDef src lbls' tgt) <$> DT.mapM f lbls
modifyNFADef f (NFADef is ts fs) =
    (\ts' -> NFADef is ts' fs) <$> DT.mapM transform ts
  where
    transform (NFATransDef src lbls tgt) =
        (\lbls' -> NFATransDef src lbls' tgt) <$> DT.mapM f lbls