Top Level TWI's again was Re: [Haskell] Re: Parameterized Show
k.schupke at imperial.ac.uk
Mon Nov 22 06:26:56 EST 2004
Adrian Hey wrote:
>Just repeating this again and again doesn't make it any more true.
Ditto... I for one think the best solution is to use the language as
intended and pass the values as function arguments. As pointed out
on this list - the only possible situation where you cannot do this is
when interfacing to a badly written C library. In which case do your
one-shot initialisation in C, as you will be importing foreign functions
>you or any of the other nay-sayers have provided any evidence or credible
>justification for this assertion, nor have any of you provided any workable
>alternative for even the simplest example. Lennart has yet to explain how he
>proposes to implement his supposedly safer "openDevice". You have yet to
>explain how you propose to deal with stdout etc..
openDevice would use OS semaphores (like the namedSem library
I posted to the cafe) - the OS is the only thing that can deal with
device driver initialisations. Infact the OS driver should multiplex single
access devices such that access is serialised. I guess stdin, stdout etc
should be passed to main as arguments like you would any other
file handle. Although if file handles are simply Ints, then there is nothing
wrong with having:
stdin = 0
stdout = 1
stderr = 2
In this case they are not IO actions anyway.
>And of course there's one top level TWI that none of us can live
>without. I am refering to the unique and stateful "world" that is
>implicitly referenced by all IO operations (with the possible
>exception of those operations I would like to put in the "SafeIO"
>monad). So is this evil too? Perhaps it is, but if so, I'd like to
>know how you propose to live without it and what purpose the IO monad
>would serve in such a situation.
This is true - but only because unsafePerformIO exists. Without it
World is simply a value passed via the IO Monad.
I would ask an alternative question - is it possible to live without
unsafePerformIO? I have never needed to use it!
More information about the Haskell