Re: [Haskell-cafe] Version constraints and cabal.config files

On 2015-03-25, at 12:16, Michael Snoyman
Trying to understand the problem: currently, with your approach, if the project depends on a library not in the LTS Haskell release, then the cabal-install dependency solver won't be able to find it. Instead, you'd like to be able to use the dependency solver to track down those extra dependencies. Is that correct?
If so, why not take a multi-pass approach: download the cabal.config from stackage.org (which creates an inclusive snapshot), and then use --dry-run, which will tell you all the packages to be used.
You’re correct. However, this will have to be `cabal install --dependencies-only --dry-run`, and not `cabal freeze --dry-run`, because `cabal freeze` always completely ignores any existing version constraints, whether local or global (https://github.com/haskell/cabal/issues/2265). I’m planning to switch away from `cabal freeze` soon, but it’s not going to be a drop-in replacement (https://github.com/mietek/halcyon/issues/52). This is a good moment to carefully consider the meaning of a per-application `cabal.config` file, and whether the `cabal freeze` flavour should be completely replaced by separate constraints files. Perhaps, as mentioned in the original `cabal freeze` proposal, we could also have separate constraints sets for different GHC versions. I’m hoping Cabal developers could chime in on the discussion. -- Miëtek https://mietek.io

The suggestion to use "cabal install --dependencies-only ..." instead
of "cabal freeze" in that issue is really nicely presented. "cabal
freeze" is close to the right thing, but it's just not as fully
featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build
plans computed for each package in Stackage. This is most of the work
my Nix tooling currently does, so it would be a big time saver.
Anthony
On Wed, Mar 25, 2015 at 8:26 AM, Miëtek Bak
On 2015-03-25, at 12:16, Michael Snoyman
wrote: Trying to understand the problem: currently, with your approach, if the project depends on a library not in the LTS Haskell release, then the cabal-install dependency solver won't be able to find it. Instead, you'd like to be able to use the dependency solver to track down those extra dependencies. Is that correct?
If so, why not take a multi-pass approach: download the cabal.config from stackage.org (which creates an inclusive snapshot), and then use --dry-run, which will tell you all the packages to be used.
You’re correct. However, this will have to be `cabal install --dependencies-only --dry-run`, and not `cabal freeze --dry-run`, because `cabal freeze` always completely ignores any existing version constraints, whether local or global (https://github.com/haskell/cabal/issues/2265).
I’m planning to switch away from `cabal freeze` soon, but it’s not going to be a drop-in replacement (https://github.com/mietek/halcyon/issues/52).
This is a good moment to carefully consider the meaning of a per-application `cabal.config` file, and whether the `cabal freeze` flavour should be completely replaced by separate constraints files. Perhaps, as mentioned in the original `cabal freeze` proposal, we could also have separate constraints sets for different GHC versions.
I’m hoping Cabal developers could chime in on the discussion.
-- Miëtek https://mietek.io

On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier. Michael

On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote: The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies. Anthony

On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote: The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or
something
else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described: https://gist.github.com/snoyberg/5b244331533fcb614523 You give it three arguments on the command line: * LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well If that's useful, I can package that up and put it on Hackage. Michael

On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote: The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going. Anthony

On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote: The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or
something
else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that: 1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially. Michael

On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote: The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable. Anthony

On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley
wrote:
The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or
something
else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now. https://gist.github.com/snoyberg/5b244331533fcb614523 One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix. If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there. Michael

On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman wrote: > > > On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley > wrote: >> >> The suggestion to use "cabal install --dependencies-only ..." instead >> of "cabal freeze" in that issue is really nicely presented. "cabal >> freeze" is close to the right thing, but it's just not as fully >> featured as "cabal install" (e.g. taking flags). >> >> As for Stackage, I think it would be helpful to cache the full build >> plans computed for each package in Stackage. This is most of the work >> my Nix tooling currently does, so it would be a big time saver. >> >> > > By "full build plans," do you mean the dist/setup-config file, or something > else? That file would be problematic since it's Cabal-library-version > specific IIRC. If you're looking for the full listing of deep dependencies > and versions, we can extract that from the .yaml file using the technique I > mentioned earlier. > > Michael Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB. Anthony

Is the idea that you'd be able to make a query such as:
GET
https://www.stackage.org/lts/1.14/build-plan?package=foo&package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"}
, ...
]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley <
acowley@seas.upenn.edu>
wrote:
The suggestion to use "cabal install --dependencies-only ..." instead of "cabal freeze" in that issue is really nicely presented. "cabal freeze" is close to the right thing, but it's just not as fully featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build plans computed for each package in Stackage. This is most of the work my Nix tooling currently does, so it would be a big time saver.
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

Yes, but a line-based format along the lines of: foo 1.2.3 bar-baz 0.1.00 Would be easier to parse with the usual shell tools. Anthony
On Mar 26, 2015, at 9:41 AM, Michael Snoyman
wrote: Is the idea that you'd be able to make a query such as:
GET https://www.stackage.org/lts/1.14/build-plan?package=foo&package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"} , ... ]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
wrote: On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: > On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: > > > >> On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley wrote: >> On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman wrote: >> > >> > >> > On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley >> > wrote: >> >> >> >> The suggestion to use "cabal install --dependencies-only ..." instead >> >> of "cabal freeze" in that issue is really nicely presented. "cabal >> >> freeze" is close to the right thing, but it's just not as fully >> >> featured as "cabal install" (e.g. taking flags). >> >> >> >> As for Stackage, I think it would be helpful to cache the full build >> >> plans computed for each package in Stackage. This is most of the work >> >> my Nix tooling currently does, so it would be a big time saver. >> >> >> >> >> > >> > By "full build plans," do you mean the dist/setup-config file, or something >> > else? That file would be problematic since it's Cabal-library-version >> > specific IIRC. If you're looking for the full listing of deep dependencies >> > and versions, we can extract that from the .yaml file using the technique I >> > mentioned earlier. >> > >> > Michael >> >> Yes, I meant the full listing of deep dependencies. > > I've put together a Gist with an executable that does what I described: > > https://gist.github.com/snoyberg/5b244331533fcb614523 > > You give it three arguments on the command line: > > * LTS version, e.g. 1.14 > * Name of package being checked > * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well > > If that's useful, I can package that up and put it on Hackage. > > Michael This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

And do you want the information on the core packages (e.g., base,
template-haskell, containers) as well, or should they be left out?
On Thu, Mar 26, 2015 at 4:48 PM Anthony Cowley
Yes, but a line-based format along the lines of:
foo 1.2.3 bar-baz 0.1.00
Would be easier to parse with the usual shell tools.
Anthony
On Mar 26, 2015, at 9:41 AM, Michael Snoyman
wrote: Is the idea that you'd be able to make a query such as:
GET https://www.stackage.org/lts/1.14/build-plan?package=foo&package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"} , ... ]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
wrote: On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley <
acowley@seas.upenn.edu>
wrote: > > The suggestion to use "cabal install --dependencies-only ..." instead > of "cabal freeze" in that issue is really nicely presented. "cabal > freeze" is close to the right thing, but it's just not as fully > featured as "cabal install" (e.g. taking flags). > > As for Stackage, I think it would be helpful to cache the full build > plans computed for each package in Stackage. This is most of the work > my Nix tooling currently does, so it would be a big time saver. > >
By "full build plans," do you mean the dist/setup-config file, or something else? That file would be problematic since it's Cabal-library-version specific IIRC. If you're looking for the full listing of deep dependencies and versions, we can extract that from the .yaml file using the technique I mentioned earlier.
Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

This is a touch subtle. base can be left out, but other packages that ship with ghc and are usually found in the global package db should be included as they can be upgraded. This has knock on effects where a new version of the unix package means we have to rebuild the directory package with that updated dependency, for example. This is something I already handle, so I'd be happy to have everything included in the provided build plan. I'd need to think more about whether or not some packages can safely be totally left out, but I'm on the road at the moment and not terribly capable of thought. Anthony
On Mar 26, 2015, at 10:50 AM, Michael Snoyman
wrote: And do you want the information on the core packages (e.g., base, template-haskell, containers) as well, or should they be left out?
On Thu, Mar 26, 2015 at 4:48 PM Anthony Cowley
wrote: Yes, but a line-based format along the lines of: foo 1.2.3 bar-baz 0.1.00
Would be easier to parse with the usual shell tools.
Anthony
On Mar 26, 2015, at 9:41 AM, Michael Snoyman
wrote: Is the idea that you'd be able to make a query such as:
GET https://www.stackage.org/lts/1.14/build-plan?package=foo&package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"} , ... ]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
wrote: On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: > On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: > > > >> On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley wrote: >> >> >>> On Mar 25, 2015, at 10:51 AM, Michael Snoyman wrote: >>> >>> >>> >>>> On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley wrote: >>>> On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman wrote: >>>> > >>>> > >>>> > On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley >>>> > wrote: >>>> >> >>>> >> The suggestion to use "cabal install --dependencies-only ..." instead >>>> >> of "cabal freeze" in that issue is really nicely presented. "cabal >>>> >> freeze" is close to the right thing, but it's just not as fully >>>> >> featured as "cabal install" (e.g. taking flags). >>>> >> >>>> >> As for Stackage, I think it would be helpful to cache the full build >>>> >> plans computed for each package in Stackage. This is most of the work >>>> >> my Nix tooling currently does, so it would be a big time saver. >>>> >> >>>> >> >>>> > >>>> > By "full build plans," do you mean the dist/setup-config file, or something >>>> > else? That file would be problematic since it's Cabal-library-version >>>> > specific IIRC. If you're looking for the full listing of deep dependencies >>>> > and versions, we can extract that from the .yaml file using the technique I >>>> > mentioned earlier. >>>> > >>>> > Michael >>>> >>>> Yes, I meant the full listing of deep dependencies. >>> >>> I've put together a Gist with an executable that does what I described: >>> >>> https://gist.github.com/snoyberg/5b244331533fcb614523 >>> >>> You give it three arguments on the command line: >>> >>> * LTS version, e.g. 1.14 >>> * Name of package being checked >>> * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well >>> >>> If that's useful, I can package that up and put it on Hackage. >>> >>> Michael >> >> This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going. >> >> Anthony > > Oh, that's actually a great idea. What if we had a program that: > > 1. takes a set of packages that needs to be installed, and an LTS version > 2. computes the dependency tree > 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed > > As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially. > > Michael Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

It's trivial for me to include them all, and equally trivial for me to call
out which ones are shipped with GHC somehow (such as an extra flag on that
line). I'll implement this currently to dump everything out without any
extra flag, and we can tweak it in the future.
On Thu, Mar 26, 2015 at 5:01 PM Anthony Cowley
This is a touch subtle. base can be left out, but other packages that ship with ghc and are usually found in the global package db should be included as they can be upgraded. This has knock on effects where a new version of the unix package means we have to rebuild the directory package with that updated dependency, for example. This is something I already handle, so I'd be happy to have everything included in the provided build plan. I'd need to think more about whether or not some packages can safely be totally left out, but I'm on the road at the moment and not terribly capable of thought.
Anthony
On Mar 26, 2015, at 10:50 AM, Michael Snoyman
wrote: And do you want the information on the core packages (e.g., base, template-haskell, containers) as well, or should they be left out?
On Thu, Mar 26, 2015 at 4:48 PM Anthony Cowley
wrote: Yes, but a line-based format along the lines of:
foo 1.2.3 bar-baz 0.1.00
Would be easier to parse with the usual shell tools.
Anthony
On Mar 26, 2015, at 9:41 AM, Michael Snoyman
wrote: Is the idea that you'd be able to make a query such as:
GET https://www.stackage.org/lts/1.14/build-plan?package=foo&package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"} , ... ]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
wrote: On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley
wrote: On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman < michael@snoyman.com> wrote: > > > On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley < acowley@seas.upenn.edu> > wrote: >> >> The suggestion to use "cabal install --dependencies-only ..." instead >> of "cabal freeze" in that issue is really nicely presented. "cabal >> freeze" is close to the right thing, but it's just not as fully >> featured as "cabal install" (e.g. taking flags). >> >> As for Stackage, I think it would be helpful to cache the full build >> plans computed for each package in Stackage. This is most of the work >> my Nix tooling currently does, so it would be a big time saver. >> >> > > By "full build plans," do you mean the dist/setup-config file, or something > else? That file would be problematic since it's Cabal-library-version > specific IIRC. If you're looking for the full listing of deep dependencies > and versions, we can extract that from the .yaml file using the technique I > mentioned earlier. > > Michael
Yes, I meant the full listing of deep dependencies.
I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

OK, should be working now:
http://www.stackage.org/lts/build-plan?package=warp
On Thu, Mar 26, 2015 at 5:03 PM Michael Snoyman
It's trivial for me to include them all, and equally trivial for me to call out which ones are shipped with GHC somehow (such as an extra flag on that line). I'll implement this currently to dump everything out without any extra flag, and we can tweak it in the future.
On Thu, Mar 26, 2015 at 5:01 PM Anthony Cowley
wrote: This is a touch subtle. base can be left out, but other packages that ship with ghc and are usually found in the global package db should be included as they can be upgraded. This has knock on effects where a new version of the unix package means we have to rebuild the directory package with that updated dependency, for example. This is something I already handle, so I'd be happy to have everything included in the provided build plan. I'd need to think more about whether or not some packages can safely be totally left out, but I'm on the road at the moment and not terribly capable of thought.
Anthony
On Mar 26, 2015, at 10:50 AM, Michael Snoyman
wrote: And do you want the information on the core packages (e.g., base, template-haskell, containers) as well, or should they be left out?
On Thu, Mar 26, 2015 at 4:48 PM Anthony Cowley
wrote: Yes, but a line-based format along the lines of:
foo 1.2.3 bar-baz 0.1.00
Would be easier to parse with the usual shell tools.
Anthony
On Mar 26, 2015, at 9:41 AM, Michael Snoyman
wrote: Is the idea that you'd be able to make a query such as:
GET https://www.stackage.org/lts/1.14/build-plan?package=foo& package=bar&package=baz
And get a result such as:
[ {"name":"foo", "version":"1.2.3"} , ... ]
?
On Thu, Mar 26, 2015 at 3:00 PM Anthony Cowley
wrote: On Mar 26, 2015, at 3:21 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 7:35 PM Anthony Cowley
wrote: On Mar 25, 2015, at 11:03 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:58 PM Anthony Cowley
wrote: On Mar 25, 2015, at 10:51 AM, Michael Snoyman
wrote: On Wed, Mar 25, 2015 at 4:30 PM Anthony Cowley < acowley@seas.upenn.edu> wrote:
> On Wed, Mar 25, 2015 at 10:24 AM, Michael Snoyman < > michael@snoyman.com> wrote: > > > > > > On Wed, Mar 25, 2015 at 4:17 PM Anthony Cowley < > acowley@seas.upenn.edu> > > wrote: > >> > >> The suggestion to use "cabal install --dependencies-only ..." > instead > >> of "cabal freeze" in that issue is really nicely presented. "cabal > >> freeze" is close to the right thing, but it's just not as fully > >> featured as "cabal install" (e.g. taking flags). > >> > >> As for Stackage, I think it would be helpful to cache the full > build > >> plans computed for each package in Stackage. This is most of the > work > >> my Nix tooling currently does, so it would be a big time saver. > >> > >> > > > > By "full build plans," do you mean the dist/setup-config file, or > something > > else? That file would be problematic since it's > Cabal-library-version > > specific IIRC. If you're looking for the full listing of deep > dependencies > > and versions, we can extract that from the .yaml file using the > technique I > > mentioned earlier. > > > > Michael > > Yes, I meant the full listing of deep dependencies. > > > I've put together a Gist with an executable that does what I described:
https://gist.github.com/snoyberg/5b244331533fcb614523
You give it three arguments on the command line:
* LTS version, e.g. 1.14 * Name of package being checked * true == only include dependencies of the library and executable, anything else == include test and benchmark dependencies as well
If that's useful, I can package that up and put it on Hackage.
Michael
This is very helpfulness, thanks! There is a bootstrapping issue, though, which is, I imagine, why both Miëtek and I have been writing much more bash than we'd like. But perhaps this becomes part of a cabal-install-like bootstrap.sh script to get things going.
Anthony
Oh, that's actually a great idea. What if we had a program that:
1. takes a set of packages that needs to be installed, and an LTS version 2. computes the dependency tree 3. writes out a shell script (possibly batch program?) to wget, tar xf, and runghc Setup.hs in the correct order to get all of those packages installed
As you can tell from the program I just threw together, stackage-types supports this kind of thing pretty trivially.
Michael
Yes, that's what the Nix tooling does. The extra bits are building up package databases suitable for each build without copying files all over the place. That has the extra benefit of being able to reuse builds when the recipe is unchanged. It is definitely not hard, but getting the build plans from stackage in a portable way would be valuable.
Anthony
OK, I've updated the Gist so that it produces a shell script that will install all necessary packages. It also has a nicer optparse-applicative interface now.
https://gist.github.com/snoyberg/5b244331533fcb614523
One thing I didn't do here is add support for custom GHC package databases. I assume you'll need that, but wasn't sure exactly how you're doing that in Nix.
If this is useful for you, I'll start a stackage-bootstrap repo, clean up this code a bit, and we can continue improving it from there.
Michael
Just having a URL from which to GET the build plan would be most useful. As you say, the actual package building happens after DB creation, and that requires knowing what to put in the DB.
Anthony

The suggestion to use "cabal install --dependencies-only ..." instead
of "cabal freeze" in that issue is really nicely presented. "cabal
freeze" is close to the right thing, but it's just not as fully
featured as "cabal install" (e.g. taking flags).
As for Stackage, I think it would be helpful to cache the full build
plans computed for each package in Stackage. This is most of the work
my Nix tooling currently does, so it would be a big time saver.
Anthony (re-sending after joining the GitHub group)
On Wed, Mar 25, 2015 at 8:26 AM, Miëtek Bak
On 2015-03-25, at 12:16, Michael Snoyman
wrote: Trying to understand the problem: currently, with your approach, if the project depends on a library not in the LTS Haskell release, then the cabal-install dependency solver won't be able to find it. Instead, you'd like to be able to use the dependency solver to track down those extra dependencies. Is that correct?
If so, why not take a multi-pass approach: download the cabal.config from stackage.org (which creates an inclusive snapshot), and then use --dry-run, which will tell you all the packages to be used.
You’re correct. However, this will have to be `cabal install --dependencies-only --dry-run`, and not `cabal freeze --dry-run`, because `cabal freeze` always completely ignores any existing version constraints, whether local or global (https://github.com/haskell/cabal/issues/2265).
I’m planning to switch away from `cabal freeze` soon, but it’s not going to be a drop-in replacement (https://github.com/mietek/halcyon/issues/52).
This is a good moment to carefully consider the meaning of a per-application `cabal.config` file, and whether the `cabal freeze` flavour should be completely replaced by separate constraints files. Perhaps, as mentioned in the original `cabal freeze` proposal, we could also have separate constraints sets for different GHC versions.
I’m hoping Cabal developers could chime in on the discussion.
-- Miëtek https://mietek.io
participants (4)
-
Anthony Cowley
-
Anthony Cowley
-
Michael Snoyman
-
Miëtek Bak