Purescript

PureScript is a strongly-typed, purely-functional programming language that transpiles to JavaScript, C++11, Erlang, and Go.

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. In addition, it introduces row polymorphism and extensible records. Also, contrary to Haskell, the PureScript language is defined as having a strict evaluation strategy, although there are non-conforming back ends which implement a lazy evaluation strategy.

PureScript
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)
Typing disciplineInferred, static, strong
LicenseBSD
Filename extensions.purs
Websitewww.purescript.org Edit this at Wikidata
Influenced by
Haskell, JavaScript

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).

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", the documentation directory "Pursuit", and the package manager "Spago"

Features

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. 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/C++11/Go code.

PureScript supports incremental compilation, and the transpiler to JavaScript distribution includes support for building source code editor plugins for iterative development. 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, 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 has inspired similar work in the GHC Haskell compiler.

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

Tags:

Purescript HistoryPurescript FeaturesPurescript ExamplesPurescriptC++11Electron (software framework)Erlang (programming language)Evaluation strategyGo (programming language)Haskell (programming language)Hugs (interpreter)JavaScriptProgramming languagePurely functional programmingRow polymorphismSource-to-source compilerStrongly-typed

🔥 Trending searches on Wiki English:

CaliforniaCreed III2023 Azerbaijan Grand PrixNapoleonRussiaMicrodata (HTML)Wes AndersonGervonta DavisRishi SunakWoody HarrelsonRobyn CrawfordXXXTentacionJavaScriptPolite Society (film)Mani Ratnam filmography123MoviesVirat KohliDaisy Jones & The SixPinkerton (detective agency)James GunnFranz StiglerBrownie (folklore)EFL League TwoM3GANAto EssandohMani RatnamTwisted MetalKrysten RitterAlyssa SutherlandVarginha UFO incident95th Academy AwardsA.C. MilanRoy HodgsonJennifer LawrenceMark Allen (snooker player)BangladeshC. J. StroudEnglandCherManchester City F.C.Eden GardensFreddie MercuryIrrfan KhanJayden ReedMother's DayOrlando BloomJake GyllenhaalChristian BaleEver AndersonCharlie Brown and Franz Stigler incidentSobhita DhulipalaDarnell WashingtonYellowjackets (TV series)Temple GrandinRobert LewandowskiCarlos AlcarazFootball at the 2023 Southeast Asian Games – Men's tournamentMrs. DavisKirsten DunstCrystal Palace F.C.John Michael SchmitzDwyane WadeDesi LydicJake MoodySouth KoreaSpainSuccession (TV series)C (programming language)Candy (miniseries)Joe PesciMike TysonPete DavidsonJamie FoxxBarry (TV series)Dheekshith ShettyPriyanka ChopraMary-Kate OlsenInterstellar (film)🡆 More