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