Re: [Haskell-cafe] background question about IO monad

2008-02-07 Thread Jonathan Cast
On 6 Feb 2008, at 11:32 PM, Uwe Hollerbach wrote: All right, after a bit of dinner and some time to mess about, here's another attempt to check my understanding: here is a simplified version of the lisp-time example: module Main where import System.Time pure_fn :: Integer - String pure_fn n

Re: [Haskell-cafe] background question about IO monad

2008-02-07 Thread Ryan Ingram
On 2/6/08, Uwe Hollerbach [EMAIL PROTECTED] wrote: And, coming back to my scheme interpreter, this is at least somewhat irrelevant, because, since I am in a REPL of my own devising, I'm firmly in IO-monad-land, now and forever. This is not entirely true; a REPL can be pure. Consider the

Re: [Haskell-cafe] background question about IO monad

2008-02-07 Thread Uwe Hollerbach
Thanks, I'm going to have to study this a bit... Uwe On 2/7/08, Ryan Ingram [EMAIL PROTECTED] wrote: On 2/6/08, Uwe Hollerbach [EMAIL PROTECTED] wrote: And, coming back to my scheme interpreter, this is at least somewhat irrelevant, because, since I am in a REPL of my own devising, I'm

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Tillmann Rendel
Uwe Hollerbach wrote: lispUTCTime [] = doIOAction (getClockTime) toS allErrs where toS val = String (calendarTimeToString (toUTCTime val)) here you use liftIO (hidden in doIOAction) to use an IO action (getClockTime) inside of a different monad wich contains IO at it's base. so your custom

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Bulat Ziganshin
Hello Uwe, Wednesday, February 6, 2008, 7:44:27 AM, you wrote: But after that, it sure seems to me as if I've taken data out of the IO monad... this means that you can't use results of IO actions in pure functions. your code works in some transformed version of IO monad, so you don't escaped

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Uwe Hollerbach
Hi, all, thanks for the responses. I understand the distinction between pure functions and impure functions/procedures/IO actions, it just felt to me in the samples that I quoted that I was in fact starting from basically the starting point, eventually getting to the same endpoint (or at least a

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Jonathan Cast
On 6 Feb 2008, at 7:30 PM, Uwe Hollerbach wrote: Hi, all, thanks for the responses. I understand the distinction between pure functions and impure functions/procedures/IO actions, Um, I'm not sure of that, given what you go on to say. it just felt to me in the samples that I quoted that I

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Uwe Hollerbach
Well, you may well be right! Just think of me as a planarian at the opera... :-) On 2/6/08, Jonathan Cast [EMAIL PROTECTED] wrote: On 6 Feb 2008, at 7:30 PM, Uwe Hollerbach wrote: Hi, all, thanks for the responses. I understand the distinction between pure functions and impure

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Uwe Hollerbach
All right, after a bit of dinner and some time to mess about, here's another attempt to check my understanding: here is a simplified version of the lisp-time example: module Main where import System.Time pure_fn :: Integer - String pure_fn n = calendarTimeToString (toUTCTime (TOD n 0))

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Luke Palmer
On Feb 7, 2008 7:32 AM, Uwe Hollerbach [EMAIL PROTECTED] wrote: pure_fn :: Integer - String pure_fn n = calendarTimeToString (toUTCTime (TOD n 0)) make_wicked :: String - IO String make_wicked str = return str -- use of make_wicked main = (make_wicked (pure_fn 1234567890)) =

[Haskell-cafe] background question about IO monad

2008-02-05 Thread Uwe Hollerbach
Hello, haskellers, I have a question for you about the IO monad. On one level, I seem to be getting it, at least I seem to be writing code that does what I want, but on another level I am almost certainly not at all clear on some concepts. In various tutorials around the web, I keep finding this

Re: [Haskell-cafe] background question about IO monad

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 9:44 PM, Uwe Hollerbach [EMAIL PROTECTED] wrote: lisp (UTCtime) Wed Feb 6 03:57:45 UTC 2008 --- lisp (UTCtime 1.203e9) Thu Feb 14 14:40:00 UTC 2008 -- But after that, it sure seems to me as if I've taken data out of the IO monad... haven't I? Given that the second