
quoth Raphaƫl_Mongeau
This : pv a = [t | Just t <- pvc a] is strange, can we really do pattern matching inside list comprehension?
Sure, but from a list - I'm sorry, I meant "map pvc a", not "pvc a". pv a = [t | Just t <- map pvc a] where pvc A = Just 'A' pvc B = Just 'B' pvc _ = Nothing You know, the pattern match in the list comprehension is just what I wanted it for in the first place - remember ['A' | A <- s] ? That's OK, it just isn't useful because I can do this for only one target.
... and I think is more clear with a lambdaCase.
lambdaCase is a great thing, but given that it's hardly any different
pv l = catMaybes $ flip map l $ \case A -> Just 'A' B -> Just 'B' _ -> Nothing
from pv l = catMaybes $ map pvc l where pvc A = Just 'A' pvc B = Just 'B' pvc _ = Nothing ... in this case I don't think we're desperate enough to use a nonstandard extension. Donn