incomplete support for record types in the abstract syntax

This commit is contained in:
krasimir
2009-03-16 14:41:49 +00:00
parent e6da4bca2d
commit 6cdb1fcb06
5 changed files with 54 additions and 2 deletions

View File

@@ -186,6 +186,8 @@ val2expP safe v = case v of
VGen i x -> if safe
then prtBad "unsafe val2exp" v
else return $ Vr $ x --- in editing, no alpha conversions presentv
VRecType xs->do xs <- mapM (\(l,v) -> val2expP safe v >>= \e -> return (l,e)) xs
return (RecType xs)
VType -> return typeType
where
substVal g e = mapPairsM (val2expP safe) g >>= return . (\s -> substTerm [] s e)

View File

@@ -189,6 +189,7 @@ instance Print Val where
prt (VClos env e) = case e of
Meta _ -> prt_ e ++ prEnv env
_ -> prt_ e ---- ++ prEnv env ---- for debugging
prt (VRecType xs) = prCurly (concat (intersperse "," [prt l ++ "=" ++ prt v | (l,v) <- xs]))
prt VType = "Type"
prv1 v = case v of

View File

@@ -65,6 +65,7 @@ unify e1 e2 g =
(App c a, App d b) -> case unify c d g of
Ok g1 -> unify a b g1
_ -> prtBad "fail unify" e1
(RecType xs,RecType ys) | xs == ys -> return g
_ -> prtBad "fail unify" e1
extend :: Unifier -> MetaSymb -> Term -> Err Unifier

View File

@@ -35,7 +35,7 @@ import GF.Grammar.Predef
type Exp = Term
data Val = VGen Int Ident | VApp Val Val | VCn QIdent | VType | VClos Env Exp
data Val = VGen Int Ident | VApp Val Val | VCn QIdent | VRecType [(Label,Val)] | VType | VClos Env Exp
deriving (Eq,Show)
type Env = [(Ident,Val)]