PureScript

Source: Wikipedia, the free encyclopedia.
PureScript
ParadigmFunctional
Designed byPhil Freeman
First appeared2013
Stable release
0.15.15 Edit this on Wikidata / 7 February 2024; 2 months ago (7 February 2024)
Haskell, JavaScript

PureScript is a

Haskell. In addition, it introduces row polymorphism and extensible records.[6] Also, contrary to Haskell, the PureScript language is defined as having a strict evaluation strategy,[7] although there are non-conforming back ends which implement a lazy evaluation strategy.[8]

History

PureScript was initially designed by Phil Freeman in 2013. He started to work on PureScript since he wasn't satisfied by other attempts to transpile Haskell to JavaScript (e.g. using Fay, Haste, or GHCJS).[9]

Since then it has been picked up by the community and is developed on GitHub. Additional core tools developed by the community include the dedicated build tool "Pulp",[10] the documentation directory "Pursuit",[11] and the package manager "Spago"[12]

Features

PureScript features

higher-rank polymorphism. PureScript's type system adds support for row polymorphism and extensible records.[13] However, PureScript lacks support for some of the more advanced features of Haskell like GADTs and type families
.

The PureScript transpilers attempt to produce readable code, where possible. Through a simple FFI interface, it also allows the reuse of existing JavaScript[14]/C++11[15][16]/Go[17] code.

PureScript supports

source code editor plugins for iterative development.[18] Editor plugins exist for many popular text editors, including Vim, Emacs, Sublime Text, Atom and Visual Studio Code
.

PureScript supports

Haskell compiler.[20]

Examples

Here is a minimal "Hello world" 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

References

  1. ^ "purescript/purescript". GitHub. 3 June 2022.
  2. ^ "PureScript to JavaScript transpiler". GitHub. Retrieved 2023-01-22.
  3. ^ "PureScript to C++11 transpiler". GitHub. Retrieved 2023-01-22.
  4. ^ purerl - the PureScript Erlang backend, purerl, 2023-09-04, retrieved 2023-09-05
  5. ^ "PureScript to Go transpiler". GitHub. Retrieved 2023-01-22.
  6. ^ "PureScript". purescript.org. Retrieved 2019-03-14.
  7. ^ purescript/documentation, PureScript, 2023-02-19, retrieved 2023-02-20
  8. ^ Alternative backends, PureScript, 2023-02-19, retrieved 2023-02-20
  9. ^ "Read PureScript by Example | Leanpub". leanpub.com. Retrieved 2019-03-14.
  10. ^ A build tool for PureScript projects, PureScript Contrib, 2019-03-08, retrieved 2019-03-14
  11. ^ "Pursuit". pursuit.purescript.org. Retrieved 2019-03-14.
  12. ^ 🍝 PureScript package manager and build tool powered by Dhall and package-sets: spacchetti/spago, spacchetti, 2019-03-14, retrieved 2019-03-14
  13. ^ Documentation for the PureScript language, compiler, and tools.: purescript/documentation, PureScript, 2019-03-14, retrieved 2019-03-14
  14. ^ "The Foreign Function Interface". PureScript. 2015-07-15. Retrieved 2023-01-22.
  15. ^ "FFI". PureScript. 2019-07-26. Retrieved 2023-01-22.
  16. ^ C++ foreign export implementations for the standard library, PureScript, 2019-07-26, retrieved 2023-01-22
  17. ^ "Go foreign export implementations for the standard library". PureScript. 2020-12-13. Retrieved 2023-01-22.
  18. ^ purs ide: Editor and tooling support for the PureScript programming language, 2019-04-21, retrieved 2019-04-21
  19. ^ Implementing type directed search for PureScript, 2016-10-27
  20. S2CID 218480974

External links