Skip to content

Commit 98f2873

Browse files
committed
use restrictKeys and list comprehension
1 parent f1a790c commit 98f2873

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/DFAMin.hs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,21 @@ groupEquivStates DFA { dfa_states = statemap }
157157
go r (a:q) = uncurry go $ List.foldl' go0 (a:r,q) xs
158158
where
159159
xs :: [EquivalenceClass]
160-
xs = filter (not . IS.null)
161-
. map (\m -> IS.unions [IM.findWithDefault IS.empty s m | s <- IS.toList a])
162-
$ IM.elems bigmap
160+
#if MIN_VERSION_containers(0, 6, 0)
161+
xs =
162+
[ x
163+
| preimageMap <- IM.elems bigmap
164+
, let x = IS.unions (IM.restrictKeys preimageMap a)
165+
, not (IS.null x)
166+
]
167+
#else
168+
xs =
169+
[ x
170+
| preimageMap <- IM.elems bigmap
171+
, let x = IS.unions [IM.findWithDefault IS.empty s preimageMap | s <- IS.toList a]
172+
, not (IS.null x)
173+
]
174+
#endif
163175

164176
go0 (r,q) x = go1 r [] []
165177
where

0 commit comments

Comments
 (0)