我在Yesod测试中有一个阻止,我希望用预期的响应来测试响应。
我试图在此do块中创建一个预期的响应
let expectedUser = User [authorized = true, ident = "AdminUser", displayName = Nothing, id = 1, avatar = Nothing]
在这一行,我收到错误
parse error on input ‘=’
Perhaps you need a 'let' in a 'do' block?
在authorized
之后的=。我如何重写这一行,以便它可以在do块中工作?
答案 0 :(得分:5)
您在编译错误中获得的建议大多无关紧要,因为解析器实际上并不知道您在此处尝试做什么。记录语法使用大括号{
和}
,而不是[
和]
。所以看起来应该是这样的:
let expectedUser = User {authorized = true, ident = "AdminUser", displayName = Nothing, id = 1, avatar = Nothing}
我会建议一些换行符:)
let expectedUser = User { authorized = true
, ident = "AdminUser"
, displayName = Nothing
, id = 1
, avatar = Nothing
}