[Haskell-cafe] Re: Beginner: IORef constructor?

Benjamin Franksen benjamin.franksen at bessy.de
Wed Dec 6 03:58:21 EST 2006


On Wednesday 06 December 2006 07:40, Bernie Pope wrote:
> On 05/12/2006, at 1:00 PM, Benjamin Franksen wrote:
> > Bernie Pope wrote:
> >> If you want a global variable then you can use something like:
> >>
> >>     import System.IO.Unsafe (unsafePerformIO)
> >>
> >>     global = unsafePerformIO (newIORef [])
> >>
> >> But this is often regarded as bad programming style (depends who
> >> you talk to).
> >
> > Besides, isn't this example /really/ unsafe? I thought, at least
> > the IORef
> > has to be monomorphic or else type safety is lost?
>
> Perhaps your question is rhetorical, 

Half-way ;-) I was pretty sure but not 100%. Thanks for the nice 
example.

Cheers,
Ben


More information about the Haskell-Cafe mailing list