Proper stack project config ? - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Vincent L

Hi,
I have a project which is built with stack and I like to improve the stack config. It's been a while I created it and I wasn't proficient in Haskell back then and tried to get something that just work. However I'd like to improve it now.

  • The first thing is that I usually modify the .cabalfile in my project, and now I have a C:\Users\vljno\OneDrive\Bureau\TDP7\RenduProcessor\UTILS.cabal was modified manually. Ignoring C:\Users\vljno\OneDrive\Bureau\TDP7\RenduProcessor\package.yaml in favor of the cabal file. message (and indeed the .yamlfile is ignored. Is there a way to "regenerate" the .cabalfile from the package so that I can edit the package.yamlfile instead ?
  • Is there a way to automatically run haddock when I do stack build/stack run ?
  • I'm using vscode and haskell LSP. In another project I saw that the LSP was able to detect if a function was not used because for instance, it's not exported and not used in the module being defined. In my current project this is not the case, no function are greyed out. Is there an option to enable this ?
TheMatten

Vincent L said:

Hi,
I have a project which is built with stack and I like to improve the stack config. It's been a while I created it and I wasn't proficient in Haskell back then and tried to get something that just work. However I'd like to improve it now.

  • The first thing is that I usually modify the .cabalfile in my project, and now I have a C:\Users\vljno\OneDrive\Bureau\TDP7\RenduProcessor\UTILS.cabal was modified manually. Ignoring C:\Users\vljno\OneDrive\Bureau\TDP7\RenduProcessor\package.yaml in favor of the cabal file. message (and indeed the .yamlfile is ignored. Is there a way to "regenerate" the .cabalfile from the package so that I can edit the package.yamlfile instead ?
  • Is there a way to automatically run haddock when I do stack build/stack run ?
  • I'm using vscode and haskell LSP. In another project I saw that the LSP was able to detect if a function was not used because for instance, it's not exported and not used in the module being defined. In my current project this is not the case, no function are greyed out. Is there an option to enable this ?
  • You can make it regenerate by removing current .cabal file
  • Try --haddockflag
  • Not sure about that one - maybe you can try running haskell-language-server in terminal and check whether it reports any errors/warnings
Vincent L

What's the syntax to add the --haddock flag to package.yaml ?

Vincent L

Removing Cabal and using stack yaml file is cleaning my project config, not bad

Georgi Lyubenov // googleson78

the stack.yaml file and the .cabal file do not do the same thing - the stack.yaml file is used to (roughly) specify which packages (and which versions of those packages) are available, and the *.cabal/package.yaml file is used to specify which dependencies your build system should use and other things related to the actual build of the project

Vincent L

yes but when I do stack build, it regenerates a UTILS.cabal file using the content from package.yaml

Georgi Lyubenov // googleson78

it's also expect that you will commit it and update it as your package.yaml changes, but not touch it directly

Vincent L

Yes, that was my initial mistake. Now I'm not modifying the cabal file directly.