PROVIDER - a strongly typed functional language compiled to JavaScript

PureScript

PureScript was created by Phil Freeman in 2013 with Haskell-like syntax compiled to JavaScript, using type classes and row types to stop errors at compile time, and 1 FFI declaration to bind an existing JS library; conceptual depth, output size and a small community are the cost.

Programming Languages & Frameworks United States 2026.11.19
3.2pts

Detailed Notes

Pros 5 items

Created by Phil Freeman in 2013 with Haskell-like syntax and JavaScript as the compilation target
Supports type classes, row types and higher-rank polymorphism, so 1 type system excludes most runtime errors at compile time
FFI needs only 1 JavaScript declaration per foreign function, keeping adoption of existing JS libraries cheap
The companion Halogen framework provides 1 unidirectional pure-functional UI model
Official package sets pin an entire dependency set through 1 manifest, preventing combination drift

Cons 4 items

A steep curve that starts with type classes, functors and monads
Output size and build times both exceed TypeScript
A small community and hiring pool concentrated in functional circles
Complex toolchain setup, with FFI and bundling requiring extra upkeep

Service Overview

PureScript was created by Phil Freeman in 2013 as a strongly typed purely functional language that compiles to JavaScript. Its syntax and philosophy follow Haskell, with some heavyweight features dropped and the JavaScript runtime in mind.

In the languages and frameworks category it takes the maximal route on frontend typing: more annotations in exchange for catching errors before they ship.

Key Strengths

  • Expressive type system: type classes, row types and higher-rank polymorphism cover sophisticated abstractions
  • Compile-time safety: effects are marked with Effect, so pure functions cannot leak side effects
  • Concise FFI: 1 declaration per foreign function is enough to bind it
  • No runtime dependency: output is plain JavaScript that drops into an existing build chain
  • Reproducible dependencies: package sets pin whole versions so team environments match

Product Ecosystem

Language and compiler

The PureScript compiler, the spago build tool and the Pursuit documentation site form the base toolchain.

Frameworks and libraries

Halogen supplies a UI component model, purescript-aff handles asynchrony, and purescript-foreign covers decoding.

Tooling

purs-tidy formats code, and editors get completion and type hints through a language server.

Limitations

  • Conceptual barrier: type classes and monads need systematic study
  • Build cost: compile time and bundle size exceed TypeScript
  • Scarce talent: the community is small, making hiring and handover harder
  • Setup complexity: FFI, bundling and editor integration need extra work

Use Cases

  • Frontends with complex business rules (★★★★): type constraints cut regression defects sharply
  • Finance and data-dense interfaces (★★★★): numeric and state modelling pays off
  • Teams already functional (★★★★): the frontend shares one type mindset with the back end
  • Rapid prototypes and small pages (★★): TypeScript is faster

Pricing

Item Price Notes
PureScript compiler $0 Open source, installed from npm or binaries
spago and package sets $0 Free to use
Learning material From $0 Official docs are free, books and courses are optional

Language and tools are free; the cost is the team learning curve and build time.

FAQ

  • PureScript or TypeScript? Choose PureScript for maximal type guarantees and purely functional style, and TypeScript for ecosystem reach and hiring supply.
  • Does it work with React? Yes, either through FFI wrappers or by using Halogen instead; bindings such as react-basic also exist.
  • Why is the output large? The runtime library and type class dictionaries add code, which dead-code elimination and bundlers compress. See the comparison under languages and frameworks.

Code Examples

Summing through a type class

module Main where

import Prelude
import Data.Foldable (sum)

total :: Array Int -> Int
total xs = sum xs

main :: Effect Unit
main = logShow (total [1, 2, 3, 4])

sum relies on the Additive type class, Array Int satisfies it, and Effect Unit marks main as effectful.

Row types describing records

type User = { id :: Int, name :: String }

greet :: forall r. { name :: String | r } -> String
greet user = "Hello, " <> user.name

sample :: String
sample = greet { id = 1, name = "Ada", admin = true }

{ name :: String | r } accepts any record containing a name field, so extra fields do not break the call.

Community & Resources

Visit PureScript Website → https://www.purescript.org/
Visit Website ↗