1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Revert "Cache the environment at each program state."

This reverts commit 4c559aae6ad4f2adaeea58cc1ca37d64d97298d2.
This commit is contained in:
Rob Rix 2018-05-15 22:21:16 -04:00
parent 36075a3ff8
commit 1fd381b0ce
2 changed files with 6 additions and 18 deletions

View File

@ -32,19 +32,14 @@ lookupCache :: (Cacheable term location (Cell location) value, Member (State (Ca
lookupCache configuration = cacheLookup configuration <$> get
-- | Run an action, caching its result and 'Heap' under the given configuration.
cachingConfiguration :: ( Cacheable term location (Cell location) value
, Members '[ State (Cache term location (Cell location) value)
, State (Environment location value)
, State (Heap location (Cell location) value)
] effects
)
cachingConfiguration :: (Cacheable term location (Cell location) value, Members '[State (Cache term location (Cell location) value), State (Heap location (Cell location) value)] effects)
=> Configuration term location (Cell location) value
-> Set (Cached location (Cell location) value)
-> TermEvaluator term location value effects value
-> TermEvaluator term location value effects value
cachingConfiguration configuration values action = do
modify' (cacheSet configuration values)
result <- Cached <$> action <*> TermEvaluator getEnv <*> TermEvaluator getHeap
result <- Cached <$> action <*> TermEvaluator getHeap
cachedValue result <$ modify' (cacheInsert configuration result)
putCache :: Member (State (Cache term location (Cell location) value)) effects
@ -127,13 +122,8 @@ converge seed f = loop seed
loop x'
-- | Nondeterministically write each of a collection of stores & return their associated results.
scatter :: ( Foldable t
, Members '[ NonDet
, State (Environment location value)
, State (Heap location (Cell location) value)
] effects
) => t (Cached location (Cell location) value) -> TermEvaluator term location value effects value
scatter = foldMapA (\ Cached{..} -> TermEvaluator (putHeap cachedHeap) *> TermEvaluator (putEnv cachedEnvironment) $> cachedValue)
scatter :: (Foldable t, Members '[NonDet, State (Heap location (Cell location) value)] effects) => t (Cached location (Cell location) value) -> TermEvaluator term location value effects value
scatter = foldMapA (\ (Cached value heap') -> TermEvaluator (putHeap heap') $> value)
caching :: Alternative f => TermEvaluator term location value (NonDet ': Reader (Cache term location (Cell location) value) ': State (Cache term location (Cell location) value) ': effects) a -> TermEvaluator term location value effects (f a, Cache term location (Cell location) value)

View File

@ -2,7 +2,6 @@
module Data.Abstract.Cache where
import Data.Abstract.Configuration
import Data.Abstract.Environment
import Data.Abstract.Heap
import Data.Map.Monoidal as Monoidal
import Data.Semilattice.Lower
@ -13,9 +12,8 @@ newtype Cache term location cell value = Cache { unCache :: Monoidal.Map (Config
deriving (Eq, Lower, Monoid, Ord, Reducer (Configuration term location cell value, Cached location cell value), Semigroup)
data Cached location cell value = Cached
{ cachedValue :: value
, cachedEnvironment :: Environment location value
, cachedHeap :: Heap location cell value
{ cachedValue :: value
, cachedHeap :: Heap location cell value
}
deriving (Eq, Ord, Show)