4

I'm new to Haskell stack and wondering how to find out the name of the package that contains a particular module.

Currently, I want to use Data.Tuple.Extra(fst3) ( https://hackage.haskell.org/package/extra-1.7.9/docs/Data-Tuple-Extra.html ) and want to know what I should write below

    $ stack install ????

I've already installed the tuple package, which, however, doesn't seem to include the Extra part.

All the Internet resources about the installation of a package I've found so far say something along the lines of "To use Blahblah.Anything.Something, you need to install the foofoo package" . . . How can one know? I searched Stackage but it shows only the documentation of Data.Tuple.Extra and I still fail to find the name of the package.

Edit: As K.A.Buhr notes in her/his answer, stack install is the wrong command for the above case. Use stack build instead.

Ryo
  • 317
  • 1
  • 7
  • 1
    The URL contains the package name: `extra`. On the web page, you can also find the package name in the header: `extra-1.7.9: Extra functions I use.`. `1.7.9` is the version number. "Extra functions I use." is the package synopsis. – sjakobi Mar 11 '21 at 13:27
  • 1
    Does this answer your question? [Where can I find correct package name and version for Haskell?](https://stackoverflow.com/questions/48854832/where-can-i-find-correct-package-name-and-version-for-haskell) – Mark Seemann Mar 11 '21 at 14:39
  • 1
    `stack install` is for installing binaries, not libraries. You want to create a stack project and add `extra` to your dependencies. – Travis Mar 11 '21 at 15:38
  • @sjakobi Thanks! That's exactly what I was looking for. (Isn't it too obscure? It's almost impossible to find out on one's own.) – Ryo Mar 11 '21 at 15:43
  • @Mark Seemann Only just. I was able to find out the answer to my question in the thread you link **only because I read it after I had read sjakobi's answer**. My question is much simpler (What's the package name for "stack install"?) and the answer is therefore much more specific and simpler. I think I would have remained confused by the thread you link if this thread here didn't exist. – Ryo Mar 11 '21 at 15:49
  • @TravisSunderland Thanks. I knew that once you've found out the name of the package, yours is the way to go, except that my "project" at hand is so small that my debugging and calculation will be easily done on ghci. It's not worth creating a "project". – Ryo Mar 11 '21 at 15:53
  • @Ryo Just in case you don't know, you can use `stack ghci --package extra` to start up ghci with the `extra` package available. – Travis Mar 11 '21 at 19:19
  • @Ryo That other question involved a second underlying issue which came to light during the discussion, which made the answers there quite scattershot. Your question is more sharply focused, which is useful. – duplode Mar 11 '21 at 23:14

1 Answers1

5

When browsing package documentation in Hackage, the top-left portion of the page header will always give the package, version number, and description. On the page you link, it's here:

enter image description here

You can also use the "Contents" link in the top-right to go to the main page for the extra package, which gives its full list of modules, licensing, links to the package home page and bug tracker, and so on.

As a side note, stack install extra is technically the wrong command to "install" this package. If you want to make the extra package available for use within the Stack global project, the correct command is stack build extra. If you want to use extra within a stack project, then you want to add extra to the dependencies in your package's xxx.cabal or package.yaml file instead and run stack build (no arguments) to build and install it for use in your project.

In contrast, the stack install command is equivalent to stack build --copy-bins which copies any executables in the package to ~/.local/bin so they'll be in your path. See the Stack docs. It's intended to be used for installing programs written in Haskell that are distributed via Stack, so you can do stack install hlint to install the hlint linter, for example.

In this case, because the extra package has no executables, stack install extra and stack build extra will do the same thing, but it's better to get into the habit of using stack build when you aren't intending to install any package binaries, to avoid surprises.

K. A. Buhr
  • 45,621
  • 3
  • 45
  • 71