How to find the package, version, documentation for the name Haskell

My specific problem is this: I ran the name throwT in Module.hs in a large Haskell project. I want to know what throwT does. In the end, I managed to figure it out as follows:

  • run ghci for the project
  • :load Module.hs followed by :i throwT throwT :: Monad m => e -> Control.Monad.Trans.Either.EitherT emr -- Defined in 'Data.EitherR'
  • query hayoo for Data.EitherR , which points to the errors package
  • ghc-pkg list errors gives errors-1.4.7
  • check out hackage for documentation on this version of the error package: throwT

Is there a better way to do this, as in the sense of more accurate (step 3 - no), and less tiring?

+5
source share
2 answers

You can use ghc-pkg find-module instead of list , which immediately gives you the installed version of the package containing the module:

  • Fire ghci
  • :load YourModule.hs , get :info from your value
  • Use the name of this module with ghc-pkg find-module .
  • Now you know the exact module, package and version.

This still forces you to check the hack documentation. However, if you add documentation: true to your cabinet configuration or --enable-documentation , cabal will automatically create documentation during the installation of this package. Then you can shorten the procedure to

  • Fire ghci
  • :load YourModule.hs , get :info from your value
  • Check your local documentation for the link module.

The local documentation will be saved in your cabal directory or, if you are in a sandboxed environment, in .cabal-sandbox/share/doc/<plattform>/index.html .

+7
source

Ideally, each module explicitly imports each function it uses. Assuming that throwT was used in Module.hs but not defined in it, the first thing to check is if there is an import statement at the top of Module.hs that explicitly imports a function that looks something like import Some-Module (throwT, someOtherFunction, possiblyAnotherFunction) , where Some-Module is the imported module, and the functions in the parenthesis are the only ones that are imported from this module (this is an explicit import). Then you will find Some-Module and find the definition of throwT .

+1
source

All Articles