[Haskell-beginners] applicativeParsec.hs in Real World Haskell not compiling any more

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Oct 24 20:08:54 CEST 2012


On Mittwoch, 24. Oktober 2012, 19:40:02, Kees Bleijenberg wrote:
> A year ago I made a program. I took code from ApplicativeParsec.hs (capt. 16
> Real World Haskell).
> The program compiled and ran flawless. Now (after a year) I've upgraded to
> GHC version 7.0.4 (Windows) and I want to change something. But the

Hum, the current version is 7.6.1, you should consider installing that, 7.0.4 
is already rather oldish.

> unchanged version doesn't compile any more. I get warning:
> ApplicativeParsec.hs:17:10:
>     Illegal instance declaration for `Applicative (GenParser s a)'
>       (All instance types must be of the form (T t1 ... tn)
>        where T is not a synonym.
>        Use -XTypeSynonymInstances if you want to disable this.)
>     In the instance declaration for `Applicative (GenParser s a)'
> 
> ApplicativeParsec.hs:22:10:
>     Illegal instance declaration for `Alternative ....(same advice as above)

That's unfortunate, it should better have reported the below immediately.

But it's hard to make the compiler always give the best error message, so 
sometimes it gives a not-best.

> 
> So I added TypeSynonymInstances. Then I got:
> ApplicativeParsec.hs:22:10:
>     Overlapping instances for Applicative (GenParser s a)
>       arising from the superclasses of an instance declaration
>     Matching instances:
>       instance Applicative (Text.Parsec.Prim.ParsecT s u m)
>         -- Defined in Text.Parsec.Prim
>       instance Applicative (GenParser s a)
>         -- Defined at ApplicativeParsec.hs:17:10-36
>     In the instance declaration for `Alternative (GenParser s a)'
> 
> Then I added the OverlappingInstances directive. Same error and no
> compilation.
> 
> I wonder, is this the new GHC version? And what can I do about it?

It's a new parsec version, that now provides Applicative and Alternative 
instances out-of-the-box.

Just remove (delete or comment out) the instance declarations from your code.

You might get a few further compilation errors due to the changes in parsec, 
in that case, either the error messages help you fix it, or you can ask a new 
question.



More information about the Beginners mailing list