Skip to content

Instantly share code, notes, and snippets.

@Wizek
Created February 1, 2018 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wizek/646f7a6063b18d6ad21e7748504f77ba to your computer and use it in GitHub Desktop.
Save Wizek/646f7a6063b18d6ad21e7748504f77ba to your computer and use it in GitHub Desktop.
#!/usr/bin/env nix-shell
#! nix-shell -p "haskell.packages.ghc822.ghcWithPackages (p: with p; with haskell.lib; [(doJailbreak (dontCheck jsaddle-warp))])"
#! nix-shell -i "runghc"
{-# language OverloadedStrings #-}
import Control.Monad.IO.Class
import Language.Javascript.JSaddle.Warp
import Language.Javascript.JSaddle
import Language.Javascript.JSaddle.Debug
import Control.Concurrent
import Control.Monad
import Data.Text
import Control.Concurrent.MVar
main = run 3197 $ do
result <- liftIO newEmptyMVar
deRefVal $ call (eval "(function(f) {f('Hello');})") global [fun $ \ _ _ [arg1] -> do
valToText arg1 >>= (liftIO . putMVar result)
]
liftIO $ takeMVar result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment