3 ms·
You just make an FFI declaration in Haskell: foreign import ccall square :: Int -> Int And use --with-js to link against a JS file: // square.js
by evincarofautumn 13y ago
You just make an FFI declaration in Haskell:
foreign import ccall square :: Int -> Int
And use --with-js to link against a JS file:
// square.js
function square(x) {
return x * x;
}
Using jQuery would be an interesting challenge. I suppose you could just get the jQuery object and go nuts on it unsafely, or write typesafe(ish) wrapper functions to export. The “ccall” convention is also a bit disingenuous.
Source: https://github.com/valderman/haste-compiler/blob/master/doc/js-externals.txt https://github.com/valderman/haste-compiler/blob/master/doc/...
- marshray 13y agojQuery seems to be particularly dynamic even as far as Javascript libraries go, but here's how Typescript handles it: https://typescript.codeplex.com/SourceControl/latest#typings/jquery.d.ts https://typescript.codeplex.com/SourceControl/latest#typings...
- fosap 13y agoSince jQuery is a monad i expect a Haskell wrapper to be written very soon.
- evincarofautumn 13y agoYou had better be joking.