# PureScript

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/PureScript
> Markdown URL: https://mediated.wiki/source/PureScript.md
> Source: https://en.wikipedia.org/wiki/PureScript
> Source revision: 1354219846
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Strongly typed language that compiles to JavaScript

This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: "PureScript" – news · newspapers · books · scholar · JSTOR (August 2019) (Learn how and when to remove this message)

PureScript Show dark mode version of file Show light mode version of file Paradigm functional Family Haskell Designed by Phil Freeman First appeared 2013; 13 years ago (2013) Stable release 0.15.16 / 15 March 2026; 3 months ago (15 March 2026) Typing discipline Inferred, static, strong License BSD 3-clause[1] Filename extensions .purs Website www.purescript.org Influenced by Haskell, JavaScript

**PureScript** is a [strongly typed](/source/Strong_and_weak_typing), [purely functional](/source/Purely_functional_programming) [programming language](/source/Programming_language) that [transpiles](/source/Source-to-source_compiler) to [JavaScript](/source/JavaScript)[2] and, with alternate backends, to [C++11](/source/C%2B%2B11),[3] [Erlang](/source/Erlang_(programming_language)),[4] and [Go](/source/Go_(programming_language)).[5] It can be used to develop web applications, server side apps, and also desktop applications with use of [Electron](/source/Electron_(software_framework)) or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that of [Haskell](/source/Haskell). Also, it introduces [row polymorphism](/source/Row_polymorphism) and [extensible records](/source/Hugs_(interpreter)).[6] Also, contrary to Haskell, the PureScript language is defined as having a [strict evaluation strategy](/source/Evaluation_strategy#Strict_evaluation),[7] although there are non-conforming back-ends which implement a [lazy evaluation strategy](/source/Evaluation_strategy#Non-strict_evaluation).[8] It is [free and open-source software](/source/Free_and_open-source_software) released under a [BSD 3-clause](/source/BSD_licenses#3-clause) license.

## History

PureScript was initially designed by Phil Freeman in 2013. He began work on it because he was unsatisfied by other attempts to transpile Haskell to JavaScript (e.g., using Fay, Haste, or GHCJS).[9]

Since then it has been adopted by the community and is developed on [GitHub](/source/GitHub). Further community-developed core tools include the dedicated build tool *Pulp*,[10] the documentation directory *Pursuit*,[11] and the package manager *Spago*.[12]

## Features

PureScript features [strict evaluation](/source/Eager_evaluation), [persistent data structures](/source/Persistent_data_structures), and [type inference](/source/Type_inference). Its [data type](/source/Data_type) system shares many features with those of similar functional languages like [Haskell](/source/Haskell): [algebraic data types](/source/Algebraic_data_type) and [pattern matching](/source/Pattern_matching), [higher kinded types](/source/Kind_(type_theory)), [type classes](/source/Type_class), [functional dependencies](/source/Type_class#Functional_dependencies), and [higher-rank polymorphism](/source/Polymorphism_(computer_science)#Rank_polymorphism). Its type system adds support for [row polymorphism](/source/Row_polymorphism) and extensible records,[13] but does not support some of the more advanced features of Haskell such as the [generalized algebraic data type](/source/Generalized_algebraic_data_type) (GADT) and the [type family](/source/Type_family).

The PureScript transpilers attempt to produce readable code, where possible. Through a simple [foreign function interface](/source/Foreign_function_interface) (FFI), it also allows [code reuse](/source/Code_reuse) of extant [source code](/source/Source_code) in JavaScript,[14] C++11,[15][16] and Go,[17] usually as an [intermediate representation](/source/Intermediate_representation).

PureScript supports [incremental compilation](/source/Incremental_compiler), and the transpiler to JavaScript distribution supports building [source-code editor](/source/Source-code_editor) [plug-ins](/source/Plug-in_(computing)) for iterative development.[18] Editor plug-ins exist for many popular text editors, including [Vim](/source/Vim_(text_editor)), [Emacs](/source/Emacs), [Sublime Text](/source/Sublime_Text), [Atom](/source/Atom_(text_editor)) and [Visual Studio Code](/source/Visual_Studio_Code).

PureScript supports [type-driven development](https://en.wikipedia.org/w/index.php?title=Type-driven_development&action=edit&redlink=1) via its [typed holes](https://en.wikipedia.org/w/index.php?title=Typed_holes&action=edit&redlink=1) feature,[19] in which a program can be constructed with missing subexpressions. The JavaScript transpiler will subsequently attempt to infer the types of the missing subexpressions, and report those types to the user. This feature inspired similar work in the [Glasgow Haskell Compiler](/source/Glasgow_Haskell_Compiler) (GHC).[20]

## Examples

Here is a minimal ["Hello, World!" program](/source/%22Hello%2C_World!%22_program) in PureScript:

module Main where

import Effect.Console (log)

main = log "Hello World!"

Here, the type of the program is inferred and checked by the PureScript transpiler. A more verbose version of the same program might include explicit type annotations:

module Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)

main :: Effect Unit
main = log "Hello World!"

## See also

- [Free and open-source software portal](https://en.wikipedia.org/wiki/Portal:Free_and_open-source_software)

- [Elm (programming language)](/source/Elm_(programming_language)) – Functional programming language

- [Reason (programming language)](/source/Reason_(programming_language)) – Syntax extension and toolchain for OCaml

- [JS++](/source/JS%2B%2B) – Web programming language

- [TypeScript](/source/TypeScript) – Programming language and superset of JavaScript

## References

1. **[^](#cite_ref-license_1-0)** ["purescript/purescript"](https://github.com/purescript/purescript/blob/master/LICENSE). *GitHub*. 3 June 2022.

1. **[^](#cite_ref-2)** ["PureScript to JavaScript transpiler"](https://github.com/purescript/purescript). *[GitHub](/source/GitHub)*. Retrieved 2023-01-22.

1. **[^](#cite_ref-3)** ["PureScript to C++11 transpiler"](https://github.com/andyarvanitis/purescript-native/tree/cpp). *[GitHub](/source/GitHub)*. Retrieved 2023-01-22.

1. **[^](#cite_ref-4)** [*purerl - the PureScript Erlang backend*](https://github.com/purerl/purerl), purerl, 2023-09-04, retrieved 2023-09-05

1. **[^](#cite_ref-5)** ["PureScript to Go transpiler"](https://github.com/andyarvanitis/purescript-native). *[GitHub](/source/GitHub)*. Retrieved 2023-01-22.

1. **[^](#cite_ref-6)** ["PureScript"](https://purescript.org/). *purescript.org*. Retrieved 2019-03-14.

1. **[^](#cite_ref-7)** ["purescript/documentation"](https://github.com/purescript/documentation/blob/ddc83562aa1de9d4e2c1067c71bf3d4e3b77b84d/language/Differences-from-Haskell.md). PureScript. 2023-02-19. Retrieved 2023-02-20.

1. **[^](#cite_ref-8)** [*Alternative backends*](https://github.com/purescript/documentation/blob/ddc83562aa1de9d4e2c1067c71bf3d4e3b77b84d/ecosystem/Alternate-backends.md), PureScript, 2023-02-19, retrieved 2023-02-20

1. **[^](#cite_ref-9)** ["Read PureScript by Example"](https://leanpub.com/purescript/read#leanpub-auto-about-the-author). *Leanpub.com*. Retrieved 2019-03-14.

1. **[^](#cite_ref-10)** [*A build tool for PureScript projects*](https://github.com/purescript-contrib/pulp), PureScript Contrib, 2019-03-08, retrieved 2019-03-14

1. **[^](#cite_ref-11)** ["Pursuit"](https://pursuit.purescript.org/). *pursuit.purescript.org*. Retrieved 2019-03-14.

1. **[^](#cite_ref-12)** [*PureScript package manager and build tool powered by Dhall and package-sets: spacchetti/spago*](https://github.com/spacchetti/spago), spacchetti, 2019-03-14, retrieved 2019-03-14

1. **[^](#cite_ref-13)** ["Documentation for the PureScript language, compiler, and tools: purescript/documentation"](https://github.com/purescript/documentation). PureScript. 2019-03-14. Retrieved 2019-03-14.

1. **[^](#cite_ref-14)** ["The Foreign Function Interface"](https://github.com/purescript/documentation/blob/master/guides/FFI.md). PureScript. 2015-07-15. Retrieved 2023-01-22.

1. **[^](#cite_ref-15)** ["FFI"](https://github.com/andyarvanitis/purescript-native/wiki/FFI). PureScript. 2019-07-26. Retrieved 2023-01-22.

1. **[^](#cite_ref-16)** [*C++ foreign export implementations for the standard library*](https://github.com/andyarvanitis/purescript-native-cpp-ffi), PureScript, 2019-07-26, retrieved 2023-01-22

1. **[^](#cite_ref-17)** ["Go foreign export implementations for the standard library"](https://github.com/andyarvanitis/purescript-native-go-ffi). PureScript. 2020-12-13. Retrieved 2023-01-22.

1. **[^](#cite_ref-18)** Hegemann, Christoph (kritzcreek) (2019-04-21). ["purs ide: Editor and tooling support for the PureScript programming language"](https://github.com/purescript/purescript/tree/dfbd19da85c92d82ed4c3184f950f74da5332e3f/psc-ide). Retrieved 2019-04-21.

1. **[^](#cite_ref-19)** Hegemann, Christoph (2016-10-27). *Implementing type directed search for PureScript* (B.Sc. thesis).

1. **[^](#cite_ref-20)** Gissurarson, Matthías Páll (2018-09-27). ["Suggesting Valid Hole Fits for Typed-Holes (Experience Report)"](https://dl.acm.org/citation.cfm?id=3242760). *ACM SIGPLAN Notices*. **53** (7): 179–185. [doi](/source/Doi_(identifier)):[10.1145/3299711.3242760](https://doi.org/10.1145%2F3299711.3242760). [S2CID](/source/S2CID_(identifier)) [218480974](https://api.semanticscholar.org/CorpusID:218480974).

## External links

- [Official website](https://www.purescript.org/)

- [PureScript Playground](https://try.purescript.org)

v t e Haskell programming Software Implementations (features) Generic Haskell° Glasgow Haskell Compiler° Template Haskell° Gofer° → Hugs° York Haskell Compiler° (Yhc) Dialects Agda° Cryptol° Curry° Elm° Hume° Idris° Ωmega° Orwell° Pugs° PureScript° TidalCycles° Ur° Electronic design Atom° Bluespec SystemVerilog (BSV) Libraries Concurrent Haskell° Haskell Platform° Parsec° QuickCheck° Package managers Cabal° Stack° Windowing systems Fudgets wxHaskell° xmonad° Web frameworks Servant° Snap° Yesod° Cardano° Darcs° Ganeti° git-annex° Haddock° HaXml° Liquid Haskell° LOLITA Pandoc° Paradox° SQream DB Book Real World Haskell Community Eponym Haskell Curry Arvind Lennart Augustsson Richard Bird Jeremy Gibbons Andrew D. Gordon Paul Hudak John Hughes John Launchbury John MacFarlane Simon Marlow Conor McBride Erik Meijer Simon Peyton Jones David Roundy Joe Stoy Audrey Tang Simon Thompson Philip Wadler Italics = discontinued • ° = Open-source software Book Categories: Family • Software

v t e Programming languages Comparison Timeline History Ada ALGOL Simula APL Assembly BASIC Visual Basic classic .NET C C++ C# COBOL Erlang Elixir Forth Fortran Go Haskell Java JavaScript Julia Kotlin Lisp Lua MATLAB ML Caml OCaml Standard ML Pascal Object Pascal Perl Raku PHP Prolog Python R Ruby Rust SAS SQL Scratch Shell Smalltalk Swift more... Lists: Alphabetical Categorical Generational Non-English-based Category

---
Adapted from the Wikipedia article [PureScript](https://en.wikipedia.org/wiki/PureScript) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/PureScript?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
