Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

PureScript

From Wikipedia, the free encyclopedia
Strongly typed language that compiles to JavaScript
icon
This articlerelies excessively onreferences toprimary sources. Please improve this article by addingsecondary or tertiary sources.
Find sources: "PureScript" – news ·newspapers ·books ·scholar ·JSTOR
(August 2019) (Learn how and when to remove this message)
PureScript
Paradigmfunctional
FamilyHaskell
Designed byPhil Freeman
First appeared2013; 13 years ago (2013)
Stable release
0.15.15 Edit this on Wikidata / 7 February 2024; 2 years ago (7 February 2024)
Typing disciplineInferred,static,strong
LicenseBSD 3-clause[1]
Filename extensions.purs
Websitewww.purescript.orgEdit this at Wikidata
Influenced by
Haskell,JavaScript

PureScript is astrongly typed,purely functionalprogramming language thattranspiles toJavaScript[2] and, with alternate backends, toC++11,[3]Erlang,[4] andGo.[5] It can be used to develop web applications, server side apps, and also desktop applications with use ofElectron or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that ofHaskell. Also, it introducesrow polymorphism andextensible records.[6] Also, contrary to Haskell, the PureScript language is defined as having astrict evaluation strategy,[7] although there are non-conforming back-ends which implement alazy evaluation strategy.[8] It isfree and open-source software released under aBSD 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 onGitHub. Further community-developed core tools include the dedicated build toolPulp,[10] the documentation directoryPursuit,[11] and the package managerSpago.[12]

Features

[edit]

PureScript featuresstrict evaluation,persistent data structures, andtype inference. Itsdata type system shares many features with those of similar functional languages likeHaskell:algebraic data types andpattern matching,higher kinded types,type classes,functional dependencies, andhigher-rank polymorphism. Its type system adds support forrow polymorphism and extensible records,[13] but does not support some of the more advanced features of Haskell such as thegeneralized algebraic data type (GADT) and thetype family.

The PureScript transpilers attempt to produce readable code, where possible. Through a simpleforeign function interface (FFI), it also allowscode reuse of extantsource code in JavaScript,[14] C++11,[15][16] and Go,[17] usually as anintermediate representation.

PureScript supportsincremental compilation, and the transpiler to JavaScript distribution supports buildingsource-code editorplug-ins for iterative development.[18] Editor plug-ins exist for many popular text editors, includingVim,Emacs,Sublime Text,Atom andVisual Studio Code.

PureScript supportstype-driven development via itstyped 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 theGlasgow Haskell Compiler (GHC).[20]

Examples

[edit]

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

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

moduleMainwhereimportPreludeimportEffect(Effect)importEffect.Console(log)main::EffectUnitmain=log"Hello World!"

See also

[edit]

References

[edit]
  1. ^"purescript/purescript".GitHub. 3 June 2022.
  2. ^"PureScript to JavaScript transpiler".GitHub. Retrieved2023-01-22.
  3. ^"PureScript to C++11 transpiler".GitHub. Retrieved2023-01-22.
  4. ^purerl - the PureScript Erlang backend, purerl, 2023-09-04, retrieved2023-09-05
  5. ^"PureScript to Go transpiler".GitHub. Retrieved2023-01-22.
  6. ^"PureScript".purescript.org. Retrieved2019-03-14.
  7. ^"purescript/documentation". PureScript. 2023-02-19. Retrieved2023-02-20.
  8. ^Alternative backends, PureScript, 2023-02-19, retrieved2023-02-20
  9. ^"Read PureScript by Example".Leanpub.com. Retrieved2019-03-14.
  10. ^A build tool for PureScript projects, PureScript Contrib, 2019-03-08, retrieved2019-03-14
  11. ^"Pursuit".pursuit.purescript.org. Retrieved2019-03-14.
  12. ^PureScript package manager and build tool powered by Dhall and package-sets: spacchetti/spago, spacchetti, 2019-03-14, retrieved2019-03-14
  13. ^"Documentation for the PureScript language, compiler, and tools: purescript/documentation". PureScript. 2019-03-14. Retrieved2019-03-14.
  14. ^"The Foreign Function Interface". PureScript. 2015-07-15. Retrieved2023-01-22.
  15. ^"FFI". PureScript. 2019-07-26. Retrieved2023-01-22.
  16. ^C++ foreign export implementations for the standard library, PureScript, 2019-07-26, retrieved2023-01-22
  17. ^"Go foreign export implementations for the standard library". PureScript. 2020-12-13. Retrieved2023-01-22.
  18. ^Hegemann, Christoph (kritzcreek) (2019-04-21)."purs ide: Editor and tooling support for the PureScript programming language". Retrieved2019-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.

External links

[edit]
Haskell programming
Software
Implementations
(features)
Dialects
Electronic
design
Libraries
Package managers
Windowing systems
Web frameworks
Book
Community
Eponym
Italics= discontinued° =Open-source software
BookCategories:FamilySoftware
Retrieved from "https://en.wikipedia.org/w/index.php?title=PureScript&oldid=1328690787"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp