mirror of
https://codeberg.org/ProgramSnail/prog_synthesis.git
synced 2025-12-15 09:48:42 +00:00
monor fixes, sepated caching eval
This commit is contained in:
parent
f27f6c5559
commit
15cbf78ed5
2 changed files with 54 additions and 32 deletions
|
|
@ -115,11 +115,13 @@ eval conf (InputE i) = do if i < 0 || i >= length (confInput conf) -- NOTE: repl
|
|||
eval _ Hole = FatalError "can't eval hole"
|
||||
|
||||
|
||||
type Cache = Map Expr (Result Value)
|
||||
|
||||
eval' :: Cache -> Conf -> Expr -> (Result Value, Cache)
|
||||
eval' cache conf expr = case expr `Map.lookup` cache of
|
||||
Just result -> (result, cache)
|
||||
Nothing -> let result = eval conf expr in
|
||||
(result, Map.insert expr result cache)
|
||||
type Cache = Map ([Value], Expr) (Result Value)
|
||||
|
||||
cachedEval :: Cache -> Conf -> Expr -> (Result Value, Cache)
|
||||
cachedEval cache conf expr = let input = confInput conf in
|
||||
case (input, expr) `Map.lookup` cache of
|
||||
Just result -> (result, cache)
|
||||
Nothing -> let result = eval conf expr in
|
||||
(result, if isResult result
|
||||
then Map.insert (input, expr) result cache
|
||||
else cache)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue