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

2004-11-12 Thread Adrian Hey
On Friday 12 Nov 2004 3:20 pm, Keean Schupke wrote: > Adrian Hey wrote: > >The latter is probably true, in a strict technical sense. But I can't > >see a way to live without them and keep modularity. In any case, > >I don't think there's any reason to force programmers "wear the hair > >shirt" in t

Re: [Haskell-cafe] IO and State

2004-11-12 Thread Graham Klyne
At 10:35 10/11/04 -0800, Iavor S. Diatchki wrote: Hello, Concurrency in Haskell (technically GHC) is much like concurrency in other languages, in that you fork off threads and do stuff with them, etc. I think you are perhaps thinking of another kind of concurrency, where different redexes in a te

Re: [Haskell-cafe] IO and State

2004-11-12 Thread Iavor S. Diatchki
Hello, I see now what you meant, thanks for the explanation. I find the argument a bit disturbing, as it seems to imply that it is OK for the compiler to produce code without any context switches at all (after all none of the context swicthes are guaranteed to happen :-). I guess this is not true

Re: [Haskell-cafe] IO and State

2004-11-12 Thread Ben Rudiak-Gould
Iavor S. Diatchki wrote: Ben Rudiak-Gould wrote: I would say that the law holds in one direction and not the other. [...] How can things be equal the one way and not the other? Saying that two things are equal means (in this context) that either can be replaced by the other without changing the se

Re: [Haskell-cafe] Re: Currying confusion

2004-11-12 Thread Henning Thielemann
On Fri, 12 Nov 2004, John Goerzen wrote: > On 2004-11-12, Henning Thielemann <[EMAIL PROTECTED]> wrote: > > > > test3 :: Int -> (Int -> String) -> String > > > > ? > > Yes. > > > Then the implementation could be written as > > > > test3 x f = (show x ++) . f > > Tried that, but: Sorry, it mus

[Haskell-cafe] Re: Currying confusion

2004-11-12 Thread John Goerzen
On 2004-11-12, Henning Thielemann <[EMAIL PROTECTED]> wrote: > > On Fri, 12 Nov 2004, John Goerzen wrote: > >> I like the partial application feature (and used it in test1). So, I >> thought I could use that to my advantage in test3 and test4: >> >> test3 :: Int -> Int -> String >> test3 x f = (s

Re: [Haskell-cafe] Currying confusion

2004-11-12 Thread Henning Thielemann
On Fri, 12 Nov 2004, John Goerzen wrote: > I like the partial application feature (and used it in test1). So, I > thought I could use that to my advantage in test3 and test4: > > test3 :: Int -> Int -> String > test3 x f = (show x) ++ f You mean test3 :: Int -> (Int -> String) -> String ? T

[Haskell-cafe] Currying confusion

2004-11-12 Thread John Goerzen
I'm trying to do something -- I think it's called uncurrying. I've boiled up a little test case to show what I mean: test1 :: Int -> String test1 = show test2 :: Int -> Int -> String test2 x y = (show x) ++ (show y) OK, that works OK. Now let's say I want to provide a function that generates t

Re: [Haskell-cafe] IO and State

2004-11-12 Thread Iavor S. Diatchki
Hello, Ben Rudiak-Gould wrote: ... I would say that the law holds in one direction and not the other. It's safe to replace do x <- readSTRef r y <- readSTRef r with do x <- readSTRef r let y = x but not the other way around. How can things be equal the one way and not the other?

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

2004-11-12 Thread Judah Jacobson
On Fri, 12 Nov 2004 14:53:33 +, Adrian Hey <[EMAIL PROTECTED]> wrote: > On Thursday 11 Nov 2004 12:27 pm, Ben Rudiak-Gould wrote: > > > > On the other hand, these are perfectly safe: > > > > once' :: IO a -> IO (IO a) > > oncePerString :: String -> IO a -> IO a > > oncePerType :

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

2004-11-12 Thread Keean Schupke
This still has a problem. Lets say B implements some useful function that relies on A. Now also C implements some different useful function and also relies on A in its implementation. If there is only one A.a then using both B and C features in the same code will potentally break both B and C. The

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

2004-11-12 Thread Robert Dockins
Should values really depend on the order of includes? Even if you limit things to just newChan in top level '<-' you still don't know if A.a in B the same A.a in C. Perhaps it is enough to say A.a only exists once no matter how many times it is directly or indirectly imported? This strikes me

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

2004-11-12 Thread Keean Schupke
Adrian Hey wrote: The latter is probably true, in a strict technical sense. But I can't see a way to live without them and keep modularity. In any case, I don't think there's any reason to force programmers "wear the hair shirt" in this respect (other than dogma and superstitious fear about the evi

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

2004-11-12 Thread Adrian Hey
On Thursday 11 Nov 2004 12:27 pm, Ben Rudiak-Gould 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 top-level <-,

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

2004-11-12 Thread Keith Wansbrough
> So you say (and I do agree). But how can I *observe* that they are the same? Well, not with a single program run (obviously). But it is the case that for any program P and input sequence X (i.e., keys pressed): running P with X and running {foo = getChar; P'} with X (where P' is P with all

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

2004-11-12 Thread Georg Martius
Hi, Sorry, but I don't really get the point of the discussion so far. I think any computation should be done in pure functional style, that gets a random generator (seed) and passes it around. Your program starts in the IO monad anyway, so you have the choice of using newStdGen to get a new see

Re: [Haskell-cafe] Space efficiency problem

2004-11-12 Thread Ben Rudiak-Gould
Adrian Victor CRISCIU wrote: 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

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

2004-11-12 Thread Graham Klyne
At 16:07 11/11/04 +, Keith Wansbrough wrote: 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

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

2004-11-12 Thread Graham Klyne
At 00:10 12/11/04 +0100, karczma wrote: But it was MUCH more important to repeat the same sequence, e.g., after making fast some nice fractal sketch, I relaunched the program with bigger size/precision, but exploiting the same random sequence. I repeat, such is my philosophy. I agree. I've used si