Top Level TWI's again was Re: [Haskell] Re: Parameterized Show

Lennart Augustsson lennart at augustsson.net
Tue Nov 23 04:39:02 EST 2004


Adrian Hey wrote:
>As for openDevice, if a device should only allow a single open I would
>>assume this is part of the device driver in the operating system?
>>(I know this is shifting blame.  But I think it shifts it to where it
>>belongs.  In the OS there will be an "open" flag per device.)
> 
> 
> IOW there is no possible sound solution in Haskell. I think that's
> a problem for a "general purpose" programming language. What if
> there is no OS or device driver? Shouldn't people reasonably expect
> to be able to write their own device driver in a general purpose
> programming language?

I find it hard to argue these things in the abstract.  Could you
post us a (simplified) signature for a module where you are
using top level variables?  Maybe that way I can be convinced
that you need them.  Or vice versa. :)

If there's no OS nor driver you are free to do what you like, so
I claim you can do without top level variables.

I've written plenty of device drivers in C for NetBSD.  They (almost)
never use top level mutable variables (except to control debugging
level).  If you use top level variables it always bites you in the end.
On some occasions I started with using top level mutables (like keeping
a free list of transfer descriptors), but in the end I always had to
change them to be local to some other piece of state.  (I didn't
change because of purity reasons, but out of necessity.)  So my aversion
for top level mutables does not stem from Haskell alone.

	-- Lennart


More information about the Haskell mailing list