1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 18:36:27 +03:00

Rename collect to gather.

This commit is contained in:
Rob Rix 2017-12-21 15:35:37 -05:00
parent aae7db2ba4
commit a1d7c5ede4
2 changed files with 7 additions and 7 deletions

View File

@ -124,7 +124,7 @@ fixCache ev' yield e = do
putCache (mempty :: Cache (LocationFor v) t v)
putStore store
reset 0
_ <- localCache (const dollar) (collect point (ev' yield e) :: m (Set.Set v))
_ <- localCache (const dollar) (gather point (ev' yield e) :: m (Set.Set v))
getCache) mempty
maybe empty scatter (cacheLookup c cache)

View File

@ -10,14 +10,14 @@ import Control.Monad.Effect.NonDetEff
-- | 'Monad's offering local isolation of nondeterminism effects.
class (Alternative m, Monad m) => MonadNonDet m where
-- | Run a computation, collecting any local nondeterminism into a 'Monoid'al value.
collect :: Monoid b
=> (a -> b) -- ^ A function constructing a 'Monoid'al value from a single computed result. This might typically be @point@ (for @Pointed@ functors), 'pure' (for 'Applicative's), or some similar singleton constructor.
-> m a -- ^ The computation to run locally-nondeterministically.
-> m b -- ^ A _deterministic_ computation producing the 'Monoid'al accumulation of the _locally-nondeterministic_ result values.
-- | Run a computation, gathering any nondeterministically produced results into a single 'Monoid'al value.
gather :: Monoid b
=> (a -> b) -- ^ A function constructing a 'Monoid'al value from a single computed result. This might typically be @point@ (for @Pointed@ functors), 'pure' (for 'Applicative's), or some similar singleton constructor.
-> m a -- ^ The computation to run locally-nondeterministically.
-> m b -- ^ A _deterministic_ computation producing the 'Monoid'al accumulation of the _locally-nondeterministic_ result values.
-- | Effect stacks containing 'NonDetEff' offer a 'MonadNonDet' instance which implements 'collect' by interpreting the requests for nondeterminism locally, without removing 'NonDetEff' from the stack—i.e. the _capacity_ for nondeterminism is still present in the effect stack, but any local nondeterminism has been applied.
instance (NonDetEff :< fs) => MonadNonDet (Eff fs) where
collect f = interpose (pure . f) (\ m k -> case m of
gather f = interpose (pure . f) (\ m k -> case m of
MZero -> pure mempty
MPlus -> mappend <$> k True <*> k False)