[Haskell-beginners] Ignoring the result of a monadic computation
Isaac Dupree
ml at isaac.cedarswampstudios.org
Sun Nov 21 13:48:11 EST 2010
On 11/19/10 10:21, Brent Yorgey wrote:
> On Fri, Nov 19, 2010 at 07:56:02AM +0100, Tim Baumgartner wrote:
>> using
>> ignore :: Monad m => m a -> b -> m b
>> ignore m a = m>> return a
>>
>> I'm satisfied with this solution but searching hoogle I didn't find
>> a standard function for my ignore. Am I missing something?
>
> Nope, there isn't such a function, but I like it. It reminds me of
> (*>) and (<*) from Control.Applicative.
In fact, it is equal to: flip (<$)
with <$ from Control.Applicative
and it only needs a Functor constraint, not Monad or Applicative.
http://haskell.org/ghc/docs/6.12.1/html/libraries/base/Control-Applicative.html
As y'all found out though, in this case an actual Applicative function
looked like a cleaner way to write the parser.
-Isaac
More information about the Beginners
mailing list