mirror of
https://codeberg.org/ProgramSnail/prog_synthesis.git
synced 2025-12-05 21:18: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
|
||||
eval conf (IfE {ifCond, ifDoThen, ifDoElse}) = do BoolV condB <- eval conf ifCond
|
||||
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
|
||||
-- guard $ length newInput == length (confInput conf)
|
||||
-- guard $ and $ zipWith structuralLess newInput (confInput conf)
|
||||
if length newInput /= length (confInput conf)
|
||||
then RecError $ "self call different length, new=" ++ show newInput ++ " old=" ++ show (confInput conf)
|
||||
if length recInput /= length (confInput conf)
|
||||
then RecError $ "self call different length, new=" ++ show recInput ++ " old=" ++ show (confInput conf)
|
||||
else do
|
||||
if not $ and $ zipWith structuralLess newInput (confInput conf)
|
||||
then RecError $ "self call on >= exprs, new=" ++ show newInput ++ " old=" ++ show (confInput conf)
|
||||
if not $ and $ zipWith structuralLess recInput (confInput conf)
|
||||
then RecError $ "self call on >= exprs, new=" ++ show recInput ++ " old=" ++ show (confInput conf)
|
||||
else do
|
||||
if newInput `notElem` confExamples conf then
|
||||
(case confOracle conf newInput of
|
||||
Just expectedV -> NewExamples [(newInput, expectedV)]
|
||||
Nothing -> RecError $ "no oracle output on " ++ show newInput) -- TODO: ???
|
||||
else eval conf{ confInput = newInput } (confProg conf)
|
||||
case confOracle conf recInput of
|
||||
Just recOutput -> if recInput `elem` confExamples conf
|
||||
then return recOutput
|
||||
else NewExamples [(recInput, recOutput)]
|
||||
Nothing -> RecError $ "no oracle output on " ++ show recInput
|
||||
eval conf (InputE e) = do IntV i <- eval conf e
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue