Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell: local variables in Printer may clash with printing functions #337

Closed
andreasabel opened this issue Jan 31, 2021 · 1 comment
Closed
Assignees
Labels
bug Haskell printer Concerning the generated printer
Milestone

Comments

@andreasabel
Copy link
Member

M. Main ::= Prt;
P. Prt  ::= Integer;

The generated printer does not compile:

[4 of 6] Compiling PrintTest        ( PrintTest.hs, PrintTest.o )

PrintTest.hs:110:43: error:
     Couldn't match expected type t0 -> AbsTest.Prt -> Doc
                  with actual type AbsTest.Prt
     The function prt is applied to two arguments,
      but its type AbsTest.Prt has none
      In the expression: prt 0 prt
      In the first argument of concatD, namely [prt 0 prt]
    |
110 |     AbsTest.M prt -> prPrec i 0 (concatD [prt 0 prt])
    |                                           ^^^^^^^^^

The problem is that the constructor arguments are lowercase versions of the argument types, e.g. Prt gives prt, which is the name of the printing function.

A solution is to prefix the local variables with an underscore.

@andreasabel andreasabel added bug Haskell printer Concerning the generated printer labels Jan 31, 2021
@andreasabel andreasabel added this to the 2.9.1 milestone Jan 31, 2021
@andreasabel andreasabel self-assigned this Jan 31, 2021
@andreasabel
Copy link
Member Author

A solution is to prefix the local variables with an underscore.

There was also a list of names to avoid, I added prt and doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Haskell printer Concerning the generated printer
Projects
None yet
Development

No branches or pull requests

1 participant