[Haskell-cafe] Best way to return Bool based on a successful pattern match?

Niklas Haas haskell at nand.wakku.to
Mon Jul 13 17:04:11 UTC 2015

I forgot to mention: The same can be extended to any monad with a good
‘fail’ definition, including many types of streams/parsers/whatever.

On Mon, 13 Jul 2015 19:03:02 +0200, Niklas Haas <haskell at nand.wakku.to> wrote:
> For this specific use case, you can also consider list comprehensions:
> [ x | x@(DataDefinition _) <- tlds ]
> I personally greatly prefer this over something like ‘filter’ + an ugly
> lambda, especially if you can use the list comprehension for the rest of
> your processing as well.
> On Mon, 13 Jul 2015 16:40:33 +0300, Nikolay Amiantov <ab at fmap.me> wrote:
> > A nice idea! It can be helpful in some cases, although usually I have
> > more complex patterns, for example "get all DataDefinitions from a list
> > of TopLevelDefinitions parsed from a .hs file" or "filter all KeyPresses
> > directed to a particular window from an Event stream".

More information about the Haskell-Cafe mailing list