My concrete problem is this: I ran across the name throwT
in Module.hs
in a big Haskell project. I want to know what throwT
does. I eventually managed to figure this one out as follows:
:load Module.hs
followed by :i throwT
throwT :: Monad m => e -> Control.Monad.Trans.Either.EitherT e m r
-- Defined in ‘Data.EitherR’
Data.EitherR
, which points at the package errors
ghc-pkg list errors
gives errors-1.4.7
Is there a better way to do this, both in the sense of being more precise (step 3 is not), and less tedious?
You could use ghc-pkg find-module
instead of list
, which gives you the installed version of the package containing the module right away:
:load YourModule.hs
, get :info
on your valueghc-pkg find-module
.This still forces you to check the hackage documentation. However, if you add documentation: true
to your cabal configuration or --enable-documentation
, cabal will automatically build the documentation during the installation of the given package. Then you can shorten the procedure to
:load YourModule.hs
, get :info
on your valueThe local documentation will be stored in your cabal directory, or, if you are in a sandbox, in .cabal-sandbox/share/doc/<plattform>/index.html
.
Ideally, every module explicitly imports every function it uses. Assuming that throwT
was used in Module.hs
, but not defined in it, the first thing to check for is if there is an import statement at the top of Module.hs
that explicitly imports the function, which would look something like import Some-Module (throwT, someOtherFunction, possiblyAnotherFunction)
, where Some-Module
is the module being imported, and the functions within the parenthesis are the only things being imported from that module (this is what an explicit import is). You'd then find Some-Module
and look for the definition of throwT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With