5

Say, I need System.Eval.Haskell. Or whatever else. How do I know which package I should specify in my package.yaml? When I go to the https://hackage.haskell.org/package/plugins-1.5.7/docs/System-Eval-Haskell.html, I see no package name.

P.S. "plugins" did not work for me. Thus, I assume it's something different. I hope so :)


Looks like there is somewhat quite unclear difference between extra-dependencies and "regular" dependencies in the configuration. Mentioning plugins-1.5.7 as extra-dep indeed works. Am I doing some dependency mismanagement here, or that's green way to go?

1
  • 3
    The package name is, in fact, "plugins", and you can find it in the page header there. I suggest you edit the error(s) you got into the question (even though your latest edit does point to your actual issue).
    – duplode
    Feb 18, 2018 at 18:01

3 Answers 3

5

When you view module documentation on hackage, the package name is in the upper left corner:

Package name highlighted

In this case, it's indeed plugins, version 1.5.7.

When you declare dependencies in your .cabal file, Stack will attempt to find a version that fits with the Long-Term Support (LTS) collection that you're targeting.

Sometimes, you want to use a different version than the one available in the LTS collection (for example if you want a more recent one), in which case you can define the package, and its specific version, in extra-dependencies.

2
  • How dangerous extra-deps are? Does it mean that I hardcode my dependency and thus auto-resolution might fail at any point due to some internal incompatibilities?
    – Zazaeil
    Feb 18, 2018 at 18:30
  • @SerejaBogolubov More dangerous than not using them... I don't think one can answer it more precisely than that. It'll depend on the particular package, etc. Feb 18, 2018 at 18:43
4

Looks like there is somewhat quite unclear difference between extra-dependencies and "regular" dependencies in the configuration. Mentioning plugins-1.5.7 as extra-dep indeed works. Am I doing some dependency mismanagement here, or that's green way to go?

That's how it is supposed to be. The issue is that there are two major archives of Haskell packages: Hackage, which includes basically every package and every version ever, and Stackage, which is a large subset of Hackage bundled into snapshots of mutually compatible packages and versions. Stack defaults to drawing packages from Stackage, so if you want to use a package from Hackage that is not in Stackage you have to also add it to the extra-deps of stack.yaml. Whether a package is in Stackage can be found the contents page of the package in the Hackage docs (if it is on Stackage, there will be an entry for it in the "Distributions" field). Also relevant is Stackage Hoogle, which lets you search for package names, modules and identifiers within a Stackage snapshot.

P.S.: For more on the relationship between Hackage, Stackage and Stack, you might have a look at my answer to What is the difference between Cabal and Stack? (You may replace any mentions of "the .cabal file" there by "package.yaml", if that's what you are using.)

4
  • Does stack suppose to guarantee that "everything will work fine all together"? I am pretty new to "real-world" Haskell projects and those dependency-management problems remarkably slows me down. Whenever I hardcode some package as extra-dep, I force stack to use that one and thus it might lead to a versioning issues, right?
    – Zazaeil
    Feb 18, 2018 at 18:23
  • @SerejaBogolubov [1/2] "Whenever I hardcode some package as extra-dep, I force stack to use that one and thus it might lead to a versioning issues, right?" -- Likely not. Assuming that your extra-dep has appropriate dependency version bounds (as it should be for a well-maintained non-Stackage package), Stack will quickly let you know if it is incompatible with the rest of the Stackage snapshot you are using. Also, the stack solver command will try to find a suitable version of the non-Stackage packages in package.yaml for you to add to the extra-deps.
    – duplode
    Feb 18, 2018 at 18:52
  • 1
    @SerejaBogolubov [2/2] Two other points worth noting. Firstly, extra-deps, unlike snapshot packages, are installed per-project, in a segregated way, so any issues won't compromise the rest of your Haskell environment. Secondly, Stack pins the versions of all snapshot packages, and so it won't attempt to bring in incompatible versions of other packages that you didn't explicitly add to extra-deps. All in all, I would say extra-deps aren't really dangerous.
    – duplode
    Feb 18, 2018 at 19:00
  • great to know, thanks a lot. you definitely showed me right way to go.
    – Zazaeil
    Feb 18, 2018 at 19:18
1

Say, I need System.Eval.Haskell. Or whatever else. How do I know which package I should specify in my package.yaml?

There may be many packages which export a particular module, so you can't necessarily know which package to import from the module name. But generally it's obvious from a google search.

As duplode mentions the package is named plugins, and as you found out stack uses the <package_name>-<version> format to specify a package name + version in the stack.yaml. Cabal uses a different format, which is more flexible (can specify fuzzy package version ranges, etc.). Since stack works on fixed snapshots of package versions, the plugins-1.5.7 format is sufficient.

When you write plugins in your *.cabal file, you're specifying something like "any version of plugins but prefer the most recent". But because your package repository is limited to a particular snapshot by stack what you're really doing is letting stack manage your dependencies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.