Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell - What is Control.Applicative.Alternative good for?

I was looking at the Applicative class within Haskell libraries and stumbled across Alternative.

What is this class good for? A google search did not reveal anything particularly insightful. And it seems to be completely out of place, bundled as it is with the Applicative package.

Could someone please post a possible scenario where you would use this class?

like image 572
Anupam Jain Avatar asked Aug 26 '11 11:08

Anupam Jain


1 Answers

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.

like image 77
hammar Avatar answered Sep 23 '22 01:09

hammar