Safe Haskell | None |
---|---|
Language | Haskell98 |
Dynamically export Haskell values to JavaScript
Synopsis
- data Export a
- export :: Typeable a => a -> IO (Export a)
- withExport :: Typeable a => a -> (Export a -> IO b) -> IO b
- derefExport :: forall a. Typeable a => Export a -> IO (Maybe a)
- releaseExport :: Export a -> IO ()
Documentation
export :: Typeable a => a -> IO (Export a) Source #
Export any Haskell value to a JavaScript reference without evaluating it. The JavaScript reference can be passed to foreign code and used to retrieve the value later.
The data referenced by the value will be kept in memory until you call
releaseExport
, even if no foreign code references the export anymore.
withExport :: Typeable a => a -> (Export a -> IO b) -> IO b Source #
Export the value and run the action. The value is only exported for the
duration of the action. Dereferencing it after the withExport
call
has returned will always return Nothing
.
derefExport :: forall a. Typeable a => Export a -> IO (Maybe a) Source #
Retrieve the Haskell value from an export. Returns Nothing
if the
type does not match or the export has already been released.
releaseExport :: Export a -> IO () Source #
Release all memory associated with the export. Subsequent calls to
derefExport
will return Nothing