Re[2]: [Haskell-cafe] Functions with side-effects?

2005-12-23 Thread Bulat Ziganshin
Hello Daniel, Wednesday, December 21, 2005, 6:24:29 PM, you wrote: DC So I can have an IO bit (e.g. a do-block) that calls functions (which DC are purely functional code) but I can't have a function that executes DC any IO. it's true DC For example, it is not possible to write a function

Re: [Haskell-cafe] Functions with side-effects?

2005-12-23 Thread Glynn Clements
Daniel Carrera wrote: I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). Those aren't functions. A function is a single-valued relation, i.e. a (possibly infinite) set of ordered

[Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really understand monads yet. Is there someone who might explain this

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really understand

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Cale Gibbard [EMAIL PROTECTED] wrote: On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my very first IO program with Haskell: --//-- main = do

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my very

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread David Roundy
On Wed, Dec 21, 2005 at 11:43:42AM +, Daniel Carrera wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking especially about the I/O monad here. A monad as such is a rather general concept like a group is in algebra. The important

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Creighton Hogg wrote: x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. Hmm... let's see if I understand: * getLine() has type IO String. * The - will convert an IO String to a plain String * So if I do x - getLine() then x has the type

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread David Barton
Wolfgang Jeltsch writes: - Original Message - Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking especially about the I/O monad here. A monad as such is a rather

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Creighton Hogg wrote: x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. Hmm... let's see if I understand: * getLine() has type IO String. * The - will convert an IO String to a plain String

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 16:28 schrieb David Barton: Wolfgang Jeltsch writes: - Original Message - Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Greg Woodhouse
--- Wolfgang Jeltsch [EMAIL PROTECTED] wrote: I think Phil Wadler said it best when he said that a monad is a *computation*. To be honest, I'm still struggling with the monad concept myself. Oh sure, I can read the definition and it makes sense. But I'm still missing that aha! moment when

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 19:02 schrieben Sie: [...] You (or, rather the processor) don't execute instructions to write Hello in same way as, say, adding 2 and 2. Exactly! Rather, you add writing this string to a to do list and wait for a driver to respond to an interrupt, pick up the