I was looking at the Applicative
class within Haskell libraries and stumbled across Alternative
.
What is this class good for? A google sear
It's commonly used with parser combinators. For example, if space
is a parser combinator that matches a single whitespace character, many space
would be one that would match consecutive whitespace.
I can agree that it's slightly out of place in Control.Applicative
, though.
Sometimes the <|>
operator is quite useful:
foldl1 (<|>) [Nothing, Just 5, Just 3]
-- Just 5