Skip to content

PureScript

Yongku cho edited this page Jul 27, 2020 · 6 revisions

https://www.purescript.org/

A strongly-typed functional programming language that compiles to JavaScript

Benefis

  • Compile to readable JavaScript and reuse existing JavaScript code easily
  • An extensive collection of libraries for development of web applications, web servers, apps and more
  • Excellent tooling and editor support with instant rebuilds
  • An active community with many learning resources
  • Build real-world applications using functional techniques and expressive types, such as:
    • Algebraic data types and pattern matching
    • Row polymorphism and extensible records
    • Higher kinded types
    • Type classes with functional dependencies
    • Higher-rank polymorphism

PureScript By Example

https://book.purescript.org/chapter1.html

https://try.purescript.org/

Function

Functions can be defined at the top-level of a file by specifying arguments before the equals sign:

add :: Int -> Int -> Int
add x y = x + y

diamond operator (<>)

string concatenation uses the diamond operator (<>), instead of the plus operator like in JavaScript.

showAddress :: Address -> String
showAddress addr = addr.street <> ", " <>
                   addr.city <> ", " <>
                   addr.state
Clone this wiki locally