type check preparation: add types to oracle

This commit is contained in:
ProgramSnail 2025-11-05 01:58:03 +03:00
parent b7963e87a6
commit edc6c373b0
8 changed files with 179 additions and 803 deletions

View file

@ -7,7 +7,10 @@ import Control.Monad (foldM)
import Debug.Trace (trace)
type Oracle = [Value] -> Maybe Value
type OracleFunc = [Value] -> Maybe Value
data Oracle = Oracle { oracleTypes :: TypeConf,
oracleFunc :: OracleFunc }
data Conf = Conf {confInput :: [Value],
confOracle :: Oracle,
@ -96,7 +99,7 @@ eval conf (SelfE es) = do recInput <- foldM (\es e -> consValsM es (eval conf e)
if not $ and $ zipWith structuralLess recInput (confInput conf)
then RecError $ "self call on >= exprs, new=" ++ show recInput ++ " old=" ++ show (confInput conf)
else do
case confOracle conf recInput of
case (oracleFunc $ confOracle conf) recInput of
Just recOutput -> if recInput `elem` confExamples conf
then return recOutput
else NewExamples $ trace ("newExample: " ++ show [(recInput, recOutput)]) [(recInput, recOutput)]