main :: IO ()
main = do
putStr "Name: "
n <- getLine
putStrLn n
/prog/, why doesn't this code work? I understand laziness, so "n" won't be evaluated until it's needed in "putStrLn", but why does "n" get evaluated, then "putStr" and "putStrLn" get evaulated?
tl;dr How the hell do you prompt for information in Haskell?
Name:
Anonymous2008-07-13 8:38
This is the output I get, by the way. The first "Hello" is the input.
First, no need to import IO, all the functions here are in Prelude.
Second, it works for me.
And there's no laziness here.
And use getArgs.
Name:
Anonymous2008-07-13 8:50
>>4
Hmmm. I'll provide some more info, then. I'm using GHC 6.8.2 on Arch Linux x86-64.
Name:
Anonymous2008-07-13 8:51
Huh, it seems to work with GHCi, but not when compiled.
Name:
Anonymous2008-07-13 9:00
Your problem is not caused by laziness, but by IO buffering. stdout is linebuffered by default, so it will only print something when it has a whole line in its buffer.
Put hFlush stdout after putStr "Name: " or disable buffering with hSetBuffering stdout NoBuffering.
>>9
Wow, you are so cool, you said ``n00bs'' because you're superior and you said ``fail'' because we're at 4chan. I bet you have a lot of friends because of them.
>>11
Are you fucking retarded you fucking piece of shit, who the fucking flying fuck doesn't know about buffering?
Yes, I said n00bs because I'm superior. So what? I can't have friends because I'm superior to OP? Your logic is broken.
>>17
What does you age matter when you act like you're twelve?
Name:
MATHEMATICA MEME FAN2008-07-13 13:08
>>19
I would like to hax your anus with Fibonacci numbers.
In[1]:= Table[Fibonacci[n], {n, 10}]
Out[1]= {1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
Name:
Anonymous2008-07-13 13:14
Your age doesn't matter on the Internet. Your life has no impact on how people perceive you here. You might lead a successful life, you might be a beggar. You're not how much money you have in the bank. You're not the car you drive. You're not the contents of your wallet. If you act like a kid, you are kid.
Grow up, kid.
Name:
HMA MEME FAN2008-07-13 13:18
>>23
You obviously did not know that I am an EXPERT MATLAB PROGRAMMER and can therefore hax your anus with my efficient numerical approximations.
Прискорбно и отвратительно всё это.
Sad and disgusting all this.
Горите в императивном аду, а Saymonk Peyote Joints будет танцевать на вашей могиле.
Gore mandatorily hell, and Saymonk Peyote Joints will dance on your tomb.
Name:
Anonymous2008-07-13 17:46
>>9
OP here, I know about buffering, I just didn't know that GHC line-buffers stdout.
Name:
Anonymous2008-07-13 17:53
I feel kinda bad about OP having his thread ravaged by evil people :( I don't know why am I feeling like this, normally I wouldn't give a damn, but something got me this time.
Name:
Anonymous2008-07-13 17:56
>>30 Gore mandatorily hell, and Saymonk Peyote Joints will dance on your tomb.