0

I have this function that checks a list of parsers if they work or not. I get error: EQUALO LPAREN FN. Any help?

fun oneOf [] = fn inp => NONE
 | oneOf (p::ps) = (fn inp => case parse p inp of
       NONE => oneOf ps inp
     | SOME (v,out) => SOME (v,out))

1 Answer 1

3

A function defined with fn can have multiple cases just like a function defined with fun. So you can write something like fun pat1 => exp1 | pat2 => exp2. This means that when the SML parser sees the | at the beginning of line 2, it assumes that it belongs to the fn on line 1, not to the fun (because the fn came more recently). So when it reaches the =, it's confused because it expected a =>.

To fix your issue surround the fn on line 1 with parentheses.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.