Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically List Dependencies For a Project

Tags:

haskell

cabal

Given a Haskell project, is there a way to automatically calculate the entire list of dependencies? All the libraries it depends on as well as libraries that have been included but are not required.

like image 936
Vlad the Impala Avatar asked May 17 '12 02:05

Vlad the Impala


1 Answers

As I said in the comments, cabal-install already does this (I'm using cabal-install 0.14.0) by guessing the packages via module lookup (like GHCi). It doesn't have any real intelligence w.r.t. versions so it just sets the version to the match major version of what you have installed.

Below you can see me making a dummy package that imports Data.Vector and cabal-install infers I am using vector 0.9.*.

[tommd@mavlo blah]$ pwd
/tmp/blah
[tommd@mavlo blah]$ cat Data/Blah.hs 
module Data.Blah where

import Data.Vector
[tommd@mavlo blah]$ cabal init
Package name? [default: blah] 
...SNIP...
What does the package build:
   1) Library
   2) Executable
Your choice? 1
Include documentation on what each field means (y/n)? [default: n] 

Guessing dependencies...           <--- SEE, SEE! YAY!

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating blah.cabal...

You may want to edit the .cabal file and add a Description field.
[tommd@mavlo blah]$ cat blah.cabal 
-- Initial blah.cabal generated by cabal init.  For further documentation, 
-- see http://haskell.org/cabal/users-guide/

name:                blah
version:             0.1.0.0
synopsis:            Sisponys
-- description:         
-- license:             
license-file:        LICENSE
author:              Me
maintainer:          [email protected]
-- copyright:           
-- category:            
build-type:          Simple
cabal-version:       >=1.8

library
  exposed-modules:     Data.Blah
  -- other-modules:       
  build-depends:       base ==4.5.*, vector ==0.9.*    <-- SEE?? SEE! YIPPEE!!
like image 92
Thomas M. DuBuisson Avatar answered Oct 03 '22 07:10

Thomas M. DuBuisson