[Haskell] Why is newChan in the IO Monad?
S. Alexander Jacobson
alex at alexjacobson.com
Fri Apr 23 16:05:05 EDT 2004
Yes, that makes sense, but I'm ok with passing in
an identity. I'd like a function like this:
newChanSafe::Identity -> Chan a
type Identity = Double -- or whatever
-Alex-
_________________________________________________________________
S. Alexander Jacobson mailto:me at alexjacobson.com
tel:917-770-6565 http://alexjacobson.com
On Fri, 23 Apr 2004, Nick Benton wrote:
> 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: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
> 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:me at alexjacobson.com
> tel:917-770-6565 http://alexjacobson.com
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
More information about the Haskell
mailing list