:type
是不够的,因为我想表达的可能包括本地定义喜欢与分配的东西变量<-
,let
或where
。类型化的孔(用_
ghc替换表达式并用ghc加载)是接近的,但是它们为您提供了在那里被接受的内容,这可能比您好奇的表达式更笼统。
我以为我找到了的头奖:type-at
,但是我无法像我希望的那样工作。使用此文件,名为“ thing.hs”:
something :: ()
something = ()
main :: IO ()
main = return something
这是我在使用时得到的结果:type-at
:
> :set +c
> :l thing.hs
[1 of 1] Compiling Main ( thing.hs, interpreted )
Ok, one module loaded.
Collecting type info for 1 module(s) ...
> :type-at thing.hs 5 8 5 13 -- "return" on last line
<no location info>: error: not an expression: ‘’
> :type-at thing.hs 5 1 5 4 -- "main" on last line
:: IO ()
> :type-at thing.hs 5 15 5 23 -- "something" on last line
<no location info>: error: not an expression: ‘’
基本上与使用相同:type
。我希望我什至可以传递它的跨度return something
并获得Monad a => a ()
or IO ()
。如果可以在仅查看表达式的类型和“在那个时候”的表达式的类型之间进行选择(受制于带有类型孔的类型所限制)之后,该方法会更酷。
当我尝试:type-at thing.hs 5 8 5 14
,我得到:: () -> IO ()
。:type-at thing.hs 5 14 5 24
也一样:type-at thing.hs 5 14 6 1
。
因此,右边界应该是表达式末尾的单元格。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句