3

I created a new quick.hs file in the ghci.exe directory. And the content is

quicksort::(Ord a)=>[a]->[a]  
quicksort []=[]  
quicksort (x:xs)=  
    let smaller = [a |a<-xs,a<=x]  
        larger = [a |a<-xs,a>x]  
    in  quicksort smaller ++ [x] ++ quicksort larger 

When I issue :l quick in the ghci command lline, the output is

Prelude> :l quick
[1 of 1] Compiling Main             ( quick.hs, interpreted )

quick.hs:5:17: error:
    parse error on input ‘=’
    Perhaps you need a 'let' in a 'do' block?
    e.g. 'let x = 5' instead of 'x = 5'
Failed, modules loaded: none.

I have concured this kind of problems many times. What's wrong on earth?

9
  • 5
    No repro Are you sure there are no tab characters in the file? Commented Aug 24, 2016 at 12:15
  • 2
    Looks OK to me. Use -Wall and check if it reports tabs in your code instead of spaces. (quick.sh instead of quick.hs above is just a typo in the posted question, right?) Commented Aug 24, 2016 at 12:16
  • I rewrited the code and made sure there is no tab in the file. But the error is still there...... Commented Aug 24, 2016 at 12:39
  • Is larger exactly defined on the same column as smaller? Commented Aug 24, 2016 at 13:04
  • 1
    @chi, was -fwarn-tabs included in -Wall before it was enabled by default? Commented Aug 24, 2016 at 17:10

2 Answers 2

8

You say in the comments that you are sure there are no tab characters in the source file, but inspecting the source of your question, indeed there is one right before the in token. Replace that with the appropriate number of spaces and you'll be all good.

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

1 Comment

I swear I have replaced all the tab characters with the appropriate number of spaces , but the error is still there
1

You have to remove all tabs and change it by spaces. I hope that this instruction helps you.

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.