Re: [Haskell-cafe] Re: Parsers are monadic?

Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written.
----- Original Message ----
From: Jules Bean
Thanks, that was helpful. I didn't realize that there were pure functional monads.
Actually, it's stronger than that. All monads are pure functional, even IO. Haskell is an entirely 100% pure functional language[*]. The IO monad allows you to build up, in a pure, referentially transparent way, an object call an 'IO action' which you have no way of actually executing, per se. Fortunately, this isn't as useless as it sounds since the runtime system contains the support to "actually run" the special IO action called 'main', which bootstraps the whole setup. Jules [*] non-functions like unsafePerformIO are not technically part of the haskell language! ____________________________________________________________________________________ Never miss an email again! Yahoo! Toolbar alerts you the instant new Mail arrives. http://tools.search.yahoo.com/toolbar/features/mail/

Gregory Propf wrote:
Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written.
There is more than one way to look at this, but I wouldn't say purity is broken, not even by the main function. You can think of an IO action as an 'execution plan', containing detailed instructions on obtaining input, applying functions, branching, creating output, etc. The compiler takes the 'main' execution plan, and creates a program that will actually perform it. As a programmer, you only compose execution plans, which is nice and pure. Kind regards, Arie

Hello Gregory, Tuesday, July 3, 2007, 1:02:44 AM, you wrote:
Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break
i recommend you to read two htmls: http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html and http://haskell.org/haskellwiki/IO_inside -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (3)
-
Arie Peterson
-
Bulat Ziganshin
-
Gregory Propf