Simple question. Is it possible to check the type of a variable that is only alive within a function?
For example:
main = do
x <- something
How can I check the type of x?
I can’t do :type x in ghci because x is not global.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Another way (quite similar to RobAgar’s and hacky as well) is to explicitly specify some wrong type for the local variable in question, e.g.:
Then ghci will give us an error:
which shows that the actual type of “x” is [String].