使用ghci查找类型

egi*_*dra 8 haskell ghci

当我在ghci中做一些简单的事情时,如下所示:

let x = 7 + 2
Run Code Online (Sandbox Code Playgroud)

我希望ghci给出x所持类型的响应,如:

x :: Integer
Run Code Online (Sandbox Code Playgroud)

当我运行ghci时,我没有得到上述那一行.我该如何得到答复?

Mat*_*nov 25

要显示类型自动使用:set +t:

?> :set +t
?> let x = 7 + 2
x :: Integer
?>
Run Code Online (Sandbox Code Playgroud)


dav*_*420 10

使用ghci :t命令,如下所示:

Prelude> let x = 7 + 2
Prelude> :t x
x :: Integer
Prelude> 
Run Code Online (Sandbox Code Playgroud)


Tan*_*neb 7

要在GHCi中查找某些内容的类型,您可以使用该:type命令,或者(更常见的是)缩写:t.有了这个,你可以做类似的事情:

Prelude> let x = 7 + 2
Prelude> :t x
x :: Integer
Run Code Online (Sandbox Code Playgroud)