1

Can't seem to line up (indent) this code correctly in Haskell. Getting error:

parse error on input `<-'

Can anyone spot where the error is at:

evalListSplitAt n stratPref stratSuff [] = return []
evalListSplitAt n stratPref stratSuff xs = do ys` <- stratPref ys
                                              zs` <- stratSuff zs
                                            return (ys` ++ zs`)
                                            where (ys,zs) = splitAt n xs

Cheers.

1 Answer 1

9

You need to indent every line in a do block equally. Also, make sure to use ' for variable names rather than `. (That is, use an apostrophe rather than a backtick. Backticks are used for making functions infix, so they cannot be used as part of a variable name. So you can name something "x prime" using an apostrophe: x'.) So your code should look something like this:

evalListSplitAt n stratPref stratSuff [] = return []
evalListSplitAt n stratPref stratSuff xs = do ys' <- stratPref ys
                                              zs' <- stratSuff zs
                                              return (ys' ++ zs')
                                        where (ys,zs) = splitAt n xs
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.