Hen*_*ing 1 syntax haskell typed-holes
Haskell如何解释表达式A._
?例如main = print $ A._
.
Haskell抛出以下错误错误:
source_file.hs:1:16:
Found hole ‘_’ with type: r0
Where: ‘r0’ is an ambiguous type variable
Relevant bindings include
main :: IO ()
(bound at source_file.hs:1:1)
In the second argument of ‘($)’, namely ‘A._’
In the expression: print $ A._
In an equation for ‘main’: main = print $ A._
Run Code Online (Sandbox Code Playgroud)
但是,根据Haskell的语法参考,A._
应该被解释为consym (A)
,varsym (.)
并且reservedid (_)
,因为_
不是有效的varid
(varid
s不能是reservedid
s).
Haskell抛出相同的错误main = print $ A._t
:
source_file.hs:1:16:
Found hole ‘_t’ with type: r0
Where: ‘r0’ is an ambiguous type variable
Relevant bindings include
main :: IO ()
(bound at source_file.hs:1:1)
In the second argument of ‘($)’, namely ‘A._t’
In the expression: print $ A._t
In an equation for ‘main’: main = print $ A._t
Run Code Online (Sandbox Code Playgroud)
然而在这种情况,该令牌序列应该qvarid (A._t)
为A
比赛modid
而_t
比赛varid
.
任何人都可以帮我解释发生了什么吗?