0

我正在将 D3 可视化从 Javascript 转换为 Purescript,并且在尝试将选择保存在 do 块中时出现语法错误。

这是代码:

enterCountry country = do

  sel <- select "g.root"
    .. selectAll "g.country"
    .. data (\c -> c.name)
    .. enter
    .. append "g" .. attr "class" "country"

  sel .. append "title" .. text (\c -> c.name)

这是错误:

unexpected LArrow
expecting no indentation or end of input
See https://github.com/purescript/purescript/wiki/Error-Code-ErrorParsingModule for more information, or to contribute content related to this error.

错误指向以开头的行sel <- ...

4

1 回答 1

3

不幸的是,在这种情况下,这似乎不是一个特别有用的错误消息,但我相信这是因为您试图将关键字data用作函数而引起的。

我不知道 purescript-d3 api,所以我不确定那个函数应该是什么。但希望这会引导你朝着正确的方向前进。

于 2015-12-23T21:18:14.557 回答