Empty 'do' constructor

I use Haskell Platform 2010.2.0.0 on WinXP, and jEdit. I write my first code, and got error... main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs myManupulation cs = (unlines cs) ! 3 The error message is "Empty 'do' construct" What's this mean? and how can I fix it? Thank you a lot! -- Sok Ha, CHANG Open Mind Clinic/Academy, 1551-1, Sa-Dong, SangRok-Gu, AnSan-City, KyongGi-Do Tel: 031-407-6114 HP: openmind.ac / www.openmind.ac

On Sat, Sep 25, 2010 at 01:43:33PM +0900, Sok H. Chang wrote:
I use Haskell Platform 2010.2.0.0 on WinXP, and jEdit. I write my first code, and got error...
main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs
myManupulation cs = (unlines cs) ! 3
Because putStrLn is not indented it is not considered part of the do-block. You should line it up under the stuff after the 'do', like this: main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs -Brent

Thank you to your answer!
I indent me code as you said.
I tried using Tab, using spaces…
But can't work.
Is there another possibility?
Thank you!
- Chang.
2010. 9. 25. 오후 1:49 Brent Yorgey
On Sat, Sep 25, 2010 at 01:43:33PM +0900, Sok H. Chang wrote:
I use Haskell Platform 2010.2.0.0 on WinXP, and jEdit. I write my first code, and got error...
main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs
myManupulation cs = (unlines cs) ! 3
Because putStrLn is not indented it is not considered part of the do-block. You should line it up under the stuff after the 'do', like this:
main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs
-Brent _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 25/09/10 08:21, Sok H. Chang wrote:
Thank you to your answer! I indent me code as you said. I tried using Tab, using spaces… But can't work.
Is there another possibility? Thank you!
With the code looking like this: main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs myManupulation cs = (unlines cs) ! 3 Then it's indented properly, but it still doesn't compile because its types don't line up properly. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

You are expecting unlines to be String -> [String] but it's [String] -> String. The function you're looking for is probably Data.List.lines. The list indexing operator is !! and not !. Your function should then probably be: myManupulation cs = (lines cs) !! 3 On Sat, 2010-09-25 at 10:02 +0100, Magnus Therning wrote:
On 25/09/10 08:21, Sok H. Chang wrote:
Thank you to your answer! I indent me code as you said. I tried using Tab, using spaces… But can't work.
Is there another possibility? Thank you!
With the code looking like this:
main = do cs <- readFile "C:\\SPR.txt" putStrLn $ myManupulation cs
myManupulation cs = (unlines cs) ! 3
Then it's indented properly, but it still doesn't compile because its types don't line up properly.
/M
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (4)
-
Brent Yorgey
-
jean verdier
-
Magnus Therning
-
Sok H. Chang