I made a mistake in another question that could have been solved by viewing
:t myfunctionofinterest
for a function I was using in a library.
However, when I am in my project root, and run
$ stack ghci
And my Main.hs has:
import MyLib
And my module does:
module MyLib {
bunchOfFunctions -- but not myfunctionofinterest
} where
import SomeDB.ModuleThatExposes -- myfunctionofinterest
myfunc :: IO ()
myfunc = do
myfunctionofinterest a b c -- place where I misuse myfunctionofinterest and could have used :t on it to see it had 3 args
I can't :t
myfunctionofinterest in the main since it's not exposed, nor does Import MyLib.myfunctionofinterest
explicitly
help, since it was something defined in an import. While I know I could expose it then check it, :a
to compile, and then edit the lib to hide it again, is there anything that allows that more quickly and directly?
This seems like it must be a common pattern. What do you do when you need to check the type of something used in a library as you develop?
Quoting the GHCi docs:
The
:module
command provides a way to do two things that cannot be done with ordinary import declarations:
:module
supports the*
modifier on modules, which opens the full top-level scope of a module, rather than just its exports.
The additional *
makes GHCi load the bytecode version of the module. This will not be as performant, but you'll get access to unexported bindings.
Example:
λ> :m *MyLib
λ> :t myfunctionofinterest
If you get
module 'MyLib' is not interpreted; try ':add *MyLib' first
you may have to do :load
first (the advice about :add
doesn't always do the trick):
λ> :l *MyLib
λ> :m *MyLib
λ> :t myfunctionofinterest
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