jdoodle.hs:10:9: error:
parse error on input ‘=’
Perhaps you need a ‘let’ in a ‘do’ block?
e.g. ‘let x = 5’ instead of ‘x = 5’
|
10 | xs = array (1,9) [(1,9),(1,1),(2,8),(3,2),(4,5),(6,7),(7,3),(8,6),(9,4)]
| ^
You’ve declared main :: IO () – good, that’s a typical signature for main. You’ve started main = do – also good. But you’ve not told what to do. Even supposing xs = ... would make sense in a do block (which it doesn’t), what happens next with xs? Do you want to quicksort it? Do you want to print the result?
I don’t see anything specific to array here. Start with baby steps. Try first binding an Int literal to some variable x and getting GHC to print that.
Are you sure with this? Perhaps it could have at least provided helpful link to discover what is possibly wrong.
E.g. what error message would your favorite language give?
@Ewerton is not working from any sort of tutorial. (I don’t know of anywhere they might have found code like this.)
Or they think Haskell is (C? Java? Javascript? Python? something procedural?).
I don’t expect GHC to guess which tutorial somebody might be using; I don’t expect GHC to guess which other language this code might resemble. I don’t expect GHC to provide a link to a basic Haskell tutorial on do blocks (because there are so many – amongst many other reasons).
I think GHC is making as helpful as possible a suggestion, given the code couldn’t possibly be any sort of Haskell: it’s not like you could switch on an extension and the code would make more sense.
My favourite compiler for my favourite language says:
Syntax error in input (unexpected `=') -- pointing at the `=` of the binding to `xs`