Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show type of each result in GHCi

How can I show type of resulting expression in GHCi after each command? For example, instead of

ghci> "hello" ++ " world"
"hello world"

I want to see

ghci> "hello" ++ " world"
"hello world" :: String

or at least

ghci> "hello" ++ " world"
"hello world" :: [Char]

REPLs for other languages provide such behavior by default. But I can't find proper ghci option for such behavior. It also will be ok for me to just print type of it after executing every command. But I didn't find a way how to call my commands after each ghci command. Well, sensible command: let ... = ... doesn't have result (though it would be nice to print type of defined variable). So what are the ways to show type of result automatically after each command?

like image 794
Shersh Avatar asked Jan 03 '23 11:01

Shersh


1 Answers

Add :set +t to .ghci.

From documentation:

+t
    Display the type of each variable bound after a statement is entered at the prompt.
    If the statement is a single expression, then the only variable binding will be for
    the variable ‘it’.
like image 176
ДМИТРИЙ МАЛИКОВ Avatar answered Jan 06 '23 02:01

ДМИТРИЙ МАЛИКОВ