我正在使用 Dhall 1.39.0 并收到此错误:
Error: Expression doesn't match annotation
- Text
+ { … : … } (a record type)
[snip]
You or the interpreter annotated this expression:
[ file contents ]
... with this type or kind:
↳ Text
... but the inferred type or kind of the expression is actually:
↳ { Sentences :
List
{ Name : Text
, Object : Text
, Statement : Bool
, Subject : Text
, Verb : Text
}
, Version : Text
}
这是从 cat show-and-tell.dhall | ~/external-programs/bin/dhall --explain text
.
请注意,我可以将相关的 dhall 文件加载到 dhall-golang 库中并使其正确呈现。所以我有点困惑。
一个有点做作的示例文件在这里:
let Sentence : Type =
{
Name : Text,
Subject : Text ,
Verb : Text ,
Object : Text ,
Statement : Bool
}
let Information : Type = {
Version : Text,
Sentences : List Sentence
}
let all = ".+"
let answer : Information = {
Version = "v1"
, Sentences =
[ { Name = "s1"
, Subject = "bobross"
, Verb = "${all}"
, Object = "${all}"
, Statement = True
}
, { Name = "s2"
, Subject = "Everyone"
, Verb = "${all}"
, Object = "${all}"
, Statement = False
}
, { Name = "s3"
, Subject = "picasso"
, Verb = "questions"
, Object = "${all}"
, Statement = True
}
]
}
in answer