18

Using Control.Applicative is very useful with Parsec, but you need to always hide <|> and similar objects as they conflict with Parsec's own:

import Control.Applicative hiding ((<|>), many, optional)
import Text.Parsec.Combinator
import Text.Parsec

Alternatively, as Antal S-Z points out, you can hide the Parsec version. However, as far as I can tell, this seems like an unnecessary restriction.

Why did parsec not simply implement these operators from Applicative?

duplode
  • 33,731
  • 7
  • 79
  • 150
luispedro
  • 6,934
  • 4
  • 35
  • 45

1 Answers1

20

It's for historic reasons. The Parsec library predates the discovery of applicative functors and so it wasn't designed with them in mind. And I guess no one has taken the time to update Parsec to use Control.Applicative. There is no deep fundamental reason for not doing it.

svenningsson
  • 4,009
  • 1
  • 24
  • 32
  • 5
    I think there's also a problem with fixities, Parsec's `<|>` has `infixr 1` for example, while Alternative's has `infixl 4`. – David Apr 11 '13 at 08:08