ghcjs-promise- Bidirectional bidings to javascript's promise.

Copyright(c) Alejandro Durán Pallarés, 2016
Safe HaskellNone



Data.JSVal.Promise defines Promise, a direct bind to javascript promise objects.

  • You can import/export them from javascript code using its FromJSVal and ToJSVal instances.
  • You can extract its value, blocking till computation has finished, using await. (you can safely call it several time from different threads, the associated computation will run once, and then memorized)
  • You can create new promise (to possible use js side) containing arbitrary haskell code using promise.

For some usage example, checkout this blog entry.



await :: Promise -> IO (Either JSVal JSVal) Source #

If the promise is return through "then", it will return Right; if it return through "catch", then it will return Left

promise :: IO (Either JSVal JSVal) -> IO Promise Source #

A Right value will be sent as a normal value through "then", a left value will be sent through "catch" (by javascript convention, representing an exception).

The block will start executing immediately, no mater if there's something waiting for it or not.

If the execution block launches an exception, then the promise will be receive as "reject", the javascript value "new Error('Haskell side error')"