1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

📝 the MonadAddress instances.

This commit is contained in:
Rob Rix 2017-12-21 10:17:56 -05:00
parent 1fb1196483
commit 475a7d79da

View File

@ -46,6 +46,7 @@ envLookupOrAlloc name env v = do
pure (name, a)
-- | 'Precise' locations are always 'alloc'ated a fresh 'Address', and 'deref'erence to the 'Latest' value written.
instance Monad m => MonadAddress Precise m where
deref = maybe uninitializedAddress (pure . unLatest) <=< flip fmap getStore . storeLookup
@ -54,6 +55,7 @@ instance Monad m => MonadAddress Precise m where
allocPrecise = Address . Precise . storeSize
-- | 'Monovariant' locations 'alloc'ate one 'Address' per unique variable name, and 'deref'erence once per stored value, nondeterministically.
instance (Alternative m, Monad m) => MonadAddress Monovariant m where
deref = asum . maybe [] (map pure . toList) <=< flip fmap getStore . storeLookup