empty list type check fix, add typecheck to forward step (no tests yet)

This commit is contained in:
ProgramSnail 2025-11-05 02:36:33 +03:00
parent edc6c373b0
commit 753ca23cbc
2 changed files with 23 additions and 12 deletions

View file

@ -10,7 +10,7 @@ import Data.Set (Set)
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.List (inits)
import Data.Maybe (fromMaybe, isJust, maybeToList)
import Data.Maybe (fromMaybe, isJust, maybeToList, isNothing)
import Debug.Trace (trace)
import TypeCheck
@ -54,12 +54,14 @@ matchAnyOutputs outputs = do exprs <- gets syntExprs
-- generate next step of exprs, remove copies
forwardStep :: Expr -> [Expr] -> SyntState (Maybe Expr)
forwardStep comp args = do let expr = fillHoles comp args
outputs <- calcExprOutputs expr
matchedExisting <- gets $ evalState (matchAnyOutputs outputs)
-- TODO: all RecErrors example could be useful on future cases ?
if any isFatalError outputs || all isRecError outputs || matchedExisting then return Nothing else do
modify $ \st -> st { syntExprs = (expr, []) : syntExprs st}
return $ Just expr
typeConf <- gets $ oracleTypes . syntOracle
if isNothing $ checkType typeConf expr then return Nothing else do
outputs <- calcExprOutputs expr
matchedExisting <- gets $ evalState (matchAnyOutputs outputs)
-- TODO: all RecErrors example could be useful on future cases ?
if any isFatalError outputs || all isRecError outputs || matchedExisting then return Nothing else do
modify $ \st -> st { syntExprs = (expr, []) : syntExprs st}
return $ Just expr
splitGoal :: Goal -> [Bool] -> Resolver
splitGoal resolverGoal@(Goal outputs) selector | length outputs == length selector =