mirror of
https://codeberg.org/ProgramSnail/prog_synthesis.git
synced 2025-12-06 05:28:42 +00:00
type check preparation: add types to oracle
This commit is contained in:
parent
b7963e87a6
commit
edc6c373b0
8 changed files with 179 additions and 803 deletions
|
|
@ -3,13 +3,6 @@ module TypeCheck where
|
|||
import Expr
|
||||
import Control.Monad
|
||||
|
||||
data Type = BoolT
|
||||
| IntT
|
||||
| ListT Type
|
||||
| TreeT Type
|
||||
| AnyT
|
||||
deriving (Read, Show, Eq, Ord)
|
||||
|
||||
typeOf :: Value -> Type
|
||||
typeOf (BoolV {}) = BoolT
|
||||
typeOf (IntV {}) = IntT
|
||||
|
|
@ -25,9 +18,6 @@ isList x | ListT {} <- typeOf x = True
|
|||
isTree x | TreeT {} <- typeOf x = True
|
||||
| otherwise = False
|
||||
|
||||
data TypeConf = TypeConf { typeConfInput :: [Type],
|
||||
typeConfOutput :: Type }
|
||||
|
||||
checkType :: TypeConf -> Expr -> Maybe Type
|
||||
checkType conf (left :&&: right) = do BoolT <- checkType conf left
|
||||
BoolT <- checkType conf right
|
||||
|
|
@ -70,7 +60,7 @@ checkType conf (left ::: right) = do t <- checkType conf left
|
|||
ListT u <- checkType conf right
|
||||
guard $ t == u
|
||||
return $ ListT t
|
||||
checkType conf EmptyListE = return $ ListT AnyT -- TODO
|
||||
checkType conf EmptyListE = return $ ListT AnyT -- TODO FIXME: deal with AnyT
|
||||
checkType conf (IsLeafE e) = do TreeT _ <- checkType conf e
|
||||
return BoolT
|
||||
checkType conf (TreeValE e) = do TreeT t <- checkType conf e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue