Reputation: 9087
When I do something simple in ghci, like the following:
let x = 7 + 2
I expect ghci to give a response of the type that x holds, like:
x :: Integer
When I run ghci, I do not get that the above line. How do I get that response?
Upvotes: 12
Views: 11697
Reputation: 198
To find the type of something in GHCi, you can use the :type
command, or (as is much more common), the abbreviated :t
. With this, you can do something like:
Prelude> let x = 7 + 2
Prelude> :t x
x :: Integer
Upvotes: 9
Reputation: 3900
To show types automatically use :set +t
:
μ> :set +t
μ> let x = 7 + 2
x :: Integer
μ>
Upvotes: 32
Reputation: 47062
Use the ghci :t
command, like so:
Prelude> let x = 7 + 2
Prelude> :t x
x :: Integer
Prelude>
Upvotes: 14