Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Tony Finch
On Sat, 29 Apr 2006, Lennart Augustsson wrote: > > And yes, somewhere there's some global mutable state in the OS. > I've never claimed that it should be totally forbidden. Various > circumstances forces it upon us. What I've been claiming is that > it should be avoided where possible. Which is

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Brian Hulley
Adrian Hey wrote: Brian Hulley wrote: The use of a plain value to initialize the ref rather than a monadic computation would ensure that there would be no problems with trying to work out which order to initialize top level refs that are dependent on values of refs in other modules since there c

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Adrian Hey
Brian Hulley wrote: The use of a plain value to initialize the ref rather than a monadic computation would ensure that there would be no problems with trying to work out which order to initialize top level refs that are dependent on values of refs in other modules since there could be no depend

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Brian Hulley
Brian Hulley wrote: The use of a plain value to initialize the ref rather than a monadic computation would ensure that there would be no problems with trying to work out which order to initialize top level refs that are dependent on values of refs in other modules since there could be no dependen

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Brian Hulley
Lennart Augustsson wrote: And yes, somewhere there's some global mutable state in the OS. I've never claimed that it should be totally forbidden. Various circumstances forces it upon us. What I've been claiming is that it should be avoided where possible. Which is almost always. Thus there s

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Lennart Augustsson
Adrian Hey wrote: I've written about 5 lines of USB devices drivers for *BSD (in C). They work from the bare metal and up. They contain no global mutable state (except for variables that define debugging levels, because you need to access these from the in-kernel debugger). Yes, I was awar

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Adrian Hey
Lennart Augustsson wrote: Adrian Hey wrote: Or put another way, would it be possible to implement the socket API, exactly as it currently is, entirely in Haskell, starting with nothing but hardware? I don't believe it is possible, but perhaps somebody can show me I'm wrong. If I get to implemen

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread John Meacham
On Thu, Apr 27, 2006 at 09:53:35PM +0100, Brian Hulley wrote: > At the moment, there is a strange unnatural discrepancy between the fixed > set of built-in privileged operations such as newUnique which are "allowed" > to make use of global state and user defined operations which have to rely > o

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread Brian Hulley
John Meacham wrote: On Thu, Apr 27, 2006 at 11:09:58AM +0100, Adrian Hey wrote: What really frustrates me about all this is that AFAIK there are no significant technical or theoretical reasons why we can't get this safety (without resort to the unsafePerformIO hack). The only serious obstacle se

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread John Meacham
On Thu, Apr 27, 2006 at 11:09:58AM +0100, Adrian Hey wrote: > What really frustrates me about all this is that AFAIK there are no > significant technical or theoretical reasons why we can't get > this safety (without resort to the unsafePerformIO hack). The > only serious obstacle seems political,

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread Lennart Augustsson
Not to fuel the flame war, I will limit myself to two comments. Adrian Hey wrote: Or put another way, would it be possible to implement the socket API, exactly as it currently is, entirely in Haskell, starting with nothing but hardware? I don't believe it is possible, but perhaps somebody can sh

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread Adrian Hey
Lennart Augustsson wrote: I was going to respond, but Cale very eloquently said most of what I was thinking. I don't think eloquent is the word I would use, but I'm certainly glad you didn't feel the need to repeat all that. It'd be really nice if just for once the "global mutable state is evil

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-24 Thread Robert Dockins
On Apr 24, 2006, at 2:42 AM, Adrian Hey wrote: Lennart Augustsson wrote: I think global mutable variables should be regarded with utmost suspicion. There are very few situations where they are the right solution. Well IMO even the use of the term "global mutable variable" causes muddled thin

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-24 Thread Lennart Augustsson
Adrian Hey wrote: . I was going to respond, but Cale very eloquently said most of what I was thinking. Let me just add one thing. Sometimes you hear the argument "I need a global IORef here because it's to track the use of my single screen" (or keyboard, or elevator, or some some other gizm

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-24 Thread Cale Gibbard
On 24/04/06, Adrian Hey <[EMAIL PROTECTED]> wrote: > Lennart Augustsson wrote: > > I think global mutable variables should be regarded with utmost > > suspicion. There are very few situations where they are the > > right solution. > > Well IMO even the use of the term "global mutable variable" cau

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-23 Thread Adrian Hey
Lennart Augustsson wrote: I think global mutable variables should be regarded with utmost suspicion. There are very few situations where they are the right solution. Well IMO even the use of the term "global mutable variable" causes muddled thinking on this and I wish people would stop it. The

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-23 Thread Lennart Augustsson
Robert Dockins wrote: Ahhh... the singleton pattern. There is a debate among OO theorists about whether the singleton pattern is actually a good idea. I tend to side with those who say that it is Just Wrong. The reality is that "singletons" are only unique within some scope (OS process, VM

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Brian Hulley
Brian Hulley wrote: Robert Dockins wrote: Sometimes I also think it would be nice if all the standard lib functions with IO types would instead take arbitrary MonadIO types, so you could avoid having to write down liftIO all the time Thanks for the suggestion - it is certainly a lot better

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Brian Hulley
Robert Dockins wrote: Are you compiling with -fglasgow-exts? You're relying on generalized newtype deriving, which is a GHC extension. http://www.haskell.org/ghc/docs/latest/html/users_guide/type- extensions.html#newtype-deriving If that's not it, what's the error you are getting? 'MonadStat

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Cale Gibbard
On 21/04/06, Brian Hulley <[EMAIL PROTECTED]> wrote: > Robert Dockins wrote: > > On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: > >> Robert Dockins wrote: > >>> On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: > >>> > Hi - > I've run into the global mutable state problem described in h

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 1:27 PM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// [snip] There is only

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Brian Hulley
Robert Dockins wrote: On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// [snip] There is only one GUI for the application and only one control in it

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 10:34 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year, I'm won

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Brian Hulley
Robert Dockins wrote: On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year, I'm wondering if there have been any developments or furth

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Robert Dockins
On Apr 21, 2006, at 9:56 AM, Brian Hulley wrote: Hi - I've run into the global mutable state problem described in http:// www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year, I'm wondering if there have been any developments or further thoughts on how

[Haskell-cafe] Current situation regarding global IORefs

2006-04-21 Thread Brian Hulley
Hi - I've run into the global mutable state problem described in http://www.haskell.org/hawiki/GlobalMutableState Since the page was last edited in March last year, I'm wondering if there have been any developments or further thoughts on how to safely create top level IORefs since they are abso