[Haskell-cafe] New to Haskell

Jules Bean jules at jellybean.co.uk
Tue Dec 18 05:59:12 EST 2007

Cristian Baboi wrote:
    What guarantees that by running the main, the string "Hello world"
>>> will be printed exactly twice ?
>> The semantics of IO, and the guarantees of the runtime.
>> IO specifies that (>>) means "compose two actions to make a larger 
>> action which does the first actions, then the second action".
>> [do {a; a;} is notation for a >> a]
>> The RTS specifies that the "main" action is performed exactly once.
> Is this dependent on the implementation (if I use GHC or Hugs) or is 
> something that the language say ?

It's something the language says. IO is part of the runtime, its 
semantics are defined.

> Aside: I tried something like this in WinHugs:
> do { xxx<-getLine ; putStrLn xxx }
> and pressed two keys at once for the "getLine" action.
> The result I've got was an "infinite" loop !!!

If that code loops you have a bug (in hugs?) it certainly shouldn't.

It will wait until you press return before it prints anything, though.


More information about the Haskell-Cafe mailing list