Re: IO behaves oddly if used nested

2003-10-14 Thread Antti-Juhani Kaijanaho
On 20031004T181216+0100, Alastair Reid wrote: be careful to distinguish 'a value of type t' from 'a computation which returns a value of type t'i I always found the idea of a computation as a value a little hard to grasp. Therefore, when I introduced monadic transput in my functional

Re: IO behaves oddly if used nested

2003-10-06 Thread blaat blaat
[snip] Neither example is odd behavior, unless you consider Hugs providing a perfectly reasonable instance of Show for IO a odd. True, every program behaves exactly as according to the definition of the run-time behavior of Haskell programs. (Hugs deviates a bit from ghc but ah well) The odd

Re: IO behaves oddly if used nested

2003-10-04 Thread Alastair Reid
The odd is in the conceptual explanation. If I give a description of some f x = y function in Haskell I expect that some program f x is reduced to y and the result is given back (possibly printed). A good story to sell to students. This is true of IO as well. The bit that's tripping up your

Re: IO behaves oddly if used nested

2003-10-03 Thread Alastair Reid
I think it's wrong. The return type of IO should be discarded. I don't follow. I thought the question was 'what should this print?' not 'what is its type?' Even if it isn't, it doesn't make sense for IO to be in Show. The general policy for Haskell 98 libraries is that if you define a

RE: IO behaves oddly if used nested

2003-10-03 Thread Simon Marlow
Alastair Reid writes: ... Thus, we have Show instances for - and IO ... Actually, you have to explicitly import Text.Show.Functions to get the Show instance for (-). Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED]

Re: Feature-request (was: Re: IO behaves oddly if used nested)

2003-10-03 Thread ketil+haskell
Simon Marlow [EMAIL PROTECTED] writes: You don't need to know :-) It's actually in the base package, but GHCi knows about all hierarchical libraries without having to specify any extra command-line arguments. Ai! And here I've been doing :set -package all this time. -kzm -- If I haven't

Re: IO behaves oddly if used nested

2003-10-02 Thread Alastair Reid
What about this program: main :: IO () main = putStr (show (putStr Hello World!)) Am I the only one who feels that there is some conceptual _wrongness_ about Hugs responding with IO action? I think it is exactly right. Having it print Hello World would clearly be wrong since it

Re: IO behaves oddly if used nested

2003-10-02 Thread Lennart Augustsson
Alastair Reid wrote: Another question with a trivial answer, what is the result of: main :: IO (IO ()) main = return (putStr Hello World!) It is a computation which, if executed, will print Hello World Clearly it also shows the relation between IO and chosen evaluation strategy. This

Re: IO behaves oddly if used nested

2003-10-02 Thread Derek Elkins
On Thu, 02 Oct 2003 12:47:15 +0200 Lennart Augustsson [EMAIL PROTECTED] wrote: Alastair Reid wrote: Another question with a trivial answer, what is the result of: main :: IO (IO ()) main = return (putStr Hello World!) It is a computation which, if executed, will print Hello

Re: IO behaves oddly if used nested

2003-10-02 Thread Lennart Augustsson
Derek Elkins wrote: If I'm not mistaken, the Report restricts main's type to be, at least, IO a. Anyways, it's perfectly sensible to return anything. The RTS simply discards it. The above example as an entire program is an IO action that returns an IO action that is discarded by the RTS. You're

Re: IO behaves oddly if used nested

2003-10-02 Thread ajb
G'day all. Alastair Reid [EMAIL PROTECTED] wrote: I think it is exactly right. I think it's wrong. The return type of IO should be discarded. Even if it isn't, it doesn't make sense for IO to be in Show. Cheers, Andrew Bromage ___ Haskell mailing