From: pimjager Date: Fri, 20 May 2016 11:35:39 +0000 (+0200) Subject: Woooo isEmpty X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=0567e0e242028586a71edb38d3fcac5b35df707f;p=cc1516.git Woooo isEmpty --- diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 4062fb6..e5d938b 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -36,6 +36,8 @@ main() { (Bool, Int) z = (True, 2); var y = z.fst; var x = (True, 5) : (False,0) : []; + var sdaf = isE(x1); + var z = isEmpty(x1); x.hd.snd = 8; return; } diff --git a/sem.icl b/sem.icl index 833d543..0ffcdd2 100644 --- a/sem.icl +++ b/sem.icl @@ -50,7 +50,7 @@ variableStream = map toString [1..] defaultGamma :: Gamma //includes all default functions defaultGamma = extend "print" (Forall ["a"] ((IdType "a") ->> VoidType)) - $ extend "isEmpty" (Forall ["a"] (ListType (IdType "a") ->> BoolType)) + $ extend "isEmpty" (Forall ["a"] ((ListType (IdType "a")) ->> BoolType)) $ extend "read" (Forall [] (IntType ->> (ListType CharType))) zero @@ -178,7 +178,6 @@ generalize :: Type -> Typing Scheme generalize t = gamma >>= \g-> pure $ Forall (difference (ftv t) (ftv g)) t lookup :: String -> Typing Type -lookup "isEmpty" = ListType <$> fresh lookup k = gamma >>= \g-> case 'Map'.member k g of False = liftT (Left $ UndeclaredVariableError zero k) True = instantiate $ 'Map'.find k g