Fixed error message

This commit is contained in:
sebastianselander 2023-05-15 13:45:50 +02:00
parent 229679f60d
commit 9495c3b12a
3 changed files with 7 additions and 10 deletions

View file

@ -13,7 +13,7 @@ add x y = x + y
sum : List Int -> Int
sum xs = case xs of
Nil => 0
Cons a as => a + (sum xs)
Cons x xs => x + (sum xs)
main : Int
main = sum (map (add 1) (Cons 1 Nil))
main = sum (map (add 1) (Cons 4 (Cons 3 (Cons 2 (Cons 1 Nil)))))

View file

@ -1,9 +1,6 @@
data List a where
Nil : List a
Cons : a -> List a -> List a
data Pair a b where
Pair : a -> b -> Pair a b
-- data List a where
-- Nil : List a
-- Cons : a -> List a -> List a
data Exp where
EVar : Char -> Exp
@ -34,7 +31,7 @@ eval cxt exp = case exp of
EAbs x e => VClosure cxt x e
EApp e1 e2 => case eval cxt e1 of
-- FIXME segmentation fault när man löser f istället för 1000
VClosure delta x f => eval delta (EInt 1000)
VClosure delta x f => eval delta f
-- EApp e1 e2 => case eval cxt e1 of
-- VClosure delta x f =>
-- let v = VClosure cxt x e2 in

View file

@ -94,7 +94,7 @@ newtype Rn a = Rn {runRn :: ExceptT String (State Cxt) a}
getName :: LIdent -> Rn LIdent
getName name = maybeToRightM err =<< gets (Map.lookup name . names)
where err = "Can't find new name " ++ printTree name
where err = "Unbound variable: '" ++ printTree name ++ "'"
newName :: LIdent -> Rn LIdent
newName name = do