Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modules generated by UUAGC are not recognized #66

Closed
nponeccop opened this Issue · 5 comments

2 participants

@nponeccop

If I change https://github.com/nponeccop/HNC/blob/master/CPP/CompileTools.hs in editor I get the following in console tab:

CPP\CompileTools.hs:3:18:
    Could not find module `Bar'
    Perhaps you meant
      Var (needs flag -package ghc-7.4.1)
      Bag (needs flag -package ghc-7.4.1)
    Use -v to see a list of the files searched for.

EclipseFP cannot find module Bar which is generated from Bar.ag file and placed in various folders under dist/build, e.g.

dist\build\spl-hnc\spl-hnc-tmp

When the project is built by cabal those folders are added to ghc search path.

@JPMoresmau
Owner

Works for me, but then again it may be linked to having several executables, maybe I got lucky and had the proper executable selected. Make sure the project has been built. We use the same configuration options as cabal so it should work.

@nponeccop

I tracked the problem down. When you save an .ag file in Eclipse, EclipseFP runs UUAGC on it and puts .hs file to the same location as the .ag file. That's why you don't see the problem - because you have the .hs file generated. But if you delete that EclipseFP-generated .ag file, the problem arises:

  • delete the generated file
  • open a Haskell module which refers to the generated module
  • see the error message

The current behavior is wrong in many aspects:

  1. During normal building process by Cabal the generated files are put into different locations than EclipseFP puts them.
  2. Because of INCLUDE UUAG statement, many .ag files are not self-contained, so it's useless to try to run UUAG and GHC on them. Instead, all their parents should be enumerated and processed.
  3. The problems with multiple stanzas from #63 apply to .ag files as well.
@JPMoresmau
Owner

Well yes, if you delete the file another file depends on you get an error. this is not a problem. Then, when you build the project fully in EclipseFP, the way it's built is... by running "cabal build". So files are generated in the same place as they are with cabal, for the same reason that they are generated by cabal. Of course, when you edit a file, only that file gets build and loaded explicitly by GHC, so it needs the dependent file. that's what happens here. I got your project to build first, without trying to open a file, then when everything is built every file opens ok.

@nponeccop

Here is example from my project tree. Bar.ag has the following lines:

INCLUDE "AG/Nodes.ag"
INCLUDE "AG/Root.ag"
INCLUDE "AG/ExpressionBuilder.ag"
INCLUDE "AG/Qualifiers.ag"
INCLUDE "AG/TemplateArgs.ag"
INCLUDE "AG/TypeInference.ag"
INCLUDE "AG/DefinitionTypes.ag"

When Cabal builds the project, it invokes UUAGC compiler only once for Bar.ag. It textually includes 7 files into one big attribute grammar file and generates Bar.hs. cabal install does not run uuagc AG/Nodes.ag, but when I modify Node.ag EclipseFP does and it fails.

The correct behaviour is to get the list of all 'root' AG files from uuagc_options file and detect that AG/Nodes.ag is not a self-contained file but a part of Bar.ag/Bar.hs. So when I modify AG/Nodes.ag EclipseFP should not attempt to generate AG/Nodes.hs as it will fail, but it should re-generate Bar.hs instead.

I hope it is easier to understand the problem now.

@nponeccop

The problem disappears once I disable UUAG builder and rely on UUAG Cabal plugin. When I edit .ag files Bar.hs gets regenerated.

@nponeccop nponeccop closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.