简体   繁体   中英

Where can I find correct package name and version for Haskell?

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.

PS "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?

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.

PS: 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.)

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

包名称突出显示

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM