Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Adrian Hey
On Thursday 11 Nov 2004 6:36 am, Judah Jacobson wrote: AFAIKS, the definition of once that I gave uses unsafePerformIO in a perfectly sound manner; namely, the creation of a top-level MVar. It only becomes unsafe if certain optimizations are performed; but then, that's also true for the

[Haskell-cafe] Sample rate inference

2004-11-11 Thread Henning Thielemann
I want to connect several functions for signal processing. The typical case is that in a network of signal processor there are parts that are already discretized such as sampled sounds, and there are processors with no particular sample rate such as amplifiers. But when it comes to computation

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Keean Schupke
Graham Klyne wrote: Keean, As far as I can tell, both your solutions to the one-shot problem require that: (a) the expression to be one-shotted is in the IO monad. That seems reasonable, since why else does one care (semantically speaking)? (b) they depend on the host operating system

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Graham Klyne
At 11:31 11/11/04 +, Keean Schupke wrote: Wouldn't it be easier to simply define once as a common Haskell library function? Erm, it is a library function (I provided the NamedSem library as an attachment)... Are you suggesting it would be nice to be able to do this without talking to the

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Ben Rudiak-Gould
Graham Klyne wrote: Wouldn't it be easier to simply define once as a common Haskell library function? Depends on the type and the expected semantics. As Adrian Hey already pointed out, (once :: IO a - IO a) with the obvious semantics is never going to be safe, because it's just not the case

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Andreas Bauer
On Thu, Nov 11, 2004 at 10:49:13AM +0100, Henning Thielemann wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some processors have the same fixed sample rate, all uncertain processors must adapt that. If some

Re: [Haskell-cafe] Space efficiency problem

2004-11-11 Thread Adrian Victor CRISCIU
Thanks for the advice. However, though I don't know how ghc manages the heap, I am not sure it is possible to achieve constant heap usage, because a value of type State is a function, and = is creating a call stack in this case. I mean, I think that, even if the argument of f :: a - State s a

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Henning Thielemann
On Thu, 11 Nov 2004, Andreas Bauer wrote: On Thu, Nov 11, 2004 at 10:49:13AM +0100, Henning Thielemann wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some processors have the same fixed sample rate, all

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Graham Klyne
At 12:27 11/11/04 +, Ben Rudiak-Gould wrote: Graham Klyne wrote: Wouldn't it be easier to simply define once as a common Haskell library function? Depends on the type and the expected semantics. As Adrian Hey already pointed out, (once :: IO a - IO a) with the obvious semantics is never

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Judah Jacobson
On Thu, 11 Nov 2004 09:16:04 +, Adrian Hey [EMAIL PROTECTED] wrote: That's the trouble with unsafePerformIO. Haskell is supposed to be a purely functional language and the compiler will assume all functions are pure. As soon as you use unsafePerformIO to create something that isn't a

Re: [Haskell-cafe] IO and State

2004-11-11 Thread Ben Rudiak-Gould
Iavor S. Diatchki wrote: In GHC the whole program stops when the main thread exits. So if the law I was talking about holds, this program should never terminate, as it will forever loop in 'reader'. However since there is a concurrent thread running that can modify the state, if 'reader' is

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Keith Wansbrough
Graham Klyne wrote: At 12:27 11/11/04 +, Ben Rudiak-Gould wrote: [..] going to be safe, because it's just not the case that x = once (newIORef ()) y = x has the same intended meaning as x = once (newIORef ()) y = once (newIORef ()) No amount of

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Koji Nakahara
On Thu, 11 Nov 2004 10:49:13 +0100 (MEZ) Henning Thielemann [EMAIL PROTECTED] wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some processors have the same fixed sample rate, all uncertain processors must adapt

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Keith Wansbrough
Koji Nakahara [EMAIL PROTECTED] wrote: On Thu, 11 Nov 2004 10:49:13 +0100 (MEZ) Henning Thielemann [EMAIL PROTECTED] wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some processors have the same fixed

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Glynn Clements
Henning Thielemann wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some processors have the same fixed sample rate, all uncertain processors must adapt that. If some processors have different

Re: [Haskell-cafe] Sample rate inference

2004-11-11 Thread Jeremy Shaw
Hello, This sounds vaguely like the encryption modulus problem dealt with in this paper: http://www.eecs.harvard.edu/~ccshan/prepose/prepose.pdf Function Pearl: Implicit Configurations -- or, Type Classes Reflect the Values of Types. Though, I have not thought about it too hard... Jeremy

Arrows (Re: [Haskell-cafe] Sample rate inference)

2004-11-11 Thread Koji Nakahara
On Fri, 12 Nov 2004 01:10:06 +0900 Koji Nakahara [EMAIL PROTECTED] wrote: On Thu, 11 Nov 2004 10:49:13 +0100 (MEZ) Henning Thielemann [EMAIL PROTECTED] wrote: The computation sample rate should be propagated through the network as follows: If in a component of equal sample rate some

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Judah Jacobson
On Thu, 11 Nov 2004 12:27:17 +, Ben Rudiak-Gould [EMAIL PROTECTED] wrote: On the other hand, these are perfectly safe: once' :: IO a - IO (IO a) oncePerString :: String - IO a - IO a oncePerType :: Typeable a = IO a - IO a once' seems virtually useless unless you have

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Keean Schupke
I think you are right... The only safe operation I can see for a one-time init is type IO (). All results have to be returned via side effects. Hence with my named-MVar proposal the first execution of the init function initialises certain named-MVars, and subsequent executions do nothing at all.

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Judah Jacobson
On Thu, 11 Nov 2004 20:14:24 +, Keean Schupke [EMAIL PROTECTED] wrote: I think you are right... The only safe operation I can see for a one-time init is type IO (). All results have to be returned via side effects. Hence with my named-MVar proposal the first execution of the init function

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-11 Thread Keean Schupke
Actually, I don't see anything wrong on the face of it with oncePerType :: Typeable a = IO a - IO a since the only instances of Typeable are monomorphic. Indeed, the implementation seems pretty straightforward: store the results of already-run computations as Dynamic values in a global

[Haskell-cafe] Re: [Haskell] Re: About Random Integer without IO

2004-11-11 Thread Clive Brettingham-Moore
This really really should have moved to haskell-cafe as previously suggested (sending to both with this in mind); apologies for being a little confising to haskell-cafe This isn't a language design issue, it is a FAQ, or at best a nebulous conceptual debate (speaking of which, has anyone got