[Haskell-beginners] Ignoring the result of a monadic computation
jongleur0815 at gmx.de
Fri Nov 19 14:39:44 EST 2010
this was my first post and I'm thankful and really impressed how many qualified answers I got. I've been learning Haskell only for a short time but I'm really fascinated how mathematical and expressive a programming language can be (I usually code Java). Recently I read a blog post, with a function
map (length &&& head) . group
that was much shorter and more elegant than the corresponding Python code. That was the main reason for me to try to write my own code in a single line without any lambda expressions.
-------- Original-Nachricht --------
> Datum: Fri, 19 Nov 2010 07:56:02 +0100
> Von: "Tim Baumgartner" <jongleur0815 at gmx.de>
> An: beginners at haskell.org
> Betreff: [Haskell-beginners] Ignoring the result of a monadic computation
> while learning about monads, I had something like
> line <- getLine
> putStrLn line
> and I wondered if I could write it in one line, without naming of
> I finally came up with
> getLine >>= ignore something >>= putStrLn
> 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?
> GRATIS! Movie-FLAT mit über 300 Videos.
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
> Beginners mailing list
> Beginners at haskell.org
GRATIS! Movie-FLAT mit über 300 Videos.
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
More information about the Beginners