Skip to content

Commit 9e6ba0f

Browse files
committed
use CPP to compile on older version of GHCs
1 parent c48f3f7 commit 9e6ba0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/DFAMin.hs

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

3+
{-# LANGUAGE CPP #-}
34
{-# LANGUAGE PatternGuards #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
56
{-# LANGUAGE TupleSections #-}
@@ -17,6 +18,12 @@ import qualified Data.IntMap as IM
1718
import qualified Data.List as List
1819
import Data.Foldable (foldl')
1920

21+
#if __GLASGOW_HASKELL__ >= 802
22+
restrictKeys = IM.restrictKeys
23+
#else
24+
restrictKeys m s = IM.filterWithKey (\k _ -> IS.member k s) m
25+
#endif
26+
2027
-- Hopcroft's Algorithm for DFA minimization (cut/pasted from Wikipedia):
2128

2229
-- P := {{all accepting states}, {all nonaccepting states}};
@@ -155,7 +162,7 @@ groupEquivStates DFA { dfa_states = statemap }
155162
where
156163
xs :: [EquivalenceClass]
157164
xs = filter (not . IS.null)
158-
. map (foldl' IS.union IS.empty . flip IM.restrictKeys a)
165+
. map (foldl' IS.union IS.empty . flip restrictKeys a)
159166
$ bigmap
160167

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

0 commit comments

Comments
 (0)