use*_*661 12 haskell types type-inference ghci
是否有可能在ghci中查询为另一个函数内的函数推断的类型?
Tom*_*rst 21
这是一个快速而丑陋的黑客攻击,但我通常只是以错误的方式使用该函数并阅读错误消息:
inc x = x + 1
where
f (y, z) = y + z
g = f :: Char
Run Code Online (Sandbox Code Playgroud)
GHCi输出:
Couldn't match expected type `Char'
against inferred type `(t, t) -> t'
In the expression: f :: Char
Run Code Online (Sandbox Code Playgroud)
虽然这省略了背景Num t =>
,但这通常会为我提供足够的信息来继续.
Pau*_*son 12
您可以尝试通过在其上设置断点来执行此操作,因此该函数位于调试器的范围内.
另外我认为EclipseFP可以告诉你鼠标悬停在它们上面时的类型,至少在某些时候.