DEV Community

Ken Aguilar
Ken Aguilar

Posted on • Edited on

Using github repos as Haskell dependency

I'm fairly new to haskell especially when it comes to packaging libraries.
I was having a hard time finding how to include github repositories in the [name of your project].cabal file of my project. I've been to cabal user guide and didn't find it there, at least not at first. Good thing @samderbyshire saw my tweet and answered my question.

First thing to do is to create a cabal.project file because this file doesn't get generated when you do cabal init, then include the following

source-repository-package
  type: git
  location: git://github.com/[repo owner]/[the repo i want to include as dependency].git

packages: ./[name of your project].cabal

Then in the your [name of your project].cabal file include the repository under the build-depends section

build-depends:    base ^>= 4.11.1.0
                , the-repo-you-want-to-include

The reason I wanted to do this was because I want to use the library I've written in one of my project without the hassle of publishing it to stackage or hackage.

Top comments (3)

Collapse
 
jvanbruegge profile image
Jan van Brügge

Just as a side note, when you are using stack, you can add git repos in your stack.yaml under extraDeps

Collapse
 
glebec profile image
Gabriel Lebec

Indeed; here is the location for the relevant docs, at least as of the date/time of this post.

Collapse
 
akbiggs profile image
Alexander Biggs

This should now use https://github.com instead of git://github.com. See cabal.readthedocs.io/en/latest/cab....