diff --git a/escher.hs b/escher.hs index ddc535c..275934e 100644 --- a/escher.hs +++ b/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