RefactoringTools / HaRe

The Haskell Refactoring Tool
http://www.cs.kent.ac.uk/projects/refactor-fp/
Other
139 stars 32 forks source link

The HaRe library gets compiled twice #39

Closed Lysxia closed 7 years ago

Lysxia commented 7 years ago

The code for both the library and the executable is in the same directory. When compiling the executable, GHC does not look in the HaRe library it just built, but instead thinks that the code in src/ is part of the executable and compiles it again from scratch.

The compilation time of the package can be halved by moving the library or the executable in separate directories.

alanz commented 7 years ago

This time can also be halved by adding HaRe as a dependency to the exe.

The problem is that then HaRe cannot refactor itself, in the sense that if something is renamed in the main library code it will not be renamed in the tests at the same time.

The correct solution is to manage the calculation of the module graph to include the lib dependencies on all the assorted test and exe portions too.

Lysxia commented 7 years ago

This time can also be halved by adding HaRe as a dependency to the exe.

Isn't it already?

I hadn't thought about HaRe refactoring itself, what you say makes sense.

alanz commented 7 years ago

Hmm. Good point. Will have to check why it builds twice then. You can see the leftover commented dependencies for the tests for when it is not included as a library.

Lysxia commented 7 years ago

The reason is what I was trying to explain. To build the executable, which imports Language.Haskell.Refact.HaRe for instance, the compiler currently finds the file Language/Haskell/Refact/HaRe.hs under the same directory, and compiles it as an independent module not part of any library. On the other hand, if the executable were in a separate directory, it would find no file matching the module name it is looking for, then search in the visible libraries, and use the already compiled module (as it should).

alanz commented 7 years ago

ok, that makes sense.

On Sun, Oct 23, 2016 at 8:25 PM, Xia Li-yao notifications@github.com wrote:

The reason is what I was trying to explain. To build the executable, which imports Language.Haskell.Refact.HaRe for instance, the compiler currently finds the file Language/Haskell/Refact/HaRe.hs under the same directory, and compiles it as an independent module not part of any library. On the other hand, if the executable were in a separate directory, it would find no file matching the module name it is looking for, then search in the visible libraries, and use the already compiled module (as it should).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RefactoringTools/HaRe/issues/39#issuecomment-255604906, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZAB4QbFi1z3v2XOBrpAbagLF5pXhOKks5q26aDgaJpZM4KTii7 .