mirror of
https://codeberg.org/ProgramSnail/prog_synthesis.git
synced 2025-12-06 05:28:42 +00:00
self eval fix: return oracle result without recursion
This commit is contained in:
parent
482b41680e
commit
0270c44bf6
1 changed files with 10 additions and 10 deletions
20
escher.hs
20
escher.hs
|
|
@ -203,21 +203,21 @@ eval conf (CreateLeafE e) = do v <- eval conf e
|
||||||
return $ TreeV $ TLeaf v
|
return $ TreeV $ TLeaf v
|
||||||
eval conf (IfE {ifCond, ifDoThen, ifDoElse}) = do BoolV condB <- eval conf ifCond
|
eval conf (IfE {ifCond, ifDoThen, ifDoElse}) = do BoolV condB <- eval conf ifCond
|
||||||
if condB then eval conf ifDoThen else eval conf ifDoElse
|
if condB then eval conf ifDoThen else eval conf ifDoElse
|
||||||
eval conf (SelfE e) = do ListV newInput <- eval conf e
|
eval conf (SelfE e) = do ListV recInput <- eval conf e
|
||||||
-- NOTE: replaced guards for better errors description
|
-- NOTE: replaced guards for better errors description
|
||||||
-- guard $ length newInput == length (confInput conf)
|
-- guard $ length newInput == length (confInput conf)
|
||||||
-- guard $ and $ zipWith structuralLess newInput (confInput conf)
|
-- guard $ and $ zipWith structuralLess newInput (confInput conf)
|
||||||
if length newInput /= length (confInput conf)
|
if length recInput /= length (confInput conf)
|
||||||
then RecError $ "self call different length, new=" ++ show newInput ++ " old=" ++ show (confInput conf)
|
then RecError $ "self call different length, new=" ++ show recInput ++ " old=" ++ show (confInput conf)
|
||||||
else do
|
else do
|
||||||
if not $ and $ zipWith structuralLess newInput (confInput conf)
|
if not $ and $ zipWith structuralLess recInput (confInput conf)
|
||||||
then RecError $ "self call on >= exprs, new=" ++ show newInput ++ " old=" ++ show (confInput conf)
|
then RecError $ "self call on >= exprs, new=" ++ show recInput ++ " old=" ++ show (confInput conf)
|
||||||
else do
|
else do
|
||||||
if newInput `notElem` confExamples conf then
|
case confOracle conf recInput of
|
||||||
(case confOracle conf newInput of
|
Just recOutput -> if recInput `elem` confExamples conf
|
||||||
Just expectedV -> NewExamples [(newInput, expectedV)]
|
then return recOutput
|
||||||
Nothing -> RecError $ "no oracle output on " ++ show newInput) -- TODO: ???
|
else NewExamples [(recInput, recOutput)]
|
||||||
else eval conf{ confInput = newInput } (confProg conf)
|
Nothing -> RecError $ "no oracle output on " ++ show recInput
|
||||||
eval conf (InputE e) = do IntV i <- eval conf e
|
eval conf (InputE e) = do IntV i <- eval conf e
|
||||||
if i < 0 || i >= length (confInput conf) -- NOTE: replaced guard for better errors description
|
if i < 0 || i >= length (confInput conf) -- NOTE: replaced guard for better errors description
|
||||||
then FatalError $ "can't access input " ++ show (confInput conf) ++ " by id " ++ show i
|
then FatalError $ "can't access input " ++ show (confInput conf) ++ " by id " ++ show i
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue