maciej-bendkowski / boltzmann-brain

Analytic sampler compiler for combinatorial systems
BSD 3-Clause "New" or "Revised" License
30 stars 5 forks source link

Compilation error with some symbol names #28

Open Kerl13 opened 2 years ago

Kerl13 commented 2 years ago

Compilation breaks if the entry point of my grammar is named S, it seems to clash with some other type with the same identifier in the generated code.

Minimal working example:

@module   Sampler
@size     1000
@generate S

S = Leaf
  | Node S S.

The error:

/tmp/tmpap7caq9k/src/Sampler.hs:20:15: error:
    Ambiguous occurrence ‘S’
    It could refer to either ‘GHC.Generics.S’,
                             imported from ‘GHC.Generics’ at src/Sampler.hs:9:1-19
                          or ‘Sampler.S’, defined at src/Sampler.hs:19:1
   |
20 |        | Node S S

My setup:

$ python -c 'import paganini; print(paganini.__version__)'
1.4.0
$ git log --oneline | head -n 1
a85fcc3 Update link
Kerl13 commented 2 years ago

Do you think it's possible to scope things so as to prevent that from ever happening? (I'm not very familiar with Haskell)

maciej-bendkowski commented 2 years ago

We should explicitly list what we need to import, so to avoid unnecessary clashes.