Re: [Haskell-cafe] Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-24 Thread jerzy . karczmarczuk
Lennart Augustsson: Shae Matijs Erisson wrote: Gregory Woodhouse <[EMAIL PROTECTED]> writes: My knowledge of functional programming is pretty much limited to Haskell, Scheme, and a smattering of Common Lisp. Are there languages other than Haskell that explicitly use monads? How about "not so

[Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-24 Thread Jim Apple
Shae Matijs Erisson wrote: Please respond with any language implementations I've missed. C++ http://www.cc.gatech.edu/~yannis/fc++/New1.5/lambda.html#monad Jim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/lis

Re: [Haskell-cafe] Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-24 Thread Lennart Augustsson
Shae Matijs Erisson wrote: Gregory Woodhouse <[EMAIL PROTECTED]> writes: My knowledge of functional programming is pretty much limited to Haskell, Scheme, and a smattering of Common Lisp. Are there languages other than Haskell that explicitly use monads? How about "not so explicitly"? Java ht

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
> Yes, but this StateT type application cannot be equal to the outer StateT type > application because this would result in an infinite type which Haskell > doesn't support. Example: > > StateT Int (StateT Int (StateT Int ...)) I see. I was trying to justify the lazy pattern in this mplus,

[Haskell-cafe] Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-24 Thread Shae Matijs Erisson
Gregory Woodhouse <[EMAIL PROTECTED]> writes: > My knowledge of functional programming is pretty much limited to Haskell, > Scheme, and a smattering of Common Lisp. Are there languages other than > Haskell that explicitly use monads? How about "not so explicitly"? Java http://www.ccs.neu.edu/home

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 21:52 schrieb Fan Wu: > > They cannot belong to the same monad. If s is the state type and m1' and > > m2' belong to the monad m then m1 and m2 belong to the monad StateT s m. > > I know it looks insane, I'm just trying to make a recursive case of > it: technically

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 21:37 schrieb Fan Wu: > [...] > This is a good example! But now I got the impression that pattern > match failure could happen in many places, so unless you want it to > fail loudly, you shall always use lazy pattern? Often you need pattern matching for distinguis

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
> They cannot belong to the same monad. If s is the state type and m1' and m2' > belong to the monad m then m1 and m2 belong to the monad StateT s m. I know it looks insane, I'm just trying to make a recursive case of it: technically it's still possible to have a StateT monad as the m in "StateT

Re: [Haskell-cafe] Other languages using monads?

2005-11-24 Thread Anders Höckersten
tor 2005-11-24 klockan 12:36 -0800 skrev Gregory Woodhouse: > My knowledge of functional programming is pretty much limited to > Haskell, Scheme, and a smattering of Common Lisp. Are there languages > other than Haskell that explicitly use monads? How about "not so > explicitly"? > > === > G

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
> They are useful not only in conjunction with infinite data structures. Take > my example state transformer "everything" and modify it so that it calls next > exactly two times, not infinitely many times, and outputs a pair of the > outputs of the two next invocations. > > Now let's assume you us

[Haskell-cafe] Other languages using monads?

2005-11-24 Thread Gregory Woodhouse
My knowledge of functional programming is pretty much limited to Haskell, Scheme, and a smattering of Common Lisp. Are there languages other than Haskell that explicitly use monads? How about "not so explicitly"? === Gregory Woodhouse [EMAIL PROTECTED] "The universe is not required to be i

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 21:19 schrieben Sie: > [...] > Here I want to correct a statement I made previously about: > > mplus m1 m2 = do ... > ~(a,s') <- lift (mplus m1' m2') > > In one of my emails to the thread I mentioned m1/m2 and m1'/m2' could > be dif

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
> But I think the reasons behind lazy pattern usage in the mplus > implementation are similar to those behind lazy pattern usage in the (>>=) > implementation. I find the explanation of "Lazy patterns are useful in contexts where infinite data structures are being defined recursively" is easier to

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 02:08 schrieb David Menendez: > Wolfgang Jeltsch writes: > > If we use an implementation of State *without lazy patterns*, it > > becomes something like this: > > > > \s -> case next s of > > (x,s') -> case everyting s' of > > (xs,s'')

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 01:49 schrieb Fan Wu: > Hi Wolfgang, > > Thanks for your response and examples! It helps a lot. > > From your example I can see "Lazy patterns are useful in contexts > where infinite data structures are being defined recursively" (quote > section 4.4 of Gentle Intro

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
Hi Wolfgang, I think you have a very good point. I'll buy it:-) > [There is a "do" missing before the lazy pattern, isn't it?] That's right! Thanks! Fan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/has

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Donnerstag, 24. November 2005 19:24 schrieb Fan Wu: > Hi Wolfgang, > > I don't know the history so maybe this is a new implementation of > State transformer. The Peek and poke functions are defined below > (copied from StateT.hs): > > instance Monad m => StateM (StateT s m) s where > peek

Re: [Haskell-cafe] Can anyone help me with partition numbers?

2005-11-24 Thread Cale Gibbard
First of all, read this :) http://haskell.org/hawiki/HomeworkHelp There doesn't appear to be a list for Haskell homework help in the list of mailing lists on haskell.org. If Jerzy knows more about one, he might be able to provide some information there. We'll be happy to help, but what have you a

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Fan Wu
Hi Wolfgang, I don't know the history so maybe this is a new implementation of State transformer. The Peek and poke functions are defined below (copied from StateT.hs): instance Monad m => StateM (StateT s m) s where peek = S (\s -> return (s,s)) poke s= S (\s1 -> ret

Re: [Haskell-cafe] Can anyone help me with partition numbers?

2005-11-24 Thread jerzy . karczmarczuk
whoals (sent by Nabble.com): Define a function parts which returns the list of distinct partitions of an integer n. Send this query perhaps to haskell-homeworks list? JK ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskel

[Haskell-cafe] Can anyone help me with partition numbers?

2005-11-24 Thread whoals (sent by Nabble.com)
A partition of a positive integer n is a representation of n as the sum of any number of positive integral parts. For example, there are 7 partitions of the number 5: 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 2+3 and 5. Define a function parts which returns the list of distinct partitions of an integ

RE: [Haskell-cafe] GHCi always optimizes?

2005-11-24 Thread Simon Marlow
On 22 November 2005 10:07, Dusan Kolar wrote: > My question is rather strange, maybe, even if simple: > Does ghci always translates with "-O" option set on? I didn't see anyone answer this specific question: the answer is "no", GHCi does not optimise. Optimisation cannot be used when interpret

RE: [Haskell-cafe] Re: Re[2]: Uses forkOS all CPUS on-board?

2005-11-24 Thread Simon Marlow
On 24 November 2005 01:35, Shae Matijs Erisson wrote: > Bulat Ziganshin <[EMAIL PROTECTED]> writes: > They work, even in a context switching regime, but I can't exploit all the CPU's on my computer. Always is "active" just one thread >> this will not help. multi-processing support

[Haskell-cafe] Re: Records vs HList

2005-11-24 Thread Keean Schupke
David Menendez wrote: Keean Schupke writes: HList can do O(log n) by the way, if the labels have order, you can implement a binary search tree of labels (Of course all the accessor functions would need to be rewritten). The idea of writing a type-level balanced binary search tree fil

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Mittwoch, 23. November 2005 20:42 schrieb Wolfgang Jeltsch: > Am Mittwoch, 23. November 2005 19:02 schrieb Fan Wu: > [...] > > But it is still not clear to me why lazy pattern is used here. Any ideas? > > Let's discuss this for State instead of StateT because this makes the > discussion easier.

Re: [Haskell-cafe] questions on lazy pattern, StateT monad

2005-11-24 Thread Wolfgang Jeltsch
Am Mittwoch, 23. November 2005 10:03 schrieb Fan Wu: > Hi Haskell gurus, > > I'm very puzzled on some code I saw in GHC Monad.StateT (which is > about state monad transformers) source and hope you can kindly give me > some insight into this. > > newtype StateT s m a = S (s -> m (a,s)) > > instance

Re: Re[2]: [Haskell-cafe] Uses forkOS all CPUS on-board?

2005-11-24 Thread Sebastian Sylvan
On 11/23/05, Bulat Ziganshin <[EMAIL PROTECTED]> wrote: > Hello Sebastian, > > Wednesday, November 23, 2005, 6:46:54 PM, you wrote: > > >> They work, even in a context switching regime, but I can't > >> exploit all the CPU's on my computer. Always is "active" > >> just one thread > > SS> Did you co