Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Keean Schupke
Jorge Adriano Aires wrote: On the list monad, I think of the mplus operation as the "union" two non-deterministic states. Mzero is the state that works as the identity (which is when you have no possible state at all). Okay... thats a definition of a monoid. What would happen if this was the

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Jorge Adriano Aires <[EMAIL PROTECTED]> wrote: > How would we implement the first kind in the Maybe instance of MonadPlus? We wouldn't, they'd be in separate classes. -- Ashley Yakeley, Seattle WA ___ Haskell-Cafe mai

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Aaron Denney
On 2005-01-23, Keean Schupke <[EMAIL PROTECTED]> wrote: > Is there only on correct definition of a monad/monoid on lists - or does > anything that satisfies the monad laws count? I got the impression you > could define anthing you liked for mzero and mplus - providing the laws > are upheld? You

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Keean Schupke
Aaron Denney wrote: You can, but the "other one" turns it into a copy of the Maybe Monad, so the current one is more useful. So what does this mean in terms of Ashley's question: But only some instances (such as []) satisfy this: (mplus a b) >>= c = mplus (a >>= c) (b >>=

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Jorge Adriano Aires <[EMAIL PROTECTED]> wrote: > One common example is using MonadPlus for some backtracking algorithm, then > instantiatiating it to Maybe or List instance depending on wether you just > want one solution or all of them. Backtracking only works

[Haskell-cafe] Re: Hugs for Zaurus

2005-01-23 Thread John Goerzen
On 2005-01-23, John Goerzen <[EMAIL PROTECTED]> wrote: > On Sat, Jan 22, 2005 at 01:52:58PM -0800, Fritz Ruehr wrote: > I can give you some idea, at least. When started from scratch, hugs > consumes about 4MB RAM on my system. I should follow up and mention that the busybox ps doesn't split out s

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
> I got the impression you > could define anthing you liked for mzero and mplus - providing the laws > are upheld? I agree that a law-based approach is the correct one. The "Monad laws" are well known, equivalent laws for Functor don't seem to be talked about so much but I doubt there'd be any

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Keean Schupke
Ashley Yakeley wrote: I think it would be helpful if all these classes came with their laws prominently attached in their Haddock documentation or wherever. The trouble with MonadPlus is that the precise set of associated laws is either unspecified or not the most useful (I assume there's a paper

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Marcin 'Qrczak' Kowalczyk
Ashley Yakeley <[EMAIL PROTECTED]> writes: > But only some instances (such as []) satisfy this: > > (mplus a b) >>= c = mplus (a >>= c) (b >>= c) > > Other instances (IO, Maybe) satisfy this: > > mplus (return a) b = return a > > I think mplus should be separated into two functions. This woul

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Jorge Adriano Aires
> >>What would happen if this was the definition? > >> > >>instance MonadPlus [] where > >> mzero = [] > >> mplus a b > >> > >> | a == [] = b > >> | otherwise = a > > Isn't the above a monoid as well? Yes. > Is there only on correct definition of a monad/monoid on lists - or does

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Jorge Adriano Aires
> > One common example is using MonadPlus for some backtracking algorithm, > > then instantiatiating it to Maybe or List instance depending on wether > > you just want one solution or all of them. > > Backtracking only works with the first kind, even if you're only > interested in the first soluti

[Haskell-cafe] Randomly balanced binary trees

2005-01-23 Thread Dominic Fox
Some more code that might be of interest to someone. Based on a suggestion by Alistair Turnbull, I've written a Haskell implementation of a randomly balanced binary tree. This merges tree updates with a stream of random numbers, which are used to shuffle the order of nodes in the tree so that it

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Jorge Adriano Aires
> I think it would be helpful if all these classes came with their laws > prominently attached in their Haddock documentation or wherever. Agree. > The trouble with MonadPlus is that the precise set of associated laws is > either unspecified or not the most useful (I assume there's a paper on >

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Daniel Fischer
Am Sonntag, 23. Januar 2005 13:21 schrieb Keean Schupke: > Ashley Yakeley wrote: > > I think it would be helpful if all these classes came with their laws > > > >prominently attached in their Haddock documentation or wherever. The Definitely! > >trouble with MonadPlus is that the precise set of a

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Daniel Fischer
Am Sonntag, 23. Januar 2005 15:58 schrieb Jorge Adriano Aires: > > I'm not arguing that definition would be "wrong". It is a monoid. This is > the instance for (): > > instance MonadPlus() where > mzero = () > mplus a b = () > Maybe I'm stupid, but: class Monad m => MonadPlus m where mzero

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Jorge Adriano Aires
> Am Sonntag, 23. Januar 2005 15:58 schrieb Jorge Adriano Aires: > > I'm not arguing that definition would be "wrong". It is a monoid. This is > > the instance for (): > > > > instance MonadPlus() where > > mzero = () > > mplus a b = () > > Maybe I'm stupid, but: > > class Monad m => MonadPlus

Re: [Haskell-cafe] File path programme

2005-01-23 Thread Marcin 'Qrczak' Kowalczyk
Isaac Jones <[EMAIL PROTECTED]> writes: > You might be interested in the new FilePath module that's in the > works. There's been a lot of work to make these functions portable. > > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/System/FilePath.hs splitFileExt "foo" = ("foo", ""

[Haskell-cafe] Re: File path programme

2005-01-23 Thread Aaron Denney
On 2005-01-23, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > What about splitFileExt "foo.bar."? ("foo", "bar.") or ("foo.bar.", "")? The latter makes more sense to me, as an extension of the first case you give and splitting "foo.tar.gz" to ("foo.tar", "gz"). -- Aaron Denney -><-

Re: [Haskell-cafe] Re: File path programme

2005-01-23 Thread Marcin 'Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: >> What about splitFileExt "foo.bar."? ("foo", "bar.") or ("foo.bar.", "")? > > The latter makes more sense to me, as an extension of the first case > you give and splitting "foo.tar.gz" to ("foo.tar", "gz"). It's not that obvious: both choices are compati

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > > I think mplus should be separated into two functions. > > This would prevent using mplus in a single parser which - depending on > the underlying monad used - backtracks or not. Exactly. -- Ashley Yakeley

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Jorge Adriano Aires <[EMAIL PROTECTED]> wrote: > I just checked the paper, > "A monadic Interpretation of Tatics", by Andrew Martin and Jeremy Gibbons > http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/tactics.pdf > > And in deed, these are the lis

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Daniel Fischer <[EMAIL PROTECTED]> wrote: > from an earlier message of Keean: > > 1. |mzero >>= f == mzero| > > 2. |m >>= (\x -> mzero) == mzero| > > 3. |mzero `mplus` m == m| > > 4. |m `mplus` mzero == m| > > What exactly does 2. mean in the IO-case? > a) the

[Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Aaron Denney
On 2005-01-23, Keean Schupke <[EMAIL PROTECTED]> wrote: > Aaron Denney wrote: > >>You can, but the "other one" turns it into a copy of the Maybe Monad, so >>the current one is more useful. >> >> > So what does this mean in terms of Ashley's question: > > But only some instances (such as [])

Re: [Haskell-cafe] weird behavior using HUnit

2005-01-23 Thread Frédéric Gobry
> lots of memory again. I've isolated the problem down. It seems that if I > declare my test suite with the line: > > testParseLog = HUnit.runTestTT (HUnit.TestList [_testUpdate]) > > then my code does not run in constant space anymore. Note that the > testParseLog is not actually used, but only