How could I change the hie.yaml, so that the common ./src directory is loaded as part of the exe, bench and test components, not only one of them? The second example makes hls ‘hide’ src to the other components. I thought this might be solved through a multi-cradle, but I have not clear how would I do that…
Is it even possible? I’m not eager to make a lib component for src, this gives faster feedback…
HLS doesn’t work well with multiple components sharing the same source dirs. What exactly do you mean with faster feedback? A lib component seems like a good option to me.
I mean that if I change, add or do anything with the library (without compiling it/restarting), and then go back to another other component, I don’t get any feedback. For example, adding func :: IO () to a module in the lib, and then importing it from the exe, it says that it doesn’t exists (having it already added to the exports):
However, if they are in the same component, changes in types, additions or eliminations of bindings in the imported module, show instant updates in the modules that they are imported to.
Yeah, this is one of my pet peeves too, but HLS using stack at the moment doesn’t notice dependency changes in non-library components. It’s reallllly hard to get it to notice, I’ve tried restarting VSCode, removing HLS build caches (the ones I could find) and I seem to still not have found the ones that I need to clear so that it passes the newly built dependencies to the test/exe/bench component.
I hope this’ll be fixed soon, but IIUC it’s stack repl that HLS uses that is the culprit and multi-component support for HLS+Stack is hanging until that gets fixed. I wish I had time to look at it myself, but in lieu of that, I wish the people working on Stack the best and look forward to anything they manage to fix
Isn’t your cradle wrong? I am understanding everything is under src, hence:
Also, notice there is a long standing issue with implicit-hie (which hls depends on) that fails to understand common stanzas for source-dirs. The issue is with cabal, I don’t know what happens with stack.
that’s an alternative for sure, i’ll think about it
No, the exe, bench and tests are in ./app, ./bench, and ./test. The code shared by all of them is in ./src, annd each component includes it in the source-dirs along with their other specific directory
I seems like you use src as source dir for other component instead of a library component you share. It should be a library component itself, and other components should depend on it.
-- I am not familiar with package.yaml, so double check the syntax
name: my-library
library
-- The libray name is the global name of the project
source-dirs: src
exectuables:
schedule-maker:
main: Main.hs
-- notice, src is not part of source, because you add it as a dependency
source-dirs: app
dependencies:
- my-library -- depends on the library component.
-- same with other executable compoments: tests and benchs
Yeah, that’s exactly what I don’t want to do, because if it is a library component, then most times, I have to restart hls and recompile because I don’t get instant feedback on the other components when something changes or is added to the library component… That’s the reason of my question, I tried to work around it to find a way where there is no library component, and the code in src/ is treated equally regardless of the component hls builds it with, so that I have no errors like those I described previously.
Anyways, it seems like what I want to do is not possible