To see the function's signature in Haskell GHCI, I have to prefix it with :t
:
Prelude> f = \x -> x+1
Prelude> :t f
f :: Num a => a -> a
But typing that prefix every time grows quickly old. If I leave it out, I get error:
Prelude> f
<interactive>:5:1: error:
• No instance for (Show (a0 -> a0)) arising from a use of ‘print’
(maybe you haven't applied a function to enough arguments?)
• In the first argument of ‘print’, namely ‘it’
In a stmt of an interactive GHCi command: print it
Instead of getting this error message, I would like see some useful information about my function f
similar to the one I get with :t f
(possibly even more information about f
).
How can I set up the GHCI to achieve this functionality, i.e. getting function's info upon entering it without :t
?
You probably can't do this today. I've opened a feature request to see about adding options to control what GHCi reports about type errors at the prompt.