Skip to content

Instantly share code, notes, and snippets.

@johncant
Created April 9, 2015 19:34
Show Gist options
  • Save johncant/ce2fdf37713396dba069 to your computer and use it in GitHub Desktop.
Save johncant/ce2fdf37713396dba069 to your computer and use it in GitHub Desktop.
GHCJS call callback synchronously [FAIL]
import GHCJS.Foreign
import GHCJS.Types
data DontTouchThis
foreign import javascript "js_testFunc" js_testFunc :: JSFun (JSRef DontTouchThis -> IO JSString) -> IO ()
main :: IO ()
main = js_testFunc =<< syncCallback1 AlwaysRetain True (\_ -> putStrLn "bar" >> return (toJSString "quux"))
js_testFunc = function(cb) {
window.setTimeout(function() {
debugger // Good luck
// cb("foo") returns null, h$runSync and most other things throws an error or returns null
}, 1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment