Using Haskell Stack makes it easy to modify a dependency of your project. Use git clone
to unpack the dependency into a subdirectory of your project dir. Then add a line to the packages:
section of stack.yaml
referencing the newly-created directory.
When it comes time to share your project, you need to make the modified dependency available as well. If it's not already, set up your dependency repo's upstream to some publicly-accessible URL, for example like so:
git remote add origin d@cryptonomic.net:public_git/project.git
git branch master --set-upstream-to origin
If you are using stock tools, you then need to ssh to the remote side and use git init --bare
to create the target repo, after which you can send the source repo over with git push
.
Alternatively, if you have the git-push-clone
script installed, you can skip the git init
step and just run git push-clone
.
Or, if the URL is a samizdat-style public_git dir, like in the cryptonomic.net
example above, you can just git push
.
yamlremote
toolFinally, you need to edit stack.yaml
to point to the global repository instead of the local directory. It is a little tedious to do that edit. You have to put in the sha1 hash of the commit, and update it every time you change the dependency. You have to figure out the remote URL. And you have to remember the overall syntax.
Here is a little tool that automatically converts the local repository to the remote one.
(It depends on the local repository being set up to track the remote branch that you want to share.)
It's intended to be used inside the editor. Select lines from your packages:
section with V
, and pipe them through yamlremote
using the vim command !yamlremote
. It will look like this: