How do I do multiline foreign imports with ghcjs?

183 Views Asked by At

How do I do multiline foreign imports in GHCJS? I have a block of javascript that stretches over multiple lines:

foreign import javascript unsafe
  "{ var x = 41;\
  \  $r = x + 1; \
  \}"
  answerToGreatestQuestion :: IO (JSRef Double)

And I get an error like:

lexical error in string/character literal at character 'i'

which points to the \ character. What's going on here?

1

There are 1 best solutions below

0
On

If you're within a CPP block, remove the leading \ from each line. See this issue.