@@ -123,6 +123,7 @@ import Control.Lens (IndexPreservingGetter, to)
123123import Data.Text (Text)
124124
125125-- $setup
126+-- >>> import Control.Concurrent.MVar (newEmptyMVar, takeMVar, putMVar)
126127-- >>> import Language.Javascript.JSaddle.Test (testJSaddle)
127128-- >>> import Language.Javascript.JSaddle.Evaluate (eval)
128129-- >>> import Language.Javascript.JSaddle.Value (val, valToText, JSNull(..), deRefVal)
@@ -409,9 +410,15 @@ obj = Object <$> sendLazyCommand NewEmptyObject
409410--
410411-- >>> testJSaddle $ eval "(function(f) {f('Hello');})(function (a) {console.log(a)})"
411412-- undefined
412−-- >>> testJSaddle . deRefVal $ call (eval "(function(f) {f('Hello');})") global [fun $ \ _ _ args -> valToText (head args) >>= (liftIO . putStrLn . T.unpack) ]
413+-- >>> :{
414+-- testJSaddle $ do
415+-- result <- liftIO newEmptyMVar
416+-- deRefVal $ call (eval "(function(f) {f('Hello');})") global [fun $ \ _ _ [arg1] -> do
417+-- valToText arg1 >>= (liftIO . putMVar result)
418+-- ]
419+-- liftIO $ takeMVar result
420+-- :}
413421-- Hello
414−-- undefined
415422fun :: JSCallAsFunction -> JSCallAsFunction
416423fun = id
417424