2

I am compiling this code and receving the error of "parse error on input '='`

import System.IO  
import Data.List.Split
main = do  
   handle <- openFile "ac/abc" ReadMode  
   contents <- hGetContents handle  
   let xs = splitOneOf "; \n " contents       
   print xs   
   readStrList contents = do 
       print contents
   hClose handle

please suggest what is wrong

2
  • What are you trying to accomplish with the readStrList line? Commented Jan 26, 2012 at 7:33
  • actually i was trying another way of recursion as forM_ requires hoogle.this worked.thanks Commented Jan 26, 2012 at 7:51

1 Answer 1

7

The problem is in these lines:

readStrList contents = do 
    print contents

If you're trying to define readStrList, then you need to put let in front:

let readStrList contents = do
        print contents
Sign up to request clarification or add additional context in comments.

2 Comments

But that definition wouldn't do anything, since contents would shadow the outer contents, and the function is never called. (Not saying you're wrong, just that I can't make heads or tails of what the line is trying to do, but that's probably not it.)
@Chuck: I assumed that it was intended to be used later on within the do block. But I agree, it's difficult to tell what's intended here.

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.