HORIZON HASKELLDocslts/ghc-10.0.xc7d136e2026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · c7d136e · 2026-10-12

Modulebase-4.23.0.0Haskell2010

GHC.JS.Foreign.Callback

  • 2 types
  • 13 values
  • Packagebase-4.23.0.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceCallback.hs
valuereleaseCallback :: Callback a -> IO ()
#

When you create a callback, the Haskell runtime stores a reference to the exported IO action or function. This means that all data referenced by the exported value stays in memory, even if nothing outside the Haskell runtime holds a reference to to callback. Use releaseCallback to free the reference. Subsequent calls from JavaScript to the callback will result in an exception.

asynchronous callbacks

4 declarations
valueasyncCallback
  1. :: IO ()

    the action that the callback runs

  2. -> IO (Callback (IO ()))

    the callback

#

Make a callback (JavaScript function) that runs the supplied IO action in an asynchronous thread when called. Call releaseCallback when done with the callback, freeing data referenced by the IO action.

synchronous callbacks

4 declarations
valuesyncCallback
  1. :: OnBlocked

    what to do when the thread blocks

  2. -> IO ()

    the Haskell action

  3. -> IO (Callback (IO ()))

    the callback

#

Make a callback (JavaScript function) that runs the supplied IO action in a synchronous thread when called. Call releaseCallback when done with the callback, freeing memory referenced by the IO action.

valuesyncCallback1
  1. :: OnBlocked

    what to do when the thread blocks

  2. -> (JSVal -> IO ())

    the Haskell function

  3. -> IO (Callback (JSVal -> IO ()))

    the callback

#

Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes one argument that it passes as a JSVal value to the Haskell function. Call releaseCallback when done with the callback, freeing data referenced by the function.

valuesyncCallback2
  1. :: OnBlocked

    what to do when the thread blocks

  2. -> (JSVal -> JSVal -> IO ())

    the Haskell function

  3. -> IO (Callback (JSVal -> JSVal -> IO ()))

    the callback

#

Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes two arguments that it passes as JSVal values to the Haskell function. Call releaseCallback when done with the callback, freeing data referenced by the function.

valuesyncCallback3
  1. :: OnBlocked

    what to do when the thread blocks

  2. -> (JSVal -> JSVal -> JSVal -> IO ())

    the Haskell function

  3. -> IO (Callback (JSVal -> JSVal -> JSVal -> IO ()))

    the callback

#

Make a callback (JavaScript function) that runs the supplied IO function in a synchronous thread when called. The callback takes three arguments that it passes as JSVal values to the Haskell function. Call releaseCallback when done with the callback, freeing data referenced by the function.

synchronous callbacks that return a value

4 declarations
valuesyncCallback' :: IO JSVal -> IO (Callback (IO JSVal))
#

Make a callback (JavaScript function) that runs the supplied IO action in a synchronous thread when called. Call releaseCallback when done with the callback, freeing memory referenced by the IO action.