Reputation: 1
I'm new to haskell. Sometimes I write some complicated functions that I'm not so sure about the types myself, so I don't define its type beforehand, compiling and running still work fine. I want to know if I can print out the types of that function like in "ghci> :info someFunc" in the program, just to see how Haskell define its. Maybe something like this:
f x = 2*x
main :: IO()
main = do
print_info f
I know I can "ghci> :load program.hs" & then ":info f", but for me it is quite unconvenient & sometime working with ghci can be ugly.
Upvotes: 0
Views: 191
Reputation: 153182
Can't be done. You can sort of get close with Typeable
, but polymorphism cannot be captured, even in principle.
Instead, I recommend that you set up the Haskell Language Server and connect your editor to it; most editors support at least the level of connection that lets you hover a term to see its type or add a type signature to a definition with a keybinding.
Upvotes: 2