Skip to content

Both xml PrettyPrinters not compiling with Haskell-Gadt backend #170

@pascalh

Description

@pascalh

I wanted to use the Gadt backend together with a Xml-PrettyPrinter, but I got the following error:

cat Calc.cf ; bnfc --haskell-gadt --xml -m Calc.cf ; make

-- file Calc.bnfc
EAdd.   Exp ::= Exp "+" Exp1    ;
ESub.   Exp ::= Exp "-" Exp1    ;
EMul.   Exp1    ::= Exp1    "*" Exp2    ;
EDiv.   Exp1    ::= Exp1    "/" Exp2    ;
EInt.   Exp2    ::= Integer ;
coercions   Exp 2   ;

8 rules accepted

   (Use Alex 3.0 to compile.)
   (Tested with Happy 1.15)
writing new file ./AbsCalc.hs
writing new file ./ComposOp.hs
writing new file ./LexCalc.x
writing new file ./ParCalc.y
writing new file ./SkelCalc.hs
writing new file ./PrintCalc.hs
writing new file ./TestCalc.hs
writing new file ./ErrM.hs
writing new file ./Makefile
writing new file ./Calc.dtd
writing new file ./XMLCalc.hs
happy -gca ParCalc.y
alex -g LexCalc.x
ghc --make TestCalc.hs -o TestCalc
[1 of 9] Compiling ComposOp         ( ComposOp.hs, ComposOp.o )
[2 of 9] Compiling ErrM             ( ErrM.hs, ErrM.o )
[3 of 9] Compiling AbsCalc          ( AbsCalc.hs, AbsCalc.o )
[4 of 9] Compiling XMLCalc          ( XMLCalc.hs, XMLCalc.o )

XMLCalc.hs:43:10:
    Illegal instance declaration for ‘XPrint Exp’
      (All instance types must be of the form (T t1 ... tn)
       where T is not a synonym.
       Use TypeSynonymInstances if you want to disable this.)
    In the instance declaration for ‘XPrint Exp’
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

It is actually the same error when using the other xml encoding --xmlt.

I have already solved this issue, but I wanted to report it here for documentation and to enable referencing it in a regression test.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions