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

Niklas Haas haskell at nand.wakku.to
Mon Jul 13 17:03:02 UTC 2015


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