This article relies too much on references to primary sources. (August 2019) |
Paradigm | Functional |
---|---|
Designed by | Phil Freeman |
First appeared | 2013 |
Stable release | 0.14.0
/ March 1, 2021 |
Typing discipline | Inferred, static, strong |
License | BSD[1] |
Filename extensions | .purs |
Website | www.purescript.org |
Influenced by | |
Haskell, JavaScript |
PureScript is a strongly-typed, purely-functional programming language that compiles to JavaScript. It can be used to develop web applications, server side apps, and also desktop applications with use of Electron. Its syntax is mostly comparable to that of Haskell. In addition, it introduces row polymorphism and extensible records.[2] Also, contrary to Haskell, PureScript adheres to a strict evaluation strategy.
PureScript was initially designed by Phil Freeman in 2013. He started to work on PureScript since he wasn't satisfied by other attempts to compile Haskell to JavaScript (e.g. using Fay, Haste, or GHCJS).[3]
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",[4] the documentation directory "Pursuit",[5] and the package manager "Spago"[6]
PureScript features strict evaluation, persistent data structures and type inference. The PureScript type system shares many features with those of similar functional languages like Haskell: algebraic data types and pattern matching, higher kinded types, type classes and functional dependencies, and higher-rank polymorphism. PureScript's type system adds support for row polymorphism and extensible records.[7] However, PureScript lacks support for some of the more advanced features of Haskell like GADTs and type families.
The PureScript compiler attempts to produce readable JavaScript code, where possible. Through a simple FFI interface, it also allows the reuse of existing JavaScript code.[8]
PureScript supports incremental compilation, and the compiler distribution includes support for building source code editor plugins for iterative development.[9] Editor plugins exist for many popular text editors, including Vim, Emacs, Sublime Text, Atom and Visual Studio Code.
PureScript supports type-driven development via its typed holes feature,[10] in which a program can be constructed with missing subexpressions. The compiler will subsequently attempt to infer the types of the missing subexpressions, and report those types to the user. This feature has inspired similar work in the GHC Haskell compiler.[11]
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 compiler. 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!"
By: Wikipedia.org
Edited: 2021-06-18 12:36:33
Source: Wikipedia.org