
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
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
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".