-
Notifications
You must be signed in to change notification settings - Fork 562
Wikipedia Page Proposal
https://en.wikipedia.org/wiki/User:Dnalot/PureScript
PureScript is a strict, purely functional, modular (no runtime dependency), programming language inspired by Haskell which compiles to readable JavaScript with a nominal foreign function interface.
PureScript was created by Phil Freeman in 2013. talk about making a language with Haskell type system features and ex. records, designed for compilation to JS.
The initial goal was to create a small language which could be used to create domain specific languages, using type system features which were unavailable in many other AltJS languages (algebraic data types, extensible records).
You'd did a much better job explaining on JavaScript Jabber. Could you adapt the transcript from there? You also make no mention of positive language influences which would provide valuable backlinks.
The PureScript compiler and its standard libraries are currently maintained by Phil Freeman and Gary Burgess.
Historical note: first SlamData PS commit on May 9, 2014 (https://github.com/slamdata/slamdata-nodewebkit/commit/73e3c9d5710ebf21552699e6bbe87f412171aec8)
The PureScript community maintains a collection of standard libraries, which aim for compatibility with the compiler.
You mentioned making this its own section. I can add it to Tools.
In 2015, PureScript took part in the Google Summer of Code program, resulting in two successful projects - a database of PureScript libraries and documentation with type-directed search, and the addition of an exhaustivity and redundancy analysis pass to the compiler.
PureScript Conf 2015 was the first conference devoted to the PureScript language, with the 2016 edition scheduled for May 2016. A book on the language was released in 2015.
module Main where
import Control.Monad.Eff.Console (log)
main = log "Hello, World!"
I'd prefer two examples (backed up in Gist for http://try.purescript.org):
- Simple HTML output (using either DOM or Thermite instead of console)
- Simple algorithm (like binary search, quick sort, or Fibonacci)
PureScript features algebraic data types, using a syntax similar to that of Haskell:
data List a = Nil | Cons a (List a)
PureScript types are inferred by the compiler, based on the types of subexpressions. For example:
map f Nil = Nil
map f (Cons x xs) = Cons (f x) (map f xs)
Here, the type of f
does not need to be specified. PureScript will infer the correct type forall a b. (a -> b) -> List a -> List b
.
The PureScript compiler provides warnings when type signatures are not provided on top-level declarations, encouraging users to provide types as a form of documentation.
PureScript supports type classes using a dictionary-passing transformation.
For example, a type class for types with decidable equality is defined in the Prelude library:
class Eq a where
eq :: a -> a -> Bool
PureScript functions which are constrained by the Eq
class are compiled to JavaScript functions, with an additional function argument which carries the Eq
implementation as an object.
Type class instances are named in PureScript, using a double colon to separate an instance name from the instance head, as in a type declaration:
instance eqList :: Eq a => Eq (List a) where
eq Nil Nil = true
eq (Cons x xs) (Cons y ys) = x == y && xs == ys
eq _ _ = false
PureScript represents records using Javascript objects at runtime, and implements extensible records using row polymorphism.
For example, it is possible to write a PureScript function which extracts a name
value from any record with a name
property:
getName rec = rec.name
PureScript will infer the following type for getName
:
getName :: forall r a. { name :: a | r } -> a
getName rec = rec.name
The type signature indicates that not only the type of the name
field, but also the remaining fields in the record, are left polymorphic.
Row polymorphism is also used to implement features such as record updates.
PureScript makes use of row polymorphism to implement its effect system. PureScript's core libraries define the Eff
type constructor, which is used to represent effectful values. Eff
is parameterized by a row of effect labels, and row polymorphism is used to combine computations which make use of different combinations of effects.
For example, the PureScript compiler is able to infer the most general type of the following computation which makes use of the RANDOM
and CONSOLE
effects, even if the type signature is omitted:
printRandom :: forall eff. Eff ( random :: RANDOM
, console :: CONSOLE
| eff
) Unit
printRandom = do
n <- random
print n
Developers are able to define new effect types using the foreign function interface. It is possible to assert that a function only uses a specific set of effects by using a type signature.
PureScript supports generic programming using type classes and generic deriving. The Generic
type class can be defined for data types using the derive
keyword:
newtype Person = Person
{ name :: String
, location :: String
}
derive instance genericPerson :: Generic Person
A Generic
instance can be used to implement data-type generic functionality such as equality testing, comparison, pretty-printing, and JSON serialization and deserialization.
PureScript is designed specifically with compilation to Javascript in mind, and its Javascript interoperability is cited as one of PureScript's design goals, and one of its strengths.
Javascript functions can be used from PureScript by assigning types in foreign import
declarations:
module FFI.Example where
foreign import shout :: String -> String
Every module has an optional companion CommonJS module which contains its foreign function implementations. For example, the function defined above might be defined in a CommonJS module as follows:
// module FFI.Example
exports.shout = function(s) {
return s + "!";
};
Conversely, PureScript functions and values can be used from Javascript, since PureScript compiles to CommonJS modules. Developers of new foreign types are expected to document the representation of those types in Javascript.
The PureScript compiler generates CommonJS modules by default, but can also bundle JavaScript modules for use in the browser, including the removal of unused code.
The PureScript compiler distribution includes tools for generating documentation in Markdown, Ctags and Etags formats, as well as a custom format which is used by the Pursuit package database.
Plugins are available for many popular text editors, including Emacs, Vim, Atom, and Visual Studio Code, with features such as syntax highlighting, autocompletion, jump to error, and smart replace. The psc-ide project defines a JSON protocol so that editors can query program metadata in a standard way.
Mention Harry Garrood
Mention Bodil
Descending by rating (>100 stars)
Ascending by date:
Date | Individual | Group | Link |
---|---|---|---|
Apr 28, 2015 | Harry Garrood | Google Summer of Code | Pursuit enhancements |
Apr 28, 2015 | Nicolas Del Piano | Google Summer of Code | Exhaustiveness Checker for PureScript |
Jun 12, 2015 | Michal Srb | Imperial College London | Haskell-Like S-Expression-Based Language Designed for an IDE |
Aug 8, 2015 | Phil Freeman | self-published | Stack Safety for Free |
Date | Individual | Group | Link |
---|---|---|---|
Sep 22, 2014 | Sergio De Simone | InfoQ | PureScript: A Haskell-like Language that Compiles to JavaScript |
Sep 15, 2015 | Steven Proctor | Functional Geekery | Episode 26 |
Dec 9, 2015 | Joe Eames | JavaScript Jabber | PureScript with John A. De Goes and Phil Freeman |
Date | Individual | Group | Link |
---|---|---|---|
Sep 21, 2014 | Bodil Stokke | Strange Loop | PureScript (Maybe This Time We Get JavaScript Right) |
Jul 9, 2015 | Bodil Stokke | PolyConf | Post FRP Frontend Programming |
Jul 20, 2015 | Boros Márton | Open Academy | PureScript: the solution to the problem Javascript |
Oct 8, 2015 | Vagmi Mudumbai | FnConf | Pure functional programming in your browser & server with PureScript |
Oct 17, 2015 | Michael Ficarra | Lambda Jam | Getting Started With Purescript |
Oct 24, 2015 | Luis Vicente | Lambda World | Purify your Lambdas |
Nov 28, 2015 | Christoph Hegemann | f(by) | PureScript – Fearless Programming for the Web |
Dec 30, 2015 | John De Goes | LambdaConf | Learn Functional Programming with PureScript |
Dec 30, 2015 | Phil Freeman | LambdaConf | Purely Functional Web Apps using React and PureScript |
Do not meet notability criteria:
Date | Individual | Group | Link |
---|---|---|---|
Jul 22, 2015 | Tim Docker | FP-Syd | PureScript: An Overview for Haskellers |
Oct 22, 2015 | Taylor Fausak | OrgSync Dev Lunch & Learn | Better know a language: PureScript |
Nov 19, 2015 | Michael Trotter | Utah Haskell Meetup | Intro to PureScript |