在输入'='`上记录语法`解析错误

时间:2018-02-25 01:48:28

标签: haskell

我在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块中工作?

1 个答案:

答案 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
                        }