DEV Community


Using github repos as Haskell dependency

Ken Aguilar
* Functional Programmer * All my posts are cross post from my site
Updated on ・1 min read

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

  type: git
  location: git://[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 ^>=
                , 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.

Discussion (1)

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

Forem Open with the Forem app