Jump to content
Wikipedia The Free Encyclopedia

PureScript

From Wikipedia, the free encyclopedia
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
Paradigm functional
FamilyHaskell
Designed by Phil Freeman
First appeared2013; 12 years ago (2013)
Stable release
0.15.15 Edit this on Wikidata / 7 February 2024; 20 months ago (7 February 2024)
Typing discipline Inferred, static, strong
License BSD 3-clause [1]
Filename extensions .purs
Websitewww.purescript.org Edit this at Wikidata
Influenced by
Haskell, JavaScript

PureScript is a strongly typed, purely functional programming language that transpiles to JavaScript,[2] C++11,[3] Erlang,[4] and Go.[5] It can be used to develop web applications, server side apps, and also desktop applications with use of Electron or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that of Haskell. Also, 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] It is free and open-source software released under a BSD 3-clause license.

History

[edit ]

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. Further community-developed core tools include the dedicated build tool Pulp,[10] the documentation directory Pursuit,[11] and the package manager Spago.[12]

Features

[edit ]

PureScript features strict evaluation, persistent data structures, and type inference. Its data type system shares many features with those of similar functional languages like Haskell: algebraic data types and pattern matching, higher kinded types, type classes, functional dependencies, and higher-rank polymorphism. Its type system adds support for 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 (GADT) and the type family.

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

PureScript supports incremental compiling, and the transpiler to JavaScript distribution supports building source-code editor plug-ins for iterative development.[18] Editor plug-ins 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,[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 (GHC).[20]

Examples

[edit ]

Here is a minimal "Hello, World!" program in PureScript:

moduleMainwhere

importEffect.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:

moduleMainwhere

importPrelude

importEffect(Effect)
importEffect.Console(log)

main::EffectUnit
main=log"Hello World!"

See also

[edit ]

References

[edit ]
  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.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. ^ Hegemann, Christoph (kritzcreek) (2019年04月21日). "purs ide: Editor and tooling support for the PureScript programming language" . Retrieved 2019年04月21日.
  19. ^ Hegemann, Christoph (2016年10月27日). Implementing type directed search for PureScript (B.Sc. thesis).
  20. ^ Gissurarson, Matthías Páll (2018年09月27日). "Suggesting Valid Hole Fits for Typed-Holes (Experience Report)" . ACM SIGPLAN Notices. 53 (7): 179–185. doi:10.1145/3299711.3242760. S2CID 218480974.
[edit ]
Haskell programming
Software
Implementations
(features)
Dialects
Electronic
design
Libraries
Package managers
Windowing systems
Web frameworks
Book
Community
Eponym

AltStyle によって変換されたページ (->オリジナル) /