PureScript
By the PureScript community
js backends with strict, sound static typing.
Definition
PureScript is a strongly-typed, purely functional programming language that compiles to readable JavaScript, designed as a Haskell-inspired alternative for building web front ends and Node.js backends with strict, sound static typing.
Overview
PureScript emerged in 2013 out of dissatisfaction with the type systems and semantics available to functional programmers targeting JavaScript. Where languages like TypeScript add gradual, escapable typing to an existing imperative language, PureScript instead starts from Haskell's foundations — pure functions, immutability by default, and an expressive Hindley-Milner-style type system with type classes — and compiles that down to small, human-readable JavaScript rather than a large runtime bundle. Unlike Haskell, PureScript has no built-in laziness; all evaluation is strict, which makes performance and behavior on the JavaScript runtime more predictable. Its module system, records, and row-polymorphism (used heavily for extensible records and effect tracking) let developers model complex domains precisely, while its Foreign Function Interface allows straightforward interop with existing JavaScript and TypeScript libraries. Effects such as I/O, exceptions, and mutation are tracked explicitly in the type system through the Effect and Aff monads, pushing side effects to the edges of a program the same way Haskell does. PureScript compiles to JavaScript that a competent JavaScript engineer can read and debug, which was a deliberate design choice to ease adoption and interoperability, distinguishing it from other Haskell-to-JS efforts like GHCJS. It has a smaller but dedicated community than TypeScript or Elm, with frameworks such as Halogen and Thermite for building purely functional web UIs. It is most often reached for by teams that already value Haskell-style correctness guarantees — exhaustive pattern matching, no null references, referential transparency — and are willing to accept a steeper learning curve and smaller ecosystem in exchange for stronger compile-time guarantees than TypeScript's structural, optional type system provides.
Key Features
- Purely functional with immutability and referential transparency by default
- Strong, sound static type system based on Hindley-Milner inference with type classes
- Compiles to small, readable, and debuggable JavaScript
- Strict (non-lazy) evaluation, unlike Haskell
- Explicit effect tracking via the Effect and Aff monads
- Row polymorphism enabling flexible, type-safe extensible records
- Foreign Function Interface for interop with existing JavaScript/TypeScript code
- Functional UI frameworks such as Halogen and Thermite for web development
Use Cases
Alternatives
History
PureScript was designed by Phil Freeman and first released in late 2013. It is a strongly typed, purely functional language whose syntax is closely comparable to Haskell and which transpiles to readable JavaScript (with community backends targeting other platforms). Freeman created it out of dissatisfaction with earlier attempts to run Haskell in the browser, aiming instead for a small language well suited to building domain-specific languages using type-system features — algebraic data types and extensible records — that were unavailable in many other compile-to-JavaScript languages of the time. PureScript has since grown a substantial package ecosystem and remains a reference point for pure functional programming on the web.
Sources
- SurviveJS — interview with PureScript creator Phil Freeman · as of 2026-07-17
- PureScript on GitHub — purescript/purescript · as of 2026-07-17