Channels have identity, so allocating a new one is a side effecting
operation. Having it outside the IO monad would require (for example):

(newChan, newChan) = (let x = newChan in (x,x))

which is wrong. If you wrap newChan in unsafePerformIO then the compiler
will feel free to apply rewrites like the above, which is unlikely to be
what you wanted.

  Nick
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of S. Alexander Jacobson
Sent: 23 April 2004 19:22
To: Haskell Mailing List
Subject: [Haskell] Why is newChan in the IO Monad?

Nothing actually happens when newChan is called
except construction of a new datastructure.  It
would be nice to have non IO monad code be able to
create a new Chan that gets passed to IO code that
uses it somewhere else.

Alternatively, is there a way to create a Chan
outside the IO monad?

-Alex-

_________________________________________________________________
S. Alexander Jacobson                  mailto:[EMAIL PROTECTED]
tel:917-770-6565                       http://alexjacobson.com
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to