[Haskell-cafe] readMVar and the devils

2004-07-02 Thread Conor T McBride
Hi folks I'm having a play with Concurrent Haskell, and came across this in the library. readMVar :: MVar a -> IO a This is a combination of takeMVar and putMVar; ie. it takes the value from the MVar, puts it back, and also returns it. I was just wondering if I understand things correctly. Su

Re: [Haskell-cafe] readMVar and the devils

2004-07-02 Thread MR K P SCHUPKE
at a guess the magic take put is: block ( do a <- takeMVar x putMVar x a ) return a Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Newbie questions

2004-07-02 Thread Keith Wansbrough
> -- gaSolutionSpace :: [a] -> [a] > -- gaSolutionSpace [] = gaSolutionSpace createRandomPopulation -- recursive > base case > gaSolutionSpace x = x : gaSolutionSpace (evolvepopulation x) This isn't quite right - you don't want the *last* element to be the initial population, but the first. I t

RE: [Haskell-cafe] readMVar and the devils

2004-07-02 Thread Simon Marlow
On 02 July 2004 10:16, Conor T McBride wrote: > Hi folks > > I'm having a play with Concurrent Haskell, and came across this in the > library. > >readMVar :: MVar a -> IO a >This is a combination of takeMVar and putMVar; ie. it takes the >value from the MVar, puts it back, and also r

Re: [Haskell-cafe] Relating functors in Category Theory to Functor

2004-07-02 Thread Frank Atanassow
On Jun 29, 2004, at 6:46 PM, Iavor S. Diatchki wrote: In Haskell, natural transformations are polymorphic functions, tau :: f a -> g a. For example, maybeToList :: Maybe a -> [a]. actually i think this is a good approximation. not all polymorphic functions are natural transformations, but "simp

[Haskell-cafe] state in the continuation monad...

2004-07-02 Thread MR K P SCHUPKE
I am trying to model state in the continuation monad, such that each continuation recieves the current state as one of its arguments. The state must vary in type, which is why I am trying to use the continuation monad, but things don't seem to be going too well. To clarify... imagine the following

Re: [Haskell-cafe] readMVar and the devils

2004-07-02 Thread Andy Moran
> at a guess the magic take put is: > > block ( do > a <- takeMVar x > putMVar x a > ) > return a This doesn't prevent the race condition Conor mentioned. It only prevents the thread executing the above code from being interrupted by an asynchronous exception (i.e., Control-C, or another thread

Re: [Haskell-cafe] state in the continuation monad...

2004-07-02 Thread Ralf Laemmel
{-# OPTIONS -fglasgow-exts #-} {- Regarding Keean's posting ... I wonder whether perhaps a more basic step is to understand how type-changing monadic computations can be understood. By this I mean, that the effects model by the monad can change their type as part of the computation. Such a monad

Re: [Haskell-cafe] readMVar and the devils

2004-07-02 Thread Jan-Willem Maessen - Sun Labs East
Conor T McBride wrote: ... [questions about operation ordering with MVars] > I'm only asking, because I'm trying to cook up some kind of partial evaluator for programs which are being simultaneously edited by fiercely argumentative devils. Kind of `demonic laziness', where the computations decide w

Re: [Haskell-cafe] Relating functors in Category Theory to Functor

2004-07-02 Thread Iavor S. Diatchki
hello, i was thinking of higher-order functions, which i think complicate things (i might be wrong though :-) for example: fix :: (a -> a) -> a is ploymorphic, but is it a natural tranformation? i belive it is in fact a di-natural transformation. -iavor On Jun 29, 2004, at 6:46 PM, Iavor S. Diatchk

[Haskell-cafe] Haskore development

2004-07-02 Thread Henning Thielemann
The idea of using a general purpose programming language for making music as provided by Haskore is very attractive to me. Especially Haskell seems to be a good choice for this task, since the lazy evaluation in principle allows an immediate play back without the necessity to build the complete so

Re: [Haskell-cafe] Newbie questions

2004-07-02 Thread David Menendez
Crypt Master writes: >From what I can see, a key difficulty you're having is with the "evolvepopulation" function. You've given it the type a -> a, which pretty much requires it to be an identity function, because it's not allowed to make any assumptions about the values it takes. To make things