0

I am converting a D3 visualisation from Javascript to Purescript and i get a syntax error while trying to save a selection within a do block.

This is the code:

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)

And this is the error:

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.

The error is pointing at the line starting with sel <- ...

danza
  • 11,511
  • 8
  • 40
  • 47

1 Answers1

3

Unfortunately, it doesn't seem to be a particularly helpful error message in this case, but I believe it is being caused because you are trying to use the keyword data as a function.

I don't know the purescript-d3 api, so I'm not sure what that function is supposed to be. But hopefully that will lead you in the right direction.

Brenton Alker
  • 8,947
  • 3
  • 36
  • 37
  • Nice timing man, i had just figured this out, but you win the trophy! ;) I will edit the question in order to help people with the same problem easier. The correct function to use instead of `data` is `bindData`, you might want to edit the answer in order to reflect this – danza Dec 23 '15 at 21:29