textToNFAWith :: (NFADef String -> Either String r) -> [T.Text] -> r
textToNFAWith f = dieOr . toNFAWithF . toT
  where
    dieOr = either error id

    toNFAWithF = doParse >=> f
    doParse = conv . parse parseNetDef ""
    conv = either (Left . show) Right

    toT = T.unlines
textToNFAWith :: (NFADef String -> Either String r) -> [T.Text] -> r
textToNFAWith f = dieOr . toNFAWithF . toT
  where
    dieOr = either error id

    toNFAWithF = doParse >=> f
    doParse = conv . parse parseNetDef ""
    conv = either (Left . show) Right

    toT = T.unlines
textToNFAWith f = dieOr . toNFAWithF . toT
  where
    dieOr = either error id

    toNFAWithF = doParse >=> f
    doParse = conv . parse parseNetDef ""
    conv = either (Left . show) Right

    toT = T.unlines