4

I am digging through ghcjs-jquery code to see how JavascriptFFI works. What I am trying to figure out is that once you define FFI import type signature for a JS function, how do you help ghcjs locate the file containing the function.

Checking Internal.hs and Cabal configuration, I don't see any way to specify the path of the JQuery JS files. I also looked around for documentation on JavascriptFFI feature but haven't found anything. I will appreciate pointers on how to do Javascript FFI in ghcjs for any JS library. There must be some command-line option to ghcjs to tell it where to locate the js files.

I am planning to play with dojo library functions after I figure out JavascriptFFI feature of ghcjs.

Cactus
  • 27,075
  • 9
  • 69
  • 149
Sal
  • 4,312
  • 1
  • 17
  • 26
  • 1
    But why does GHCJS have to be able to "find" the functions? It just generates calls to them; then, if at runtime the functions are loaded, the calls will succeed. Have I missed something? – Erik Kaplun Apr 21 '15 at 09:27

1 Answers1

1

You need to take care of loading those Javascript files yourself in the page that you use the GHCJS-generated Javascript. GHCJS doesn't need to find the actual definition of the referenced Javascript functions -- it takes for granted whatever type you add in your foreign declaration.

Cactus
  • 27,075
  • 9
  • 69
  • 149