From 475a7d79da733bfe9879da05d71ab17e8f0014b7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 21 Dec 2017 10:17:56 -0500 Subject: [PATCH] :memo: the MonadAddress instances. --- src/Control/Monad/Effect/Address.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Control/Monad/Effect/Address.hs b/src/Control/Monad/Effect/Address.hs index c498c0260..94effa056 100644 --- a/src/Control/Monad/Effect/Address.hs +++ b/src/Control/Monad/Effect/Address.hs @@ -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