1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Use foldMapA instead of asum/map.

This commit is contained in:
Rob Rix 2017-12-21 15:13:35 -05:00
parent a50a63e6c0
commit 10b7ce1ff3

View File

@ -94,9 +94,9 @@ evCache ev0 ev' yield e = do
let c = Configuration e roots env store :: Configuration (LocationFor v) t v let c = Configuration e roots env store :: Configuration (LocationFor v) t v
out <- getCache out <- getCache
case cacheLookup c out of case cacheLookup c out of
Just pairs -> asum . flip map (toList pairs) $ \ (value, store') -> do Just pairs -> foldMapA (\ (value, store') -> do
putStore store' putStore store'
pure value pure value) (toList pairs)
Nothing -> do Nothing -> do
in' <- askCache in' <- askCache
let pairs = fromMaybe mempty (cacheLookup c in') let pairs = fromMaybe mempty (cacheLookup c in')
@ -129,9 +129,9 @@ fixCache ev' yield e = do
reset 0 reset 0
_ <- localCache (const dollar) (collect point (ev' yield e) :: m (Set.Set v)) _ <- localCache (const dollar) (collect point (ev' yield e) :: m (Set.Set v))
getCache) mempty getCache) mempty
asum . flip map (maybe [] toList (cacheLookup c cache)) $ \ (value, store') -> do maybe empty (foldMapA (\ (value, store') -> do
putStore store' putStore store'
pure value pure value) . toList) (cacheLookup c cache)
-- | Compute the Kleene fixed-point theorem in a monadic context. -- | Compute the Kleene fixed-point theorem in a monadic context.