On Sat, Jul 28, 2012 at 8:00 AM, Thiago Negri wrote:
> I'm solving this exercise:
>
> http://www.haskell.org/haskellwiki/All_About_Monads#Exercise_4:_Using_the_Monad_class_constraint
>
> I'm missing a function to transform a Maybe a into a MonadPlus m => m a.
> I did search on Hoogle with no luck
I'm solving this exercise:
http://www.haskell.org/haskellwiki/All_About_Monads#Exercise_4:_Using_the_Monad_class_constraint
I'm missing a function to transform a Maybe a into a MonadPlus m => m a.
I did search on Hoogle with no luck.
There is no standard definition for the "g" function I'm defini
On 10/29/11 11:02 PM, Gregory Crosswhite wrote:
Hey everyone,
What is the difference between MonadPlus and Alternative? In my mind, it would make sense for the
difference to be that the former provides "and" semantics (i.e., x `mplus` y means do both x
and y) whereas the latter provides "or"
On Sun, Oct 30, 2011 at 04:02, Gregory Crosswhite wrote:
> So is there any difference between the interpretation of MonadPlus and
> Alternative, or is the only difference between them that the former applies
> to Monad whereas the latter applies to Applicative?
>
Somewhat OT, but this led me to p
MonadPlus is `or` semantics, as is Alternative. It does, indeed, reflect
the Applicative/Monad difference.
On Sat, Oct 29, 2011 at 8:02 PM, Gregory Crosswhite
wrote:
> Hey everyone,
>
> What is the difference between MonadPlus and Alternative? In my mind, it
> would make sense for the difference
Hey everyone,
What is the difference between MonadPlus and Alternative? In my mind, it would
make sense for the difference to be that the former provides "and" semantics
(i.e., x `mplus` y means do both x and y) whereas the latter provides "or"
semantics (i.e., x <|> y means do x or y but not
On Sun, May 2, 2010 at 4:23 AM, Sebastian Fischer <
s...@informatik.uni-kiel.de> wrote:
> Ideally, every MonadPlus instance would also be an Alternative instance and
> every Alternative instance would be an instance of Monoid. You may find it
> unfortunate that there are so many operations for the
On Sat, May 1, 2010 at 7:11 PM, Sean Leather wrote:
> I want to generalize a set of functions from lists to some functor type. I
> require the following three operation types.
>
> f a
> a -> f a
> f a -> f a -> f a
>
Since f is a functor, FunctorPlus and Pointed together get you exactly th
would you have any suggestions on a name for such a class or names
for the methods?
I'm afraid I don't. I'd like
class Pointed t where
point :: a -> t a
class Monoid m where
id :: m
(.) :: m -> m -> m
constraint Monoidy t = (Pointed t, Monoid (t a))
(although
On Sun, May 2, 2010 at 12:07, Sebastian Fischer wrote:
>
> On May 2, 2010, at 11:10 AM, Sean Leather wrote:
>
> Or should I make my own class?
>>
>> Then, there obviously won't be any instances for existing types other than
>> your own (which might be a good or bad thing). You may want to do this
On May 2, 2010, at 11:10 AM, Sean Leather wrote:
Or should I make my own class?
Then, there obviously won't be any instances for existing types
other than your own (which might be a good or bad thing). You may
want to do this, if you don't want to require either (>>=) or (<*>),
which ma
On Sun, May 2, 2010 at 10:23, Sebastian Fischer wrote:
>
> On May 2, 2010, at 1:11 AM, Sean Leather wrote:
>
> I want to generalize a set of functions from lists to some functor type.
>> [...] Should I choose MonadPlus and use these? [...] Or should I choose
>> Alternative and use these? [...]
>>
On May 2, 2010, at 1:11 AM, Sean Leather wrote:
I want to generalize a set of functions from lists to some functor
type. [...] Should I choose MonadPlus and use these? [...] Or should
I choose Alternative and use these? [...]
There are some types that can be an instance of Alternative but
Check the laws that instances of MonadPlus and Alternative should comply
with to help you make your decision.
Cheers
Mark
Sean Leather wrote:
I want to generalize a set of functions from lists to some functor
type. I require the following three operation types.
f a
a -> f a
f a -> f a
I want to generalize a set of functions from lists to some functor type. I
require the following three operation types.
f a
a -> f a
f a -> f a -> f a
Should I choose MonadPlus and use these?
mzero
return
mplus
Or should I choose Alternative and use these?
empty
pure
(<|>)
O
Miguel said:
> Well, that's the whole point of mathematics, isn't it?
Abstraction is common to mathematics and computing. But in computing
the abstraction often follows lines that seem obvious. For example a
GUI library might have a Widget class and people can immediately
identify various regions
On 10 May 2008, at 00:43, Dan Piponi wrote:
Andrew asked,
...so it's a kind of choice operator? Run all actions until you get
to one
that succeeds and return the result from that?
The eternal bit of trickiness for Haskell is that type classes group
often together things that people don't
Andrew asked,
> ...so it's a kind of choice operator? Run all actions until you get to one
> that succeeds and return the result from that?
The eternal bit of trickiness for Haskell is that type classes group
often together things that people don't immediately see as similar -
monads probably bei
It sounds like the semantics of the MonadPlus methods are
under-specified. I recall once writing a newtype wrapper to treat the
same non-determinism monad with different mplus semantics, akin to cut
versus backtracking.
I think of MonadPlus as a less expressive version of msplit, from
Backtrack
On Fri, 2008-05-09 at 12:48 -0700, Bryan O'Sullivan wrote:
> Andrew Coppin wrote:
> > But here's a
> > question: what is the purpose of the MonadPlus class?
>
> It gives you a way of working with monads as monoids.
I find this description mostly useless. Monads form monoids without
being MonadP
Andrew Coppin wrote:
> ...so it's a kind of choice operator? Run all actions until you get to
> one that succeeds and return the result from that?
In the context of Parsec, yes. In the grander scheme of things, the
behaviour depends on whatever is appropriate for the particular monad
you're work
On Fri, 2008-05-09 at 12:47 -0700, David Roundy wrote:
> On Fri, May 09, 2008 at 08:39:38PM +0100, Andrew Coppin wrote:
> > OK, so I feel I understand monads fine. I regularly use Maybe, [] and
> > IO, and I've even constructed a few monads of my own. But here's a
> > question: what is the purpos
On May 9, 2008, at 15:56 , Andrew Coppin wrote:
Bryan O'Sullivan wrote:
Andrew Coppin wrote:
But here's a
question: what is the purpose of the MonadPlus class?
It gives you a way of working with monads as monoids. Consider a
Parsec
example:
metasyntactic = text "foo" `mplus` text "ba
Bryan O'Sullivan wrote:
Andrew Coppin wrote:
But here's a
question: what is the purpose of the MonadPlus class?
It gives you a way of working with monads as monoids. Consider a Parsec
example:
metasyntactic = text "foo" `mplus` text "bar" `mplus` text "baz"
You'll get back whichever
Andrew Coppin wrote:
> But here's a
> question: what is the purpose of the MonadPlus class?
It gives you a way of working with monads as monoids. Consider a Parsec
example:
metasyntactic = text "foo" `mplus` text "bar" `mplus` text "baz"
You'll get back whichever one matched, in left-to-right-o
On Fri, May 9, 2008 at 2:39 PM, Andrew Coppin <[EMAIL PROTECTED]>
wrote:
> [In a somewhat unrelated question... I saw some code the other day that
> used Either as if it were a monad. And yet, I don't see an instance given in
> the standard libraries - even though there should be one. I can see Fu
On Fri, May 09, 2008 at 08:39:38PM +0100, Andrew Coppin wrote:
> OK, so I feel I understand monads fine. I regularly use Maybe, [] and
> IO, and I've even constructed a few monads of my own. But here's a
> question: what is the purpose of the MonadPlus class?
>
> Clearly it defines a binary oper
OK, so I feel I understand monads fine. I regularly use Maybe, [] and
IO, and I've even constructed a few monads of my own. But here's a
question: what is the purpose of the MonadPlus class?
Clearly it defines a binary operation over monadic values and an
identity element for that operation. B
I'm using the following code in some of my projects:
newtype MonadPlusAsMonoid a = MPM { unMPM :: a }
instance MonadPlus m => Monoid (MonadPlusAsMonoid (m a)) where
mempty = MPM mzero
MPM l `mappend` MPM r = MPM (l `mplus` r)
Is there some sort of pitfall I'm not considering?
It seems
Am Mittwoch, 2. Februar 2005 14:48 schrieb David Roundy:
> On Wed, Feb 02, 2005 at 02:41:42PM +0100, Daniel Fischer wrote:
> > Probably you haven't imported 'Control.Monad.Error', where the instance
> > is defined. I did and all went well.
>
> Thanks, that did it. It's confusing that the instance
On Wed, Feb 02, 2005 at 02:41:42PM +0100, Daniel Fischer wrote:
> Probably you haven't imported 'Control.Monad.Error', where the instance is
> defined. I did and all went well.
Thanks, that did it. It's confusing that the instance is documented in
Control.Monad.
--
David Roundy
http://www.darcs
| David Roundy
| Sent: 02 February 2005 13:18
| To: haskell-cafe@haskell.org
| Subject: [Haskell-cafe] MonadPlus instance for IO
|
| I'm sure I'm doing something stupid, but somehow ghc isn't recognizing
the
| existance of a MonadPlus instance for IO:
|
| DarcsIO.lhs:48:
|
Am Mittwoch, 2. Februar 2005 14:17 schrieb David Roundy:
> I'm sure I'm doing something stupid, but somehow ghc isn't recognizing the
> existance of a MonadPlus instance for IO:
>
> DarcsIO.lhs:48:
> No instance for (MonadPlus IO)
> arising from use of `mplus' at DarcsIO.lhs:48
> In t
I'm sure I'm doing something stupid, but somehow ghc isn't recognizing the
existance of a MonadPlus instance for IO:
DarcsIO.lhs:48:
No instance for (MonadPlus IO)
arising from use of `mplus' at DarcsIO.lhs:48
In the definition of `foo':
foo = (fail "aaack") `mplus` (fail "fo
34 matches
Mail list logo