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

How to use hie with custom-setup? #352

Open
hanjoosten opened this issue Jun 13, 2022 · 2 comments
Open

How to use hie with custom-setup? #352

hanjoosten opened this issue Jun 13, 2022 · 2 comments

Comments

@hanjoosten
Copy link

In a project I use, we have a build-type: Custom. During executing Setup.hs, a new .hs file is being generated.
Currently, I use the HSL setup with VSCode. That works great, except that before it is working, we have to manually build the project, so that the generated file can be found.
Is there support for projects with a Custom build-type?

Project I am talking about: https://github.com/AmpersandTarski/Ampersand
The actual setup is done using .devcontainer

@fendor
Copy link
Collaborator

fendor commented Jun 16, 2022

Hi!

This seems to happen because we run stack repl (and cabal repl) to find the compilation options of components, but the hook you supplied is only run upon build, irrc.
It seems to work with the following changes to Setup.hs:

main :: IO ()
main = defaultMainWithHooks (simpleUserHooks {buildHook = generateHook, replHook = generateHook1 })

generateHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()

-- | Generate Haskell modules that are required for the build and start the build
generateHook pd lbi uh bf = do
  generateBuildInfoModule (T.pack . prettyShow . pkgVersion . package $ pd)
  generateStaticFileModule
  buildHook simpleUserHooks pd lbi uh bf -- start the build

generateHook1 :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO ()

-- | Generate Haskell modules that are required for the build and start the build
generateHook1 pd lbi uh rf args = do
  generateBuildInfoModule (T.pack . prettyShow . pkgVersion . package $ pd)
  generateStaticFileModule
  replHook simpleUserHooks pd lbi uh rf args-- start the build

(I am not checking for validity, or how many times this will rebuild now stuff because it re-touches the generated file).

I also used a cabal cradle:

cradle:
  cabal:

but that was mainly because I am more comfortable understanding cabal shenanigans. However, it might be possible that this doesn't work for stack: commercialhaskell/stack#4315

We overall might have a better experience, if we make use of a proper cabal API as we are implementing here: haskell/cabal#7500. And then, we will have to teach stack about it.

hanjoosten added a commit to AmpersandTarski/Ampersand that referenced this issue Jun 17, 2022
@hanjoosten
Copy link
Author

Thank you very much for the suggestion. and also for the links. They give good insight in all the hard work being done for Haskell tooling. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants