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

Questions about Haskell Aliases article #52

Open
tomjaguarpaw opened this issue Oct 2, 2020 · 5 comments
Open

Questions about Haskell Aliases article #52

tomjaguarpaw opened this issue Oct 2, 2020 · 5 comments
Labels

Comments

@tomjaguarpaw
Copy link
Contributor

Hi Veronika,

I have some questions about your excellent Haskell Aliases article:

  • alias cdoc="cabal haddock --enable-documentation"

    What happens if you don't use --enable-documentation here? It seems strange to me that Haddock has this option because I thought its sole purpose was to build documentation!

  • I use build + cp the executable

    How do you get the path of the built executable so you can cp it? The trick I know is cabal exec --verbose=0 --offline sh -- -c 'which <binary name>', but that's rather messy.

  • I personally don't experience any issues with the GHC environment files

    It would be interesting to know what problems, if any, others experience with GHC environment files. I'd be quite happy to turn on this option but I don't know what problems it might cause!

  • As I do not own a powerful laptop, sometimes it is too hard for it to build such projects so that it freezes

    I have a similar problem. My laptop has 4GB of RAM and regularly becomes sluggish due to builds or even incapacitated by swapping. I like to do the following to limit the time, memory and IO resources that builds can consume.

    MEM=$[1000 * 1000]; ulimit -d $MEM; ulimit -m $MEM; ulimit -v $MEM
    ionice -c idle nice -n 19 cabal build
    
  • these are completely reasonable use-cases for installation

    Both of these are cases of installing executables rather than libraries. Would it be more precise to say never cabal install libraries and only cabal install executables?

@vrom911
Copy link
Owner

vrom911 commented Oct 14, 2020

Sorry for a delayed response 😞

alias cdoc="cabal haddock --enable-documentation"

Yeah, I would think so too. But here the same story as with cabal test --please-test. It may work on some projects, but could fail on others due to the design of Cabal.
Also, in here, --enable-documentation builds the haddock documentation for dependencies as well, which the default won't do. That means that if you want to see full local documentation as it would have been on Hackage, it is better to use this option 🙂

How do you get the path of the built executable so you can cp it?

I agree that output is not completely friendly and contain a lot of links to different stanzas if you build the whole project.
I usually use cbuild with the executable name, so the last link is always what I need, e.g. cbuild my-project-exe.

It would be interesting to know what problems, if any, others experience with GHC environment files.

There were hot discussions on this topic, as this option was enabled by default when it was just introduced. As I understand, Nix users had the most struggles with this, while for others, the env files were helpful for "capturing" environment. This is the relevant discussion that caused this feature to be disabled by default: haskell/cabal#4542

I like to do the following to limit the time, memory and IO resources that builds can consume.

Nice one! Thanks for sharing 🤗

Both of these are cases of installing executables rather than libraries. Would it be more precise to say never cabal install libraries and only cabal install executables?

Yes, this is more explicit wording of my thought!

@georgefst
Copy link

I use build + cp the executable

You hinted in the blog at "some concerns" around using install instead. Do you know what the difference between installing and copying the result of build actually is? I've never been able to get an answer from anyone on this. For one thing, I think install triggers a rebuild of all dependencies, implying it's using different default flags to build...

@tomjaguarpaw
Copy link
Contributor Author

Do you know what the difference between installing and copying the result of build actually is?

One difference is that install is an out-of-tree build. It copies all the source files to some temporary location and builds there. (One unfortunate consequence is that I can't use TH to grab the git commit id!).

@tomjaguarpaw
Copy link
Contributor Author

the last link is always what I need, e.g. cbuild my-project-exe

Ah, I see. Do you mean that you look at the last line of the output where it tells you what file it is linking and then manually type in a cp command? I was hoping to find something programmatic.cabal exec --verbose=0 --offline sh -- -c 'which <binary name>' is the best programmatic way I have found but it's not great.

@vrom911
Copy link
Owner

vrom911 commented Oct 17, 2020

@tomjaguarpaw , yes, that is right!
I also would like to have something universal (and be able to use that at CI as well), but the solution that you suggest is not working on Windows, so it is not universal, unfortunately. I would prefer to have something out-of-the-box.
In the yet unreleased cabal 3.4 there is going to be list-bin command, that should help with that 🙂

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

No branches or pull requests

3 participants