Skip to content

Commit 3cdc24c

Browse files
committed
get rid of restrictKeys
1 parent e4ae0b8 commit 3cdc24c

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/DFAMin.hs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
22

3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE PatternGuards #-}
54
{-# LANGUAGE ScopedTypeVariables #-}
65
{-# LANGUAGE TupleSections #-}
@@ -16,13 +15,6 @@ import qualified Data.IntSet as IS
1615
import Data.IntMap (IntMap)
1716
import qualified Data.IntMap as IM
1817
import qualified Data.List as List
19-
import Data.Foldable (foldl')
20-
21-
#if __GLASGOW_HASKELL__ >= 802
22-
restrictKeys = IM.restrictKeys
23-
#else
24-
restrictKeys m s = IM.intersection m (IM.fromSet (const ()) s)
25-
#endif
2618

2719
-- Hopcroft's Algorithm for DFA minimization (cut/pasted from Wikipedia):
2820

@@ -162,7 +154,7 @@ groupEquivStates DFA { dfa_states = statemap }
162154
where
163155
xs :: [EquivalenceClass]
164156
xs = filter (not . IS.null)
165-
. map (foldl' IS.union IS.empty . flip restrictKeys a)
157+
. map (\m -> IS.unions [IM.findWithDefault IS.empty s m | s <- IS.toList a])
166158
$ bigmap
167159

168160
go0 (r,q) x = go1 r [] []

0 commit comments

Comments
 (0)