Dhall - 表达式与注释不匹配,应键入文本
Dhall - Expression doesn't match annotation, type Text expected
我正在使用 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
dhall text
用于呈现 Text
类型的 Dhall 表达式的值(有点像,例如 jq
的 -r
选项):
$ echo '"Foo"' | dhall text
Foo
与
相比
$ echo '"Foo"' | dhall
"Foo"
您的表达式的类型为 Information
;你只需要 dhall
本身。
$ cat show-and-tell.dhall | dhall
{ Sentences =
[ { Name = "s1"
, Object = ".+"
, Statement = True
, Subject = "bobross"
, Verb = ".+"
}
, { Name = "s2"
, Object = ".+"
, Statement = False
, Subject = "Everyone"
, Verb = ".+"
}
, { Name = "s3"
, Object = ".+"
, Statement = True
, Subject = "picasso"
, Verb = "questions"
}
]
, Version = "v1"
}
我正在使用 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
dhall text
用于呈现 Text
类型的 Dhall 表达式的值(有点像,例如 jq
的 -r
选项):
$ echo '"Foo"' | dhall text
Foo
与
相比$ echo '"Foo"' | dhall
"Foo"
您的表达式的类型为 Information
;你只需要 dhall
本身。
$ cat show-and-tell.dhall | dhall
{ Sentences =
[ { Name = "s1"
, Object = ".+"
, Statement = True
, Subject = "bobross"
, Verb = ".+"
}
, { Name = "s2"
, Object = ".+"
, Statement = False
, Subject = "Everyone"
, Verb = ".+"
}
, { Name = "s3"
, Object = ".+"
, Statement = True
, Subject = "picasso"
, Verb = "questions"
}
]
, Version = "v1"
}