From: Mart Lubbers Date: Wed, 20 Mar 2019 07:43:38 +0000 (+0100) Subject: fix check X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=84dafc0cc9d23296b66ac16c5af7b360b29c9a7b;p=minfp.git fix check --- diff --git a/check.icl b/check.icl index e27f446..a18a378 100644 --- a/check.icl +++ b/check.icl @@ -22,7 +22,9 @@ check fs | length dups > 0 = Left ["Duplicate functions: ":[toString n\\[(Function n _ _):_]<-dups]] = case partition (\a->a=:(Function ['start'] _ _)) fs of ([], _) = Left ["No start function defined"] - ([Function _ [] e:_], fs) = (\x->(e, x)) <$> runInfer (infer (fromList builtin) $ makeExpression fs e) + ([Function _ [] e:_], fs) + # e = makeExpression fs e + = (\x->(e, x)) <$> runInfer (infer (fromList builtin) e) ([Function _ _ _:_], _) = Left ["Start cannot have arguments"] makeExpression :: [Function] Expression -> Expression diff --git a/int.dcl b/int.dcl index 356b986..d314ca8 100644 --- a/int.dcl +++ b/int.dcl @@ -5,3 +5,4 @@ from ast import :: Expression, :: Value :: Eval a int :: Expression -> Either [String] Value +eval :: Expression -> Eval Value diff --git a/tests/preamble.mfp b/tests/preamble.mfp index b984811..70fc870 100644 --- a/tests/preamble.mfp +++ b/tests/preamble.mfp @@ -10,16 +10,12 @@ $ ifxr 0 x y = x y; + ifxl 6 = code add; on f g a b = f (g a) (g b); -onn = \f. \g. \a. \b. f (g a) (g b); //Conditional operators if = code if; -//fac i = if (i == 0) 1 $ i * fac (i - 1); +fac i = if (i == 0) 1 $ i * fac (i - 1); id x = x; even i = if (i == 0) True (odd (i - 1)); odd i = if (i == 0) False (even (i - 1)); - -//start = on; -start = ($) id 42;