Skip to content

Instantly share code, notes, and snippets.

Last active May 7, 2020
What would you like to do?
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 ..
  • edit your cabal.project (didn't work with cabal.project.local for me)

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:

  type: git
  location: git://
  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