[Haskell-cafe] New to Haskell

Cristian Baboi cristi at ot.onrc.ro
Tue Dec 18 05:53:06 EST 2007

Thank you very much!

On Tue, 18 Dec 2007 12:17:54 +0200, Jules Bean <jules at jellybean.co.uk>  

> Cristian Baboi wrote:
>> On Tue, 18 Dec 2007 10:29:43 +0200, Miguel Mitrofanov  
>> <miguelimo38 at yandex.ru> wrote:

>>>> - what guarantees are made by the LANGUAGE that an IO action (such  
>>>> as  do
>>>> putStrLn "Hello world" ) is not performed twice
>>> There are no such guarantees. If you write
>>> a = putStrLn "Hello world"
>>> main = do {a; a;}
>>> then your putStrLn would be performed twice. IO actions are  
>>> first-class values, that's a feature, not a bug.
>>   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 ?
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 !!!

>>>> - the lambda expressions can be written (input) but cannot be printed
>>>> (output)
>>> Yes, since two different lambda expressions can denote the same  
>>> function.
>> I just want the sistem to be able to print one of these expressions !
>>  Its this too much to ask ?
>> I find it very strange that I can write a lambda expresion, but the  
>> system cannot.

> Haskell doesn't contain a code representation natively. It is not a  
> "homoiconic" language. Just like C, C++, Java, Python, Perl, and Ruby,  
> the compiler/interpreter is free to transform code into some more  
> efficient form for running (including transformation all the way to  
> native code, which is what ghc does) and once it has done so, it retains  
> no information about the "shape of" the source code which yielded the  
> function.

Thank you.

________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
  part000.txt - is OK

More information about the Haskell-Cafe mailing list