Haskell Syntax: Parse Error On Input
Posted
by
NuNu
on Stack Overflow
See other posts from Stack Overflow
or by NuNu
Published on 2012-11-17T00:38:47Z
Indexed on
2012/11/17
11:03 UTC
Read the original article
Hit count: 294
haskell
|syntax-error
As part of a mini-haskell compiler that I'm writing, I have a function named app
. What I want this function to do is take in these arguments epp (App e1 e2)
. The first step would be to evaluate e1
recursively (epp e1
) and check if the output would be an error. If not then evaluate e2
and then call another function eppVals
to evaluate the outputs of the calls on e1
and e2
which I defined as v1
and v2
respectively.
epp (App e1 e2)
| epp e1 /= Error = eppVals v1 v2
| otherwise = Error
where v1 = epp e1
v2 = epp e2 <- parse error on input `='
Logically I believe what I have written so far works but I'm getting a parse error on input =
where I stated above. Any idea why?
My second try
epp :: Exp -> Error Val
epp (App e1 e2) = (eppVals v1 v2) where
v1 = (epp e1)
v2 = (epp e2)
But now throws Couldn't match expected type Val with actual type Error Val
© Stack Overflow or respective owner