Closed crocket closed 8 years ago
I'm trying to find a good way to wrap https://github.com/electron/electron/blob/master/docs/api/app.md#event-certificate-error
newtype AppBlahCallback = AppBlahCallback JSVal foreign import javascript interruptible "app.on('blah', function (a, b, c, callback) { $c(a, b, c, callback); })" waitAppBlah :: IO (JSVal, JSVal, JSVal, AppBlahCallback) foreign import javascript unsafe "$1($2)" appBlahCallback :: AppBlahCallback -> Bool -> IO () main :: IO () main = do forkIO $ do (_, _, _, cb) <- waitAppBlah appBlahCallback cb True
I cannot retrieve IO (JSVal, JSVal, JSVal, AppBlahCallback) from waitAppBlah more than once, but the event can call the callback multiple times.
IO (JSVal, JSVal, JSVal, AppBlahCallback)
waitAppBlah
If I retrieved
from waitAppBlah twice,
app.on('blah', function (a, b, c, callback) { $c(a, b, c, callback); })
would just be called twice. This doesn't make sense.
Since no function on GHCJS/Foreign/Callback.hs generates a callback of 4 or more parameters, it's not possible to write the following snippet, either.
GHCJS/Foreign/Callback.hs
newtype AppBlahCallback = AppBlahCallback JSVal foreign import javascript unsafe "app.on('blah', $1)" onAppBlah :: Callback (JSVal -> JSVal -> JSVal -> AppBlahCallback -> IO ()) -> IO () foreign import javascript unsafe "$1($2)" appBlahCallback :: AppBlahCallback -> Bool -> IO () main :: IO () main = do onAppBlah $ asyncCallback4 $ \_ _ _ cb -> appBlahCallback cb True
Does ghcjs-base need modification before I become able to write a wrapper for https://github.com/electron/electron/blob/master/docs/api/app.md#event-certificate-error?
Perhaps, do we need the following functions?
syncCallbackN :: Int -> OnBlocked -> a -> IO (Callback a) asyncCallbackN :: Int -> a -> IO (Callback a)
Or, how about
asyncCallback :: (JSVal -> JSVal -> ... -> JSVal -> IO a) -> IO (Callback (JSVal -> JSVal -> ... -> JSVal -> IO a))
I believe https://github.com/ghcjs/ghcjs-base/issues/76 subsumes this issue.
oops sorry did not see this and made #76 based on you gitter chat
I'm trying to find a good way to wrap https://github.com/electron/electron/blob/master/docs/api/app.md#event-certificate-error
I cannot retrieve
IO (JSVal, JSVal, JSVal, AppBlahCallback)
fromwaitAppBlah
more than once, but the event can call the callback multiple times.If I retrieved
from
waitAppBlah
twice,would just be called twice. This doesn't make sense.
Since no function on
GHCJS/Foreign/Callback.hs
generates a callback of 4 or more parameters, it's not possible to write the following snippet, either.Does ghcjs-base need modification before I become able to write a wrapper for https://github.com/electron/electron/blob/master/docs/api/app.md#event-certificate-error?
Perhaps, do we need the following functions?
Or, how about