Using PureScript FFI to Safely Call JavaScript Libraries
Learn how PureScript’s FFI lets you call JavaScript functions with type‑safe contracts, see a worked sqrt example, and understand the limits and verification steps.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how PureScript’s FFI lets you call JavaScript functions with type‑safe contracts, see a worked sqrt example, and understand the limits and verification steps.
PureScript’s Foreign Function Interface (FFI) lets you call JavaScript directly. This article walks through a real example, highlights common pitfalls, and shows how to keep your code safe and maintainable.
Learn how to call C's printf from Nim using the FFI pragma, compile with the correct linker flags, verify the output, and troubleshoot common linking issues.
Use LuaJIT FFI to call C libraries in an embedded Lua runtime. Follow a minimal architecture, validate trust boundaries, perform runtime checks, and know when to fallback to the Lua C API.
Integration goal Determine whether the PureScript FFI layer propagates JavaScript exceptions thrown inside a mock effect interpreter used with purescript-http-client as PureScript errors in the Effect monad, or whether such exceptions can terminate the test process. Constraints and uncertainty Tests must run without production credentials, using a pure mock
Carbon aims to provide a bidirectional bridge with C++ while maintaining a memory safety model through its default 'safe' dialect. This model restricts pointer arithmetic and unchecked memory access to prevent common vulnerabilities found in manual memory management. When integrating Carbon with legacy C++ code, the language must reconcile its strict type sy
PureScript compiles to JavaScript and exposes host functions through foreign import , but the FFI boundary is untyped: PureScript's erased types become plain objects at runtime, and JavaScript consumers cannot rely on compile-time guarantees. The compiler can emit different JavaScript module formats, such as CommonJS and ES modules, which determines how Node
Stale FFI type specialization after reloading a LuaJIT module I am working with LuaJIT's FFI and have run into a design question around type-specialization caching. When a module is reloaded via require (for example after redefining a C struct layout), the recorded type specialization appears to persist, so conversions may still follow the old struct layout.
Interruption Behavior in Foreign Function Interface Racket provides the timeout function to limit the execution time of expressions, returning #f if the specified millisecond threshold is exceeded. This mechanism relies on the runtime's ability to deliver an interruption signal to the executing thread. A known constraint involves the interaction between thes