 = D.mkDFA fst dfaRules dfaGoal
  where
    fstClose = eclose [(enfa^.fstState)] (enfa^.rules)
    fst :: D.State (Set a)
    fst = D.State $ fromList $ L.map (\(D.State x) -> x) fstClose
    enfaRules = enfa^.rules
    fstDFARules = genDFARule' fst enfaRules
    fstTmpStates = L.filter (\x -> x /= fst) $ L.map (\(D.Rule _ _ x) -> x) fstDFARules
    dfaRules = (genDFARule'' enfaRules fstDFARules [fst] fstTmpStates)
    dfaGoal = L.nub $ L.filter (\(D.State t) -> any (\(D.State x) -> member x t) (enfa^.goalState)) $ [fst] ++ (L.map (\(D.Rule _ _ g) -> g) dfaRules)

genDFA :: forall a b. (Ord a) => EpsilonNFA a b -> D.DFA (Set a) b
genDFA enfa = D.mkDFA fst dfaRules dfaGoal
  where
    fstClose = eclose [(enfa^.fstState)] (enfa^.rules)
    fst :: D.State (Set a)
    fst = D.State $ fromList $ L.map (\(D.State x) -> x) fstClose
    enfaRules = enfa^.rules
    fstDFARules = genDFARule' fst enfaRules
    fstTmpStates = L.filter (\x -> x /= fst) $ L.map (\(D.Rule _ _ x) -> x) fstDFARules
    dfaRules = (genDFARule'' enfaRules fstDFARules [fst] fstTmpStates)
    dfaGoal = L.nub $ L.filter (\(D.State t) -> any (\(D.State x) -> member x t) (enfa^.goalState)) $ [fst] ++ (L.map (\(D.Rule _ _ g) -> g) dfaRules)
genDFA enfa = D.mkDFA fst dfaRules dfaGoal
  where
    fstClose = eclose [(enfa^.fstState)] (enfa^.rules)
    fst :: D.State (Set a)
    fst = D.State $ fromList $ L.map (\(D.State x) -> x) fstClose
    enfaRules = enfa^.rules
    fstDFARules = genDFARule' fst enfaRules
    fstTmpStates = L.filter (\x -> x /= fst) $ L.map (\(D.Rule _ _ x) -> x) fstDFARules
    dfaRules = (genDFARule'' enfaRules fstDFARules [fst] fstTmpStates)
    dfaGoal = L.nub $ L.filter (\(D.State t) -> any (\(D.State x) -> member x t) (enfa^.goalState)) $ [fst] ++ (L.map (\(D.Rule _ _ g) -> g) dfaRules)