Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Haskell-cafe] How to know the build dependencies?

1 view
Skip to first unread message

Magicloud Magiclouds

unread,
Jun 13, 2009, 10:22:53 PM6/13/09
to haskell-cafe
Hi,
I am learning to use cabal for my code.
Just when I start, I met a question, is there an easy way to find
out what packages my code depends?

Thanks.
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gwern Branwen

unread,
Jun 13, 2009, 11:13:40 PM6/13/09
to Magicloud Magiclouds, haskell-cafe
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote:
> Hi,
> I am learning to use cabal for my code.
> Just when I start, I met a question, is there an easy way to find
> out what packages my code depends?
>
> Thanks.

Not really. The easiest way is to just build your code and add every
package Cabal complains about being hid into your build-depends.
(Usually this won't take more than a minute or 3 if you're toggling
between a terminal and an editor.)

- --
gwern
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEAREKAAYFAko0arEACgkQvpDo5Pfl1oJbNACfYNB+oScSsiwF3qwZMHzu3AjM
s24An3tcamliH1rJzZiNg1EqjTLLYzzo
=7Fgw
-----END PGP SIGNATURE-----

Deniz Dogan

unread,
Jun 14, 2009, 6:05:59 AM6/14/09
to Gwern Branwen, haskell-cafe
2009/6/14 Gwern Branwen <gwe...@gmail.com>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote:
>> Hi,
>> �I am learning to use cabal for my code.
>> �Just when I start, I met a question, is there an easy way to find
>> out what packages my code depends?
>>
>> Thanks.
>
> Not really. The easiest way is to just build your code and add every
> package Cabal complains about being hid into your build-depends.
> (Usually this won't take more than a minute or 3 if you're toggling
> between a terminal and an editor.)
>
> - --
> gwern

Someone really ought to write a tool for this...

--
Deniz Dogan

Claus Reinke

unread,
Jun 14, 2009, 6:25:05 AM6/14/09
to haskell-cafe
> I am learning to use cabal for my code.
> Just when I start, I met a question, is there an easy way to find
> out what packages my code depends?

If you've managed to get your code to compile,

ghc --show-iface Main.hi

is perhaps the easiest way (ghc --make and ghci will also report
package dependencies as they encounter them).

If you're looking for the package for a particular module, ghc-pkg
can help

ghc-pkg find-module Control.Concurrent
c:/ghc/ghc-6.10.3\package.conf:
base-3.0.3.1, base-4.1.0.0

ghc-pkg find-module Data.Map
c:/ghc/ghc-6.10.3\package.conf:
containers-0.2.0.1

If you're looking for a minimal set of imports before hunting for
packages, ghc's -ddump-minimal-imports will create a file Main.imports
with that information. You could then run ghc-pkg find-module over
that list.

These are not the only options. Perhaps the available tools
need to be advertized more?-)

Claus

Krzysztof Skrzętnicki

unread,
Jun 14, 2009, 8:41:23 AM6/14/09
to Magicloud Magiclouds, haskell-cafe
If your module compiles, you can get the info by passing '-ddump-types':

TYPE SIGNATURES
numbersTests :: Test
testAverage :: Test
testBindInt :: Test
TYPE CONSTRUCTORS
Dependent modules: [(MoresmauJP.Util.Numbers, False)]
Dependent packages: [HUnit-1.2.0.3, base, ghc-prim, integer]

It is, however, available only after your code has successfully compiled.

Best regards

Krzysztof Skrzętnicki

Gwern Branwen

unread,
Jun 14, 2009, 10:13:08 AM6/14/09
to Deniz Dogan, haskell-cafe
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On Sun, Jun 14, 2009 at 6:05 AM, Deniz Dogan wrote:
> Someone really ought to write a tool for this...

Well, it's an issue of time. Just building and adding the deps is fast
and straightforward. A tool I'd need to know about, have installed,
and remember to use in the middle of a Cabalizing session. The people
who most need such a tool are those who are least likely to use it.
And given the overhead, it's unclear that it would actually save time.
Sometimes, somethings aren't worth automating.

Now, if someone were to create such a tool and integrate it into
'mkcabal', then it might make sense. You could create the basic .cabal
with the build-depends filled in. But as a separate tool it's too
small a task to handle. Even memorizing the -show-iface or
- -ddump-types options may not be worthwhile - how often does one create
Cabal packages from scratch?

- --
gwern
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEAREKAAYFAko1BWEACgkQvpDo5Pfl1oKvigCeO7ABRVr/9+kT62dIFpo0k5+f
y/AAnR6wLaDpX5/lZPqQzB/Wb4kuj8i9
=L2iA
-----END PGP SIGNATURE-----

Deniz Dogan

unread,
Jun 14, 2009, 10:14:43 AM6/14/09
to Gwern Branwen, haskell-cafe
2009/6/14 Gwern Branwen <gwe...@gmail.com>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> On Sun, Jun 14, 2009 at 6:05 AM, Deniz Dogan wrote:
>> Someone really ought to write a tool for this...
>
> Well, it's an issue of time. Just building and adding the deps is fast
> and straightforward. A tool I'd need to know about, have installed,
> and remember to use in the middle of a Cabalizing session. The people
> who most need such a tool are those who are least likely to use it.
> And given the overhead, it's unclear that it would actually save time.
> Sometimes, somethings aren't worth automating.
>
> Now, if someone were to create such a tool and integrate it into
> 'mkcabal', then it might make sense. You could create the basic .cabal
> with the build-depends filled in. But as a separate tool it's too
> small a task to handle. Even memorizing the -show-iface or
> - -ddump-types options may not be worthwhile - how often does one create
> Cabal packages from scratch?

I'm sorry, I was not aware of those flags when I wrote my message. You're right.

--
Deniz Dogan

Toby Miller

unread,
Jun 14, 2009, 12:49:57 PM6/14/09
to haskel...@haskell.org

On Jun 14, 2009, at 6:05 AM, Deniz Dogan wrote:

> 2009/6/14 Gwern Branwen <gwe...@gmail.com>:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA512
>>
>> On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote:
>>> Hi,
>>> I am learning to use cabal for my code.
>>> Just when I start, I met a question, is there an easy way to find
>>> out what packages my code depends?
>>>
>>> Thanks.
>>
>> Not really. The easiest way is to just build your code and add every
>> package Cabal complains about being hid into your build-depends.
>> (Usually this won't take more than a minute or 3 if you're toggling
>> between a terminal and an editor.)
>>
>> - --
>> gwern
>
> Someone really ought to write a tool for this...


Visualising the Haskell Universe � Control.Monad.Writer

0 new messages