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
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
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
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 >>=
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
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
> 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
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
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
> >>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
> > 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
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
> 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
>
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
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
> 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
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", ""
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
-><-
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
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
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
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
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 [])
> 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
24 matches
Mail list logo