Skip to content

Instantly share code, notes, and snippets.

@docteurklein
Last active May 7, 2020 10:15
Show Gist options
  • Save docteurklein/1be51fde1ca4015404dacf60a0f7ae00 to your computer and use it in GitHub Desktop.
Save docteurklein/1be51fde1ca4015404dacf60a0f7ae00 to your computer and use it in GitHub Desktop.
Work on a cabal dependency to contribute upstream

Work on a cabal dependency to contribute upstream

The haskell dependency management can be quite intimidating at first, but after a while you get used to it and realize it's very similar to rust's cargo (so many things are similar between rust and haskell, by the way).

One of the things I found particularly easy (once you know how) is to edit a dependency locally to work on it.

So imagine you have a cabal project with a dependency:

build-depends: base
             , aeson
             , hasql
             , hasql-pool

local path

If you want to work on hasql-pool for example, you just have to:

  • clone the repo in the (parent) directoy (you can find the git url on its hackage page)
git clone github.com/nikita-volkov/hasql-pool.git ..
  • edit your cabal.project (didn't work with cabal.project.local for me)
packages:
  ./
  ../hasql-pool/

And that's it!

You can now edit the files in ../hasql-pool and you'll directly see the results when running cabal repl or cabal build.

Fork the github repo

You could also decide to directly ask cabal to clone the repo and override the default one in your cabal.project (.local works too) one using:

source-repository-package
  type: git
  location: git://github.com/docteurklein/hasql-pool
  tag: e1c41a9
  -- subdir: sub/path/to/project

You'll need to push your changes and edit the tag field for every change, which makes it less useful than the local-path option.

Note: This also works if the package is not yet published on hackage.

It's all defined here but sometimes it's pretty hard to find what you want in the cabal documentation.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment