IO behaves oddly if used nested

blaat blaat l4t3r at hotmail.com
Wed Oct 1 23:33:17 EDT 2003


Hi, the interact remark triggered me to post this remark on nested use of 
IO. (I posted something similar some month ago on haskell-cafe/I read the 
haskell-archives ones so often)

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>>?

Another question with a trivial answer, what is the result of:

  main :: IO (IO ())
  main = return (putStr "Hello World!")

Clearly it also shows the relation between IO and chosen evaluation 
strategy.

Cheers,
  l4t3r

Some other random thoughts:....

Hmm,... there was also some question on the use of existential types, what 
about the following one (might be used to implement IO trivially in a 
_pure*_ manner! *with respect to rewrite strategy):

  data Nomad a = Return a | forall b . Bind (Nomad b) (b -> Nomad a)

I would like to see Haskell extended with subtyping on algebraic datatypes 
(or is this implemented already?) Some of my programs would really benefit 
from such a feature.

I am a teacher, I use haskell to test random ideas from combinatorics, 
SAT/EDA verification, control theory, real-time processes, and 
compiler/verification-language implementation. In short, I use Haskell as a 
vehicle to test short algorithms.

Oh yeah, I propose to move the link on the Haskell site on "Monads explained 
by the Catholic Church" from the "Humor" section to the "Learning Haskell" 
section since they seem to be the only ones who actually clearly understand 
what is up with monadic IO. ;-p (actually, that is a dead-serious 
proposition)

Hmm, long post, cheers again,
  l4t3r

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail



More information about the Haskell mailing list