[Git][ghc/ghc][wip/js-exports] JS/FFI/Callbacks: edit user guide documentation

Josh Meredith (@JoshMeredith) gitlab at gitlab.haskell.org
Tue Mar 21 14:06:15 UTC 2023



Josh Meredith pushed to branch wip/js-exports at Glasgow Haskell Compiler / GHC


Commits:
65129449 by Josh Meredith at 2023-03-21T14:06:05+00:00
JS/FFI/Callbacks: edit user guide documentation

- - - - -


1 changed file:

- docs/users_guide/exts/ffi.rst


Changes:

=====================================
docs/users_guide/exts/ffi.rst
=====================================
@@ -1147,12 +1147,15 @@ FFI and the JavaScript Backend
    single: FFI and the JavaScript Backend
 
 GHC's JavaScript backend supports its own calling convention for
-JavaScript-specific foreign imports. Instead of a function name,
-the import string expected to be an unapplied JavaScript `arrow
-function <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions>`_.
+JavaScript-specific foreign imports. Any unapplied function is
+supported, including function names. Commonly, JavaScript foreign
+imports are written as an unapplied JavaScript `arrow function
+<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions>`_,
+but ``function`` keyword anonymous functions are also supported.
 
-Arrow functions enable the use of arbitrary JavaScript in import
-strings, so a simple example might look like:
+By treating an import string as an unapplied function, arbitrary
+JavaScript can be included in an import, so a simple example might
+look like:
 
 .. code-block:: haskell
 
@@ -1246,7 +1249,9 @@ must be manually released when no longer needed.
 
 On the first line of ``main``, we see where the ``Callback`` is actually
 created, by ``syncCallback1``. ``syncCallback`` has versions up to three,
-including a zero-argument version with no suffix.
+including a zero-argument version with no suffix. To use callbacks with more
+than three pieces of data, it's recommended to package data into JavaScript
+objects or arrays as required.
 
 There are three categories of functions that create callbacks, with the
 arity-1 type signatures shown here for demonstration:



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65129449323bbd723a8ffbab480187de6af77c61

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65129449323bbd723a8ffbab480187de6af77c61
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230321/9be294ab/attachment-0001.html>


More information about the ghc-commits mailing list