git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove docs after move to wiki
ff6430aPhil Freeman
docs/.gitignoredeleted−1
@@ -1 +0,0 @@
1−build
docs/Makefiledeleted−177
@@ -1,177 +0,0 @@
1−# Makefile for Sphinx documentation
2−#
3−
4−# You can set these variables from the command line.
5−SPHINXOPTS =
6−SPHINXBUILD = sphinx-build
7−PAPER =
8−BUILDDIR = build
9−
10−# User-friendly check for sphinx-build
11−ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12−$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13−endif
14−
15−# Internal variables.
16−PAPEROPT_a4 = -D latex_paper_size=a4
17−PAPEROPT_letter = -D latex_paper_size=letter
18−ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
19−# the i18n builder cannot share the environment and doctrees with the others
20−I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
21−
22−.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
23−
24−help:
25− @echo "Please use \`make <target>' where <target> is one of"
26− @echo " html to make standalone HTML files"
27− @echo " dirhtml to make HTML files named index.html in directories"
28− @echo " singlehtml to make a single large HTML file"
29− @echo " pickle to make pickle files"
30− @echo " json to make JSON files"
31− @echo " htmlhelp to make HTML files and a HTML help project"
32− @echo " qthelp to make HTML files and a qthelp project"
33− @echo " devhelp to make HTML files and a Devhelp project"
34− @echo " epub to make an epub"
35− @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
36− @echo " latexpdf to make LaTeX files and run them through pdflatex"
37− @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
38− @echo " text to make text files"
39− @echo " man to make manual pages"
40− @echo " texinfo to make Texinfo files"
41− @echo " info to make Texinfo files and run them through makeinfo"
42− @echo " gettext to make PO message catalogs"
43− @echo " changes to make an overview of all changed/added/deprecated items"
44− @echo " xml to make Docutils-native XML files"
45− @echo " pseudoxml to make pseudoxml-XML files for display purposes"
46− @echo " linkcheck to check all external links for integrity"
47− @echo " doctest to run all doctests embedded in the documentation (if enabled)"
48−
49−clean:
50− rm -rf $(BUILDDIR)/*
51−
52−html:
53− $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
54− @echo
55− @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
56−
57−dirhtml:
58− $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
59− @echo
60− @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
61−
62−singlehtml:
63− $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
64− @echo
65− @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
66−
67−pickle:
68− $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
69− @echo
70− @echo "Build finished; now you can process the pickle files."
71−
72−json:
73− $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
74− @echo
75− @echo "Build finished; now you can process the JSON files."
76−
77−htmlhelp:
78− $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
79− @echo
80− @echo "Build finished; now you can run HTML Help Workshop with the" \
81− ".hhp project file in $(BUILDDIR)/htmlhelp."
82−
83−qthelp:
84− $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
85− @echo
86− @echo "Build finished; now you can run "qcollectiongenerator" with the" \
87− ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
88− @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PureScript.qhcp"
89− @echo "To view the help file:"
90− @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PureScript.qhc"
91−
92−devhelp:
93− $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
94− @echo
95− @echo "Build finished."
96− @echo "To view the help file:"
97− @echo "# mkdir -p $$HOME/.local/share/devhelp/PureScript"
98− @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PureScript"
99− @echo "# devhelp"
100−
101−epub:
102− $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
103− @echo
104− @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
105−
106−latex:
107− $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
108− @echo
109− @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
110− @echo "Run \`make' in that directory to run these through (pdf)latex" \
111− "(use \`make latexpdf' here to do that automatically)."
112−
113−latexpdf:
114− $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
115− @echo "Running LaTeX files through pdflatex..."
116− $(MAKE) -C $(BUILDDIR)/latex all-pdf
117− @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
118−
119−latexpdfja:
120− $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
121− @echo "Running LaTeX files through platex and dvipdfmx..."
122− $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
123− @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
124−
125−text:
126− $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
127− @echo
128− @echo "Build finished. The text files are in $(BUILDDIR)/text."
129−
130−man:
131− $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
132− @echo
133− @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
134−
135−texinfo:
136− $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
137− @echo
138− @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
139− @echo "Run \`make' in that directory to run these through makeinfo" \
140− "(use \`make info' here to do that automatically)."
141−
142−info:
143− $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
144− @echo "Running Texinfo files through makeinfo..."
145− make -C $(BUILDDIR)/texinfo info
146− @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
147−
148−gettext:
149− $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
150− @echo
151− @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
152−
153−changes:
154− $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
155− @echo
156− @echo "The overview file is in $(BUILDDIR)/changes."
157−
158−linkcheck:
159− $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
160− @echo
161− @echo "Link check complete; look for any errors in the above output " \
162− "or in $(BUILDDIR)/linkcheck/output.txt."
163−
164−doctest:
165− $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
166− @echo "Testing of doctests in the sources finished, look at the " \
167− "results in $(BUILDDIR)/doctest/output.txt."
168−
169−xml:
170− $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
171− @echo
172− @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
173−
174−pseudoxml:
175− $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
176− @echo
177− @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
docs/source/conf.pydeleted−258
@@ -1,258 +0,0 @@
1−# -*- coding: utf-8 -*-
2−#
3−# PureScript documentation build configuration file, created by
4−# sphinx-quickstart on Wed Jan 22 22:04:23 2014.
5−#
6−# This file is execfile()d with the current directory set to its
7−# containing dir.
8−#
9−# Note that not all possible configuration values are present in this
10−# autogenerated file.
11−#
12−# All configuration values have a default; values that are commented out
13−# serve to show the default.
14−
15−import sys
16−import os
17−
18−# If extensions (or modules to document with autodoc) are in another directory,
19−# add these directories to sys.path here. If the directory is relative to the
20−# documentation root, use os.path.abspath to make it absolute, like shown here.
21−#sys.path.insert(0, os.path.abspath('.'))
22−
23−# -- General configuration ------------------------------------------------
24−
25−# If your documentation needs a minimal Sphinx version, state it here.
26−#needs_sphinx = '1.0'
27−
28−# Add any Sphinx extension module names here, as strings. They can be
29−# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30−# ones.
31−extensions = []
32−
33−# Add any paths that contain templates here, relative to this directory.
34−templates_path = ['_templates']
35−
36−# The suffix of source filenames.
37−source_suffix = '.rst'
38−
39−# The encoding of source files.
40−#source_encoding = 'utf-8-sig'
41−
42−# The master toctree document.
43−master_doc = 'index'
44−
45−# General information about the project.
46−project = u'PureScript'
47−copyright = u'2014, Phil Freeman'
48−
49−# The version info for the project you're documenting, acts as replacement for
50−# |version| and |release|, also used in various other places throughout the
51−# built documents.
52−#
53−# The short X.Y version.
54−version = '0.5.0'
55−# The full version, including alpha/beta/rc tags.
56−release = '0.5.0'
57−
58−# The language for content autogenerated by Sphinx. Refer to documentation
59−# for a list of supported languages.
60−#language = None
61−
62−# There are two options for replacing |today|: either, you set today to some
63−# non-false value, then it is used:
64−#today = ''
65−# Else, today_fmt is used as the format for a strftime call.
66−#today_fmt = '%B %d, %Y'
67−
68−# List of patterns, relative to source directory, that match files and
69−# directories to ignore when looking for source files.
70−exclude_patterns = []
71−
72−# The reST default role (used for this markup: `text`) to use for all
73−# documents.
74−#default_role = None
75−
76−# If true, '()' will be appended to :func: etc. cross-reference text.
77−#add_function_parentheses = True
78−
79−# If true, the current module name will be prepended to all description
80−# unit titles (such as .. function::).
81−#add_module_names = True
82−
83−# If true, sectionauthor and moduleauthor directives will be shown in the
84−# output. They are ignored by default.
85−#show_authors = False
86−
87−# The name of the Pygments (syntax highlighting) style to use.
88−pygments_style = 'sphinx'
89−
90−# A list of ignored prefixes for module index sorting.
91−#modindex_common_prefix = []
92−
93−# If true, keep warnings as "system message" paragraphs in the built documents.
94−#keep_warnings = False
95−
96−
97−# -- Options for HTML output ----------------------------------------------
98−
99−# The theme to use for HTML and HTML Help pages. See the documentation for
100−# a list of builtin themes.
101−html_theme = 'default'
102−
103−# Theme options are theme-specific and customize the look and feel of a theme
104−# further. For a list of options available for each theme, see the
105−# documentation.
106−#html_theme_options = {}
107−
108−# Add any paths that contain custom themes here, relative to this directory.
109−#html_theme_path = []
110−
111−# The name for this set of Sphinx documents. If None, it defaults to
112−# "<project> v<release> documentation".
113−#html_title = None
114−
115−# A shorter title for the navigation bar. Default is the same as html_title.
116−#html_short_title = None
117−
118−# The name of an image file (relative to this directory) to place at the top
119−# of the sidebar.
120−#html_logo = None
121−
122−# The name of an image file (within the static path) to use as favicon of the
123−# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
124−# pixels large.
125−#html_favicon = None
126−
127−# Add any paths that contain custom static files (such as style sheets) here,
128−# relative to this directory. They are copied after the builtin static files,
129−# so a file named "default.css" will overwrite the builtin "default.css".
130−html_static_path = ['_static']
131−
132−# Add any extra paths that contain custom files (such as robots.txt or
133−# .htaccess) here, relative to this directory. These files are copied
134−# directly to the root of the documentation.
135−#html_extra_path = []
136−
137−# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
138−# using the given strftime format.
139−#html_last_updated_fmt = '%b %d, %Y'
140−
141−# If true, SmartyPants will be used to convert quotes and dashes to
142−# typographically correct entities.
143−#html_use_smartypants = True
144−
145−# Custom sidebar templates, maps document names to template names.
146−#html_sidebars = {}
147−
148−# Additional templates that should be rendered to pages, maps page names to
149−# template names.
150−#html_additional_pages = {}
151−
152−# If false, no module index is generated.
153−#html_domain_indices = True
154−
155−# If false, no index is generated.
156−#html_use_index = True
157−
158−# If true, the index is split into individual pages for each letter.
159−#html_split_index = False
160−
161−# If true, links to the reST sources are added to the pages.
162−#html_show_sourcelink = True
163−
164−# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
165−#html_show_sphinx = True
166−
167−# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
168−#html_show_copyright = True
169−
170−# If true, an OpenSearch description file will be output, and all pages will
171−# contain a <link> tag referring to it. The value of this option must be the
172−# base URL from which the finished HTML is served.
173−#html_use_opensearch = ''
174−
175−# This is the file name suffix for HTML files (e.g. ".xhtml").
176−#html_file_suffix = None
177−
178−# Output file base name for HTML help builder.
179−htmlhelp_basename = 'PureScriptdoc'
180−
181−
182−# -- Options for LaTeX output ---------------------------------------------
183−
184−latex_elements = {
185−# The paper size ('letterpaper' or 'a4paper').
186−#'papersize': 'letterpaper',
187−
188−# The font size ('10pt', '11pt' or '12pt').
189−#'pointsize': '10pt',
190−
191−# Additional stuff for the LaTeX preamble.
192−#'preamble': '',
193−}
194−
195−# Grouping the document tree into LaTeX files. List of tuples
196−# (source start file, target name, title,
197−# author, documentclass [howto, manual, or own class]).
198−latex_documents = [
199− ('index', 'PureScript.tex', u'PureScript Documentation',
200− u'Phil Freeman', 'manual'),
201−]
202−
203−# The name of an image file (relative to this directory) to place at the top of
204−# the title page.
205−#latex_logo = None
206−
207−# For "manual" documents, if this is true, then toplevel headings are parts,
208−# not chapters.
209−#latex_use_parts = False
210−
211−# If true, show page references after internal links.
212−#latex_show_pagerefs = False
213−
214−# If true, show URL addresses after external links.
215−#latex_show_urls = False
216−
217−# Documents to append as an appendix to all manuals.
218−#latex_appendices = []
219−
220−# If false, no module index is generated.
221−#latex_domain_indices = True
222−
223−
224−# -- Options for manual page output ---------------------------------------
225−
226−# One entry per manual page. List of tuples
227−# (source start file, name, description, authors, manual section).
228−man_pages = [
229− ('index', 'purescript', u'PureScript Documentation',
230− [u'Phil Freeman'], 1)
231−]
232−
233−# If true, show URL addresses after external links.
234−#man_show_urls = False
235−
236−
237−# -- Options for Texinfo output -------------------------------------------
238−
239−# Grouping the document tree into Texinfo files. List of tuples
240−# (source start file, target name, title, author,
241−# dir menu entry, description, category)
242−texinfo_documents = [
243− ('index', 'PureScript', u'PureScript Documentation',
244− u'Phil Freeman', 'PureScript', 'One line description of project.',
245− 'Miscellaneous'),
246−]
247−
248−# Documents to append as an appendix to all manuals.
249−#texinfo_appendices = []
250−
251−# If false, no module index is generated.
252−#texinfo_domain_indices = True
253−
254−# How to display URL addresses: 'footnote', 'no', or 'inline'.
255−#texinfo_show_urls = 'footnote'
256−
257−# If true, do not generate a @detailmenu in the "Top" node's menu.
258−#texinfo_no_detailmenu = False
docs/source/ffi.rstdeleted−40
@@ -1,40 +0,0 @@
1−Foreign Function Interface
2−==========================
3−
4−Importing Values
5−----------------
6−
7−The ``foreign import`` keywords declare a value which is defined in Javascript, and its type::
8−
9− foreign import pow :: Number -> Number -> Number
10−
11−Inline Javascript
12−-----------------
13−
14−A foreign import declaration may optionally contain its definition in Javascript as a string literal. If this is provided, the string will be inserted directly into the generated Javascript before the current module definition::
15−
16− foreign import pow
17− """function pow(n) {
18− return function(p) {
19− return Math.pow(n, p);
20− };
21− }""" :: Number -> Number -> Number
22−
23−Importing Types
24−---------------
25−
26−To declare a new type with no constructors, use ``foreign import data`` and provide the kind::
27−
28− foreign import data DOM :: *
29−
30− foreign import document :: {
31− createElement :: String -> DOM
32− }
33−
34−Importing Type Class Instances
35−------------------------------
36−
37−Type class instances can be imported with ``foreign import instance``::
38−
39− foreign import instance showString :: Prelude.Show String
40−
docs/source/images/Prelude.pngdeleted

Binary file not shown.

docs/source/index.rstdeleted−31
@@ -1,31 +0,0 @@
1−.. PureScript documentation master file, created by
2− sphinx-quickstart on Wed Jan 22 22:04:23 2014.
3− You can adapt this file completely to your liking, but it should at least
4− contain the root `toctree` directive.
5−
6−Welcome to PureScript's documentation!
7−======================================
8−
9−Contents:
10−
11−.. toctree::
12− :maxdepth: 2
13−
14− intro
15− start
16− types
17− kinds
18− syntax
19− typeclasses
20− patterns
21− modules
22− ffi
23− prelude
24−
25−Indices and tables
26−==================
27−
28−* :ref:`genindex`
29−* :ref:`modindex`
30−* :ref:`search`
31−
docs/source/intro.rstdeleted−106
@@ -1,106 +0,0 @@
1−Introduction
2−============
3−
4−PureScript is a small strongly, statically typed compile-to-JS language with a number of interesting features, such as:
5−
6−- Type Inference
7−- Higher Kinded Polymorphism
8−- Support for basic Javascript types
9−- Extensible records
10−- Extensible effects
11−- Optimizer rules for generation of efficient Javascript
12−- Pattern matching
13−- Simple FFI
14−- Modules
15−- Rank N Types
16−- Do Notation
17−- Tail-call elimination
18−- Type Classes
19−
20−Motivation
21−----------
22−
23−I was looking for a simple functional language which would compile to JavaScript and have the following characteristics:
24−
25−- Generate simple readable Javascript
26−- Provide the ability to compile to tight loops if necessary
27−- Reasonable type system
28−- Ideally, written in a programming language I would enjoy working in
29−- Provides a simple interface to existing Javascript code
30−
31−I didn't find exactly what I was looking for, so I wrote PureScript. It doesn't have everything right now, but it should serve as a simple core on which to develop new ideas.
32−
33−PureScript was originally designed to implement purely functional core logic. However, recent additions to the compiler and libraries now also make it a good option for general-purpose programming.
34−
35−PureScript can also be seen as a trade-off between a theoretically ideal language and one which generates reasonably high performance code.
36−
37−Hello, PureScript!
38−------------------
39−
40−As an introductory example, here is the usual "Hello World" written in PureScript::
41−
42− module Main where
43−
44− import Debug.Trace
45−
46− main = trace "Hello, World!"
47−
48−which compiles to the following Javascript, ignoring the Prelude::
49−
50− var Main;
51− (function (Main) {
52− var main = trace("Hello, World!");
53− Main.main = main;
54− })(Main = Main || {});
55−
56−The following command will compile and execute the PureScript code above::
57−
58− psc input.purs --main | node
59−
60−Another Example
61−---------------
62−
63−The following code defines a ``Person`` data type and a function to generate a string representation for a ``Person``::
64−
65− data Person = Person { name :: String, age :: Number }
66−
67− showPerson :: Person -> String
68− showPerson (Person o) = o.name ++ ", aged " ++ show o.age
69−
70− examplePerson :: Person
71− examplePerson = Person { name: "Bonnie", age: 26 }
72−
73−Line by line, this reads as follows:
74−
75−- ``Person`` is a data type with one constructor, also called ``Person``
76−- The ``Person`` constructor takes an object with two properties, ``name`` which is a ``String``, and ``age`` which is a ``Number``
77−- The ``showPerson`` function takes a ``Person`` and returns a ``String``
78−- ``showPerson`` works by case analysis on its argument, first matching the constructor ``Person`` and then using string concatenation and object accessors to return its result.
79−- ``examplePerson`` is a Person object, made with the ``Person`` constructor and given the String "Bonnie" for the name value and the Number 26 for the age value.
80−
81−The generated Javascript looks like this::
82−
83− var Person = function (value) {
84− return { ctor: 'Person', values: [value] };
85− };
86−
87− function showPerson(_1) {
88− return _1.values[0].name + ", aged " + numberToString(_1.values[0].age);
89− };
90−
91− var examplePerson = Person({
92− name: "Bonnie",
93− age: 26
94− });
95−
96−Related Projects
97−----------------
98−
99−PureScript might be compared to other AltJS projects such as Roy, Haste, Fay, Elm and GHCJS. Certainly, there is a lot of overlap in terms of syntax, but the goals of PureScript listed above separate it in one or more ways from each of these languages.
100−
101−Roy is probably the most similar language on the list, and was a large influence on the development of PureScript. There are however, key differences in the foreign function interface, the type system and the choice of development language (Haskell vs. Javascript)
102−
103−Projects such as Haste, Fay and GHCJS aim to use some combination of the GHC compiler itself and/or its intermediate representation, Core, to perform some of the tasks involved in compilation such as parsing and type checking. This usually gives the advantage that tools and libraries can be shared with Haskell, but often at the cost of the size of the generated Javascript. This is the main practical difference between PureScript and these projects.
104−
105−Elm also shares a lot in terms of functionality with PureScript. Elm is designed for functional reactive programming, and focusses on tools and language features suitable for that domain, while PureScript focusses on the development of purely functional core application logic. Another difference between PureScript and Elm is PureScript's lack of a runtime system.
106−
docs/source/kinds.rstdeleted−21
@@ -1,21 +0,0 @@
1−Kind System
2−===========
3−
4−The kind system defines the following kinds:
5−
6−- ``*``, the kind of types.
7−- ``!``, the kind of effects.
8−- Arrow kinds ``k1 -> k2``
9−- Row kinds ``# k``
10−
11−Row Kinds
12−---------
13−
14−The kind ``# k`` of rows is used to classify labelled, unordered collections of types of kind ``k``.
15−
16−For example ``# *`` is the kind of rows of types, as used to define records, and ``# !`` is the kind of rows of effects, used to define the monad ``Eff`` of extensible effects.
17−
18−Quantification
19−--------------
20−
21−A type variable can refer to not only a type or a row, but a type constructor, or row constructor etc., and type variables with those kinds can be bound inside a ``forall`` quantifier.
docs/source/modules.rstdeleted−57
@@ -1,57 +0,0 @@
1−Modules
2−=======
3−
4−All code in PureScript is contained in a module. Modules are introduced using the ``module`` keyword::
5−
6− module A where
7−
8− id x = x
9−
10−When referencing values or data types in another module, names may be qualified by using a dot::
11−
12− module B where
13−
14− foo = A.id
15−
16−Importing Modules
17−-----------------
18−
19−A module can be imported using the ``import`` keyword. This will create aliases for all of the values and types in the imported module::
20−
21− module B where
22−
23− import A
24−
25−Alternatively, a list of names to import can be provided in parentheses::
26−
27− module B where
28−
29− import A (runFoo)
30−
31−Values, type constructors and data constructors can all be explicitly imported. A type constructor should be followed by a list of associated data constructors to import in parentheses. A double dot (``..``) can be used to import all data constructors for a given type constructor::
32−
33− module B where
34−
35− import A (runFoo, Foo(..), Bar(Bar))
36−
37−Qualified Imports
38−-----------------
39−
40−Modules can also be imported `qualified`, which means that their names will not be brought directly into scope, but rather, aliased to a different module name. This can be helpful when avoiding naming conflicts::
41−
42− module Main where
43−
44− import qualified Data.Array as A
45−
46− null = ...
47−
48−Here, the name ``null`` would ordinarily conflict with ``null`` from ``Data.Array``, but the qualified import solves this problem. ``Data.Array.null`` can be referenced using ``A.null`` instead.
49−
50−Module Exports
51−--------------
52−
53−Module exports can be restricted to a set of names by providing that set in parentheses in the module declaration::
54−
55− module A (runFoo, Foo(..)) where
56−
57−The types of names which can be exported is the same as for module imports.
docs/source/patterns.rstdeleted−139
@@ -1,139 +0,0 @@
1−Pattern Matching
2−================
3−
4−Pattern matching deconstructs a value to bring zero or more expressions into scope. Pattern matches are introduced with the `case` keyword.
5−
6−Pattern matches have the following general form::
7−
8− case value of
9− pattern -> result
10− ...
11− pattern -> result
12−
13−Pattern matching can also be used in the declaration of functions, as we have already seen::
14−
15− fn pattern_1 ... pattern_n = result
16−
17−Patterns can also be used when introducing functions. For example::
18−
19− example x y z = x * y + z
20−
21−The following pattern types are supported:
22−
23−- Wildcard pattern
24−- Literal patterns
25−- Variable pattern
26−- Array patterns
27−- Cons patterns
28−- Constructor patterns
29−- Record patterns
30−- Named patterns
31−- Guards
32−
33−Patterns need not be exhaustive. A pattern match failed exception will be thrown at runtime if no pattern matches the input.
34−
35−Wildcard Patterns
36−-----------------
37−
38−The wilcard `_` matches any input and brings nothing into scope::
39−
40− f _ = 0
41−
42−Literal Patterns
43−----------------
44−
45−Literal patterns are provided to match on primitives::
46−
47− f true = 0
48− f false = 1
49−
50− g "Foo" = 0
51− g _ = 1
52−
53− h 0 = 0
54− h _ = 1
55−
56−Variable Patterns
57−-----------------
58−
59−A variable pattern matches any input and binds that input to its name::
60−
61− double x = x * 2
62−
63−Array Patterns
64−--------------
65−
66−Array patterns match an input which is an array, and bring its elements into scope. For example::
67−
68− f [x] = x
69− f [x, y] = x * y
70− f _ = 0
71−
72−Here, the first pattern only matches arrays of length one, and brings the first element of the array into scope.
73−
74−The second pattern matches arrays with two elements, and brings the first and second elements into scope.
75−
76−Cons Patterns
77−-------------
78−
79−The head and tail of a non-empty array can be matched by using a cons pattern::
80−
81− sum [] = 0
82− sum (x : xs) = x + sum xs
83−
84−``:`` associates to the right::
85−
86− addPairs (x : y : xs) = x * y + addPairs xs
87− addPairs _ = 0
88−
89−
90−Constructor patterns
91−--------------------
92−
93−Constructor patterns match a data constructor and its arguments::
94−
95− data Foo = Foo String | Bar Number Boolean
96−
97− foo (Foo s) = true
98− foo (Bar _ b) = b
99−
100−Record Patterns
101−---------------
102−
103−Record patterns match an input which is a record, and bring its properties into scope::
104−
105− f { foo = "Foo", bar = n } = n
106− f _ = 0
107−
108−Nested Patterns
109−---------------
110−
111−The patterns above can be combined to create larger patterns. For example::
112−
113− f { arr = x : _, take = "car" } = x
114− f { arr = _ : x : _, take = "cadr" } = x
115− f _ = 0
116−
117−Named Patterns
118−--------------
119−
120−Named patterns bring additional names into scope when using nested patterns. Any pattern can be named by using the ``@`` symbol::
121−
122− f a@(_ : _ : _) = true
123− f _ = false
124−
125−Here, in the first pattern, any array with two or more elements will be matched and bound to the variable ``a``.
126−
127−Guards
128−------
129−
130−Guards are used to impose additional constraints inside a pattern using boolean-valued expressions, and are introduced with a pipe after the pattern::
131−
132− evens [] = 0
133− evens (x : xs) | x % 2 == 0 = 1 + evens xs
134− evens (_ : xs) = evens xs
135−
136−When using patterns to define a function at the top level, guards appear after all patterns::
137−
138− greater x y | x > y = true
139− greater _ _ = false
docs/source/prelude.rstdeleted−429
@@ -1,429 +0,0 @@
1−Module Documentation
2−====================
3−
4−Module Prelude
5−--------------
6−
7−Types
8−~~~~~
9−
10−::
11−
12− data Ordering where
13− LT :: Ordering
14− GT :: Ordering
15− EQ :: Ordering
16−
17− data Unit where
18− Unit :: { } -> Unit
19−
20−Type Classes
21−~~~~~~~~~~~~
22−
23−.. figure:: images/Prelude.png
24− :alt: Prelude
25−
26− Prelude
27−::
28−
29− class Alternative f where
30− empty :: forall a. f a
31− (<|>) :: forall a. f a -> f a -> f a
32−
33− class (Apply f) <= Applicative f where
34− pure :: forall a. a -> f a
35−
36− class (Functor f) <= Apply f where
37− (<*>) :: forall a b. f (a -> b) -> f a -> f b
38−
39− class (Apply m) <= Bind m where
40− (>>=) :: forall a b. m a -> (a -> m b) -> m b
41−
42− class Bits b where
43− (&) :: b -> b -> b
44− (|) :: b -> b -> b
45− (^) :: b -> b -> b
46− shl :: b -> Number -> b
47− shr :: b -> Number -> b
48− zshr :: b -> Number -> b
49− complement :: b -> b
50−
51− class BoolLike b where
52− (&&) :: b -> b -> b
53− (||) :: b -> b -> b
54− not :: b -> b
55−
56− class (Semigroupoid a) <= Category a where
57− id :: forall t. a t t
58−
59− class Eq a where
60− (==) :: a -> a -> Boolean
61− (/=) :: a -> a -> Boolean
62−
63− class Functor f where
64− (<$>) :: forall a b. (a -> b) -> f a -> f b
65−
66− class (Applicative m, Bind m) <= Monad m where
67−
68− class Num a where
69− (+) :: a -> a -> a
70− (-) :: a -> a -> a
71− (*) :: a -> a -> a
72− (/) :: a -> a -> a
73− (%) :: a -> a -> a
74− negate :: a -> a
75−
76− class (Eq a) <= Ord a where
77− compare :: a -> a -> Ordering
78−
79− class Semigroup a where
80− (<>) :: a -> a -> a
81−
82− class Semigroupoid a where
83− (<<<) :: forall b c d. a c d -> a b c -> a b d
84−
85− class Show a where
86− show :: a -> String
87−
88−Type Class Instances
89−~~~~~~~~~~~~~~~~~~~~
90−
91−::
92−
93− instance applicativeArr :: Applicative (Prim.Function r)
94−
95− instance applyArr :: Apply (Prim.Function r)
96−
97− instance bindArr :: Bind (Prim.Function r)
98−
99− instance bitsNumber :: Bits Number
100−
101− instance boolLikeBoolean :: BoolLike Boolean
102−
103− instance categoryArr :: Category Prim.Function
104−
105− instance eqArray :: (Eq a) => Eq [a]
106−
107− instance eqBoolean :: Eq Boolean
108−
109− instance eqNumber :: Eq Number
110−
111− instance eqOrdering :: Eq Ordering
112−
113− instance eqString :: Eq String
114−
115− instance eqUnit :: Eq Unit
116−
117− instance functorArr :: Functor (Prim.Function r)
118−
119− instance monadArr :: Monad (Prim.Function r)
120−
121− instance numNumber :: Num Number
122−
123− instance ordArray :: (Ord a) => Ord [a]
124−
125− instance ordBoolean :: Ord Boolean
126−
127− instance ordNumber :: Ord Number
128−
129− instance ordString :: Ord String
130−
131− instance ordUnit :: Ord Unit
132−
133− instance semigroupArr :: (Semigroup s') => Semigroup (s -> s')
134−
135− instance semigroupString :: Semigroup String
136−
137− instance semigroupUnit :: Semigroup Unit
138−
139− instance semigroupoidArr :: Semigroupoid Prim.Function
140−
141− instance showArray :: (Show a) => Show [a]
142−
143− instance showBoolean :: Show Boolean
144−
145− instance showNumber :: Show Number
146−
147− instance showOrdering :: Show Ordering
148−
149− instance showString :: Show String
150−
151− instance showUnit :: Show Unit
152−
153−Values
154−~~~~~~
155−
156−::
157−
158− (#) :: forall a b. a -> (a -> b) -> b
159−
160− ($) :: forall a b. (a -> b) -> a -> b
161−
162− (++) :: forall s. (Semigroup s) => s -> s -> s
163−
164− (:) :: forall a. a -> [a] -> [a]
165−
166− (<) :: forall a. (Ord a) => a -> a -> Boolean
167−
168− (<=) :: forall a. (Ord a) => a -> a -> Boolean
169−
170− (>) :: forall a. (Ord a) => a -> a -> Boolean
171−
172− (>=) :: forall a. (Ord a) => a -> a -> Boolean
173−
174− (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
175−
176− ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
177−
178− asTypeOf :: forall a. a -> a -> a
179−
180− cons :: forall a. a -> [a] -> [a]
181−
182− const :: forall a b. a -> b -> a
183−
184− flip :: forall a b c. (a -> b -> c) -> b -> a -> c
185−
186− liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
187−
188− liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
189−
190− refEq :: forall a. a -> a -> Boolean
191−
192− refIneq :: forall a. a -> a -> Boolean
193−
194− return :: forall m a. (Monad m) => a -> m a
195−
196− unit :: Unit
197−
198− void :: forall f a. (Functor f) => f a -> f Unit
199−
200−Module Data.Function
201−--------------------
202−
203−Types
204−~~~~~
205−
206−::
207−
208− data Fn0 :: * -> *
209−
210− data Fn1 :: * -> * -> *
211−
212− data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
213−
214− data Fn2 :: * -> * -> * -> *
215−
216− data Fn3 :: * -> * -> * -> * -> *
217−
218− data Fn4 :: * -> * -> * -> * -> * -> *
219−
220− data Fn5 :: * -> * -> * -> * -> * -> * -> *
221−
222− data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
223−
224− data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
225−
226− data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
227−
228− data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
229−
230−Values
231−~~~~~~
232−
233−::
234−
235− mkFn0 :: forall a. (Unit -> a) -> Fn0 a
236−
237− mkFn1 :: forall a b. (a -> b) -> Fn1 a b
238−
239− mkFn10 :: forall a b c d e f g h i j k. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> Fn10 a b c d e f g h i j k
240−
241− mkFn2 :: forall a b c. (a -> b -> c) -> Fn2 a b c
242−
243− mkFn3 :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
244−
245− mkFn4 :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
246−
247− mkFn5 :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
248−
249− mkFn6 :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
250−
251− mkFn7 :: forall a b c d e f g h. (a -> b -> c -> d -> e -> f -> g -> h) -> Fn7 a b c d e f g h
252−
253− mkFn8 :: forall a b c d e f g h i. (a -> b -> c -> d -> e -> f -> g -> h -> i) -> Fn8 a b c d e f g h i
254−
255− mkFn9 :: forall a b c d e f g h i j. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> Fn9 a b c d e f g h i j
256−
257− on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
258−
259− runFn0 :: forall a. Fn0 a -> a
260−
261− runFn1 :: forall a b. Fn1 a b -> a -> b
262−
263− runFn10 :: forall a b c d e f g h i j k. Fn10 a b c d e f g h i j k -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
264−
265− runFn2 :: forall a b c. Fn2 a b c -> a -> b -> c
266−
267− runFn3 :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
268−
269− runFn4 :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
270−
271− runFn5 :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
272−
273− runFn6 :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
274−
275− runFn7 :: forall a b c d e f g h. Fn7 a b c d e f g h -> a -> b -> c -> d -> e -> f -> g -> h
276−
277− runFn8 :: forall a b c d e f g h i. Fn8 a b c d e f g h i -> a -> b -> c -> d -> e -> f -> g -> h -> i
278−
279− runFn9 :: forall a b c d e f g h i j. Fn9 a b c d e f g h i j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
280−
281−Module Data.Eq
282−--------------
283−
284−Types
285−~~~~~
286−
287−::
288−
289− data Ref a where
290− Ref :: a -> Ref a
291−
292−Type Class Instances
293−~~~~~~~~~~~~~~~~~~~~
294−
295−::
296−
297− instance eqRef :: Eq (Ref a)
298−
299− instance functorRef :: Functor Ref
300−
301−Values
302−~~~~~~
303−
304−::
305−
306− liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
307−
308−Module Prelude.Unsafe
309−---------------------
310−
311−Values
312−~~~~~~
313−
314−::
315−
316− unsafeIndex :: forall a. [a] -> Number -> a
317−
318−Module Control.Monad.Eff
319−------------------------
320−
321−Types
322−~~~~~
323−
324−::
325−
326− data Eff :: # ! -> * -> *
327−
328− type Pure a = forall e. Eff e a
329−
330−Type Class Instances
331−~~~~~~~~~~~~~~~~~~~~
332−
333−::
334−
335− instance applicativeEff :: Applicative (Eff e)
336−
337− instance applyEff :: Apply (Eff e)
338−
339− instance bindEff :: Bind (Eff e)
340−
341− instance functorEff :: Functor (Eff e)
342−
343− instance monadEff :: Monad (Eff e)
344−
345−Values
346−~~~~~~
347−
348−::
349−
350− bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
351−
352− forE :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
353−
354− foreachE :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
355−
356− returnE :: forall e a. a -> Eff e a
357−
358− runPure :: forall a. Pure a -> a
359−
360− untilE :: forall e. Eff e Boolean -> Eff e Unit
361−
362− whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
363−
364−Module Control.Monad.Eff.Unsafe
365−-------------------------------
366−
367−Values
368−~~~~~~
369−
370−::
371−
372− unsafeInterleaveEff :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
373−
374−Module Debug.Trace
375−------------------
376−
377−Types
378−~~~~~
379−
380−::
381−
382− data Trace :: !
383−
384−Values
385−~~~~~~
386−
387−::
388−
389− print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
390−
391− trace :: forall r. String -> Eff (trace :: Trace | r) Unit
392−
393−Module Control.Monad.ST
394−-----------------------
395−
396−Types
397−~~~~~
398−
399−::
400−
401− data ST :: * -> !
402−
403− data STArray :: * -> * -> *
404−
405− data STRef :: * -> * -> *
406−
407−Values
408−~~~~~~
409−
410−::
411−
412− modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
413−
414− newSTArray :: forall a h r. Number -> a -> Eff (st :: ST h | r) (STArray h a)
415−
416− newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
417−
418− peekSTArray :: forall a h r. STArray h a -> Number -> Eff (st :: ST h | r) a
419−
420− pokeSTArray :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) a
421−
422− readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
423−
424− runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
425−
426− runSTArray :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]
427−
428− writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
429−
docs/source/start.rstdeleted−61
@@ -1,61 +0,0 @@
1−Getting Started
2−===============
3−
4−Compiler Installation
5−---------------------
6−
7−If you have the Haskell Plaform installed, then you can install the latest released version from Hackage::
8−
9− cabal update
10− cabal install purescript
11−
12−If you would like to build the latest version of the code, clone this repository and build::
13−
14− git clone git@github.com:purescript/purescript.git
15− cd purescript
16− cabal configure --enable-tests
17− cabal build
18− cabal test
19− cabal install
20−
21−Alternatively, consider installing PureScript in a Cabal sandbox using ``cabal sandbox init``.
22−
23−Creating a new PureScript project
24−---------------------------------
25−
26−You can create a new PureScript project using ``grunt-init`` and `this PureScript project template <https://github.com/purescript-contrib/grunt-init-purescript>`_. This will give you a project that uses `Grunt <http://gruntjs.com>`_ as its build tool and `Bower <http://bower.io>`_ for dependency management. See the `README <https://github.com/purescript-contrib/grunt-init-purescript>`_ for step-by-step instructions.
27−
28−Compiler usage
29−--------------
30−
31−The `psc` executable takes a list of PureScript source files as arguments and by default writes out its errors or output to the console.
32−
33−The following options are supported:
34−
35−--stdin Read input from standard input instead of from files.
36−--output Write the generated Javascript to the specified file.
37−--externs Write a list of foreign imports declarations to the specified file in addition to generating Javascript output.
38−--no-tco Turn off tail-call elimination.
39−--no-prelude Do not include the Prelude in the generated Javascript.
40−--no-magic-do Turn off optimizations which inline calls to ``>>=`` for the ``Eff`` monad.
41−--no-opts Disable all optimizations.
42−--main Generate a call to ``main`` in the specified module after all other generated Javascript. Defaults to ``Main`` if the option is used but no value is provided.
43−--module If specified, any code which is not referenced transitively from this module will be removed. This argument can be used multiple times.
44−--codegen A list of modules for which Javascript and externs should be generated. This argument can be used multiple times.
45−--browser-namespace Specify the namespace that PureScript modules will be exported to when running in the browser.
46−--verbose-errors Generate verbose error messages.
47−
48−psc-make
49−--------
50−
51−The ``psc-make`` executable makes CommonJS modules and supports incremental compilation. Unlike ``psc``, it does not do dead code elimination.
52−
53−The following command line options are supported:
54−
55−--output=VAL The output directory. Default: ``output``.
56−--verbose-errors Display verbose error messages.
57−--help=FMT Show this help in format FMT (``pager``, ``plain``, or ``groff``). Default: ``pager``.
58−--no-magic-do Disable the optimization that overloads the ``do`` keyword to generate efficient code specifically for the ``Eff`` monad.
59−--no-opts Skip the optimization phase.
60−--no-prelude Omit the Prelude.
61−--no-tco Disable tail call optimizations
docs/source/syntax.rstdeleted−266
@@ -1,266 +0,0 @@
1−Syntax
2−======
3−
4−Whitespace Rules
5−----------------
6−
7−Syntax is whitespace sensitive. The general rule of thumb is that declarations which span multiple lines should be indented past the column on which they were first defined on their subsequent lines.
8−
9−That is, the following is valid::
10−
11− foo = bar(x) +
12− baz(x)
13−
14−But this is not::
15−
16− foo = bar(x) +
17− baz(x)
18−
19−Operators
20−---------
21−
22−Binary operators in PureScript are just regular functions. The Prelude defines a number of operators which correspond to Javascript's operators.
23−
24−The Prelude defines the following functions which correspond to Javascript's unary operators:
25−
26−========== ======== =======================
27−Function Operator Meaning
28−========== ======== =======================
29−negate \- Numeric negation
30−not ! Boolean negation
31−complement ~ Binary negation
32−========== ======== =======================
33−
34−and the following binary operators:
35−
36−========== =========== =====================
37−Function JS Operator Meaning
38−========== =========== =====================
39−\+ \+ Numeric addition
40−\- \- Numeric subtraction
41−\* \* Numeric multiplication
42−/ / Numeric division
43−% % Numeric modulus
44−== == Equality check
45−/= != Inequality check
46−< < Less than
47−<= <= Less than or equal
48−> > Greater than
49−>= >= Greater than or equal
50−&& && Boolean AND
51−|| || Boolean OR
52−& & Binary AND
53−\| \| Binary OR
54−^ ^ Binary XOR
55−shl << Shift Left
56−shr >> Shift Right
57−zshr \>>> Zero-Fill Shift Right
58−++ \+ String concatenation
59−========== =========== =====================
60−
61−Literal Values
62−--------------
63−
64−Numeric literals can be integers or floating point numbers. Numbers in hexadecimal notation should be preceded by the characters ``0x``::
65−
66− 16
67− 16.0
68− 0xF0
69−
70−String literals are enclosed in double-quotes and may extend over multiple lines. Line breaks should be surrounded by slashes as follows::
71−
72− "Hello World"
73−
74− "Hello \
75− \World"
76−
77−The two boolean literals are ``true`` and ``false``.
78−
79−Array Literals
80−--------------
81−
82−Array literals are surrounded by square brackets, as in Javascript::
83−
84− []
85− [1, 2, 3]
86−
87−Record Literals
88−---------------
89−
90−Record literals are surrounded by braces, as in Javascript::
91−
92− {}
93− { foo: "Foo", bar: 1 }
94−
95−Array Indexing
96−--------------
97−
98−The ``Prelude.Unsafe`` module defines the ``unsafeIndex`` function which retrieves the element of an array at an index::
99−
100− unsafeIndex :: forall a. [a] -> Number -> a
101−
102−The code generator will turn the expression ``unsafeIndex arr index`` into the simplified Javascript ``arr[index]``.
103−
104−The ``purescript-array`` core library defines an alternative safe version ``!!`` of ``unsafeIndex`` which checks arrays bounds and returns a value of type ``Maybe a``.
105−
106−Property Accessors
107−------------------
108−
109−To access a property of a record, use a dot, followed by the property name, as in Javascript::
110−
111− rec.propertyName
112−
113−Functions
114−---------
115−
116−Functions are introduced by using a backslash followed by a list of argument names::
117−
118− example1 = \a b -> a + b
119−
120−which would correspond to the following Javascript::
121−
122− function example1(a) {
123− return function (b) {
124− return a + b;
125− }
126− }
127−
128−Function application is indicated by just the juxtaposition of a function with its arguments::
129−
130− example1 10 20
131−
132−Functions can also be defined at the top level by providing a list of patterns and an optional guard on the left hand side of the equals sign::
133−
134− f [] [] = []
135− f (x:xs) (y:ys) = x + y : f xs ys
136−
137−If-Then-Else Expressions
138−------------------------
139−
140−The ``if``, ``then`` and ``else`` keywords can be used to create conditional expressions. In this case, the ``else`` block is always required.
141−
142−For example::
143−
144− conditional = if 2 > 1 then "ok" else "oops"
145−
146−Do Notation
147−-----------
148−
149−The ``do`` keyword introduces simple syntactic sugar for monadic expressions.
150−
151−Here is an example, using the maybe monad::
152−
153− data Maybe a = Nothing | Just a
154−
155− isEven :: Number -> Maybe Unit
156− isEven n | n % 2 == 0 = Just unit
157− isEven _ = Nothing
158−
159− evenSum a b = do
160− n <- a
161− m <- b
162− let sum = n + m
163− isEven sum
164− return sum
165−
166−``isEven`` adds two values of type ``Maybe Number`` and returns their sum, if the sum is even. If the sum is odd, ``evenSum`` returns ``Nothing``.
167−
168−When using ``do`` notation, the corresponding type constructor must be an instance of the ``Prelude.Monad`` type class.
169−
170−Statements can have the following form:
171−
172−- ``a <- x`` which desugars to ``x >>= \a -> ...``
173−- ``x`` which desugars to ``x >>= \_ -> ...`` or just ``x`` if this is the last statement.
174−- A let binding ``let a = x`` where ``a`` can be either a name or a binder. Note the lack of the ``in`` keyword.
175−
176−The example ``evenSum`` desugars to::
177−
178− evenSum a b =
179− a >>= \n ->
180− b >>= \m ->
181− let sum = n + m in
182− isEven sum >>= \_ ->
183− return sum
184−
185−Binders can be used on the left hand side of ``<-`` or ``=``. For example::
186−
187− test arr = do
188− (x:y:_) <- arr
189− ret (x + y)
190−
191−A pattern match failure will generate a runtime exception, just as in the case of a regular ``case`` statement.
192−
193−Operators
194−---------
195−
196−User-defined infix operators can be created by enclosing names in parentheses.
197−
198−E.g. to create an infix synonym for the ``Data.Array.range`` function::
199−
200− (..) :: Number -> Number -> [Number]
201− (..) = Data.Array.range
202−
203−This function can be used as follows::
204−
205− oneToTen = 1 .. 10
206−
207−Regular functions can be used as operators by enclosing their names in backticks::
208−
209− foo x y = x * y + y
210−
211− test = 10 `foo` 20
212−
213−Fixity declarations can associate a precedence level, which is a natural number, to a user-defined operator, and specify which way it associates::
214−
215− infix 5 ..
216− infixl 7 %%
217− infixr 9 ^^
218−
219−Record Updates
220−--------------
221−
222−Properties on records can be updated using the following syntax::
223−
224− o { key = value, ..., key = value }
225−
226−For example, the following function increments the ``foo`` property on its argument::
227−
228− incr o = o { foo = o.foo + 1 }
229−
230−Let Bindings
231−------------
232−
233−The ``let`` keywords a collection of local declarations, which may be mutually recursive, and which may include type declarations::
234−
235− factorial :: Number -> Number
236− factorial =
237− let
238− go :: Number -> Number -> Number
239− go acc 1 = acc
240− go acc n = go (acc * n) (n - 1)
241− in
242− go 1
243−
244−The ``where`` keyword can also be used to introduce local declarations `at the end of a value declaration`::
245−
246− factorial :: Number -> Number
247− factorial = go 1
248− where
249− go :: Number -> Number -> Number
250− go acc 1 = acc
251− go acc n = go (acc * n) (n - 1)
252−
253−Comments
254−--------
255−
256−A single line comment starts with ``--``::
257−
258− -- This is a comment
259−
260−Multi-line comments are enclosed in ``{-`` and ``-}``. These can be nested::
261−
262− {- Comment {- nested comment -} continued comment -}
263−
264−
265−
266−
docs/source/typeclasses.rstdeleted−48
@@ -1,48 +0,0 @@
1−Type Classes
2−============
3−
4−PureScript has basic support for type classes via the ``class`` and ``instance`` keywords.
5−
6−Types appearing in class instances are must be of the form ``String``, ``Number``, ``Boolean``, or ``C t1 ... tn`` where ``C`` is a type constructor (including ``[]`` and ``->`` and ``t_i`` are types of the same form).
7−
8−Type class instances are resolved based on the order in which they appeared in the source files. Overlapping instances will result in a compilation error.
9−
10−Example
11−-------
12−
13−Here is an example of the ``Show`` typeclass, with instances for ``String``, ``Booleans`` and ``[]``::
14−
15− class Show a where
16− show :: a -> String
17−
18− instance showString :: Show String where
19− show s = s
20−
21− instance showBoolean :: Show Boolean where
22− show true = "true"
23− show false = "false"
24−
25− instance showArray :: (Show a) => Show [a] where
26− show [] = "[]"
27− show (x:xs) = show x ++ " : " ++ showArray xs
28−
29− example = show [true, false]
30−
31−Superclasses
32−------------
33−
34−Superclass implications can be indicated in a class declaration with a backwards fat arrow ``<=``::
35−
36− class (Monad m) <= MonadFail m where
37− fail :: forall a. String -> m a
38−
39−Superclass instances will be used when searching for an instance of a subclass. For example, in the code below, the ``Monad`` constraint introduced by the ``return`` function can be discharged since ``Monad`` is a superclass of ``MonadFail``::
40−
41− assert :: forall m. (MonadFail m) => Boolean -> m Unit
42− assert true = return unit
43− assert false = fail "Assertion failed"
44−
45−Type Annotations
46−----------------
47−
48−A constrained type will never be inferred for a top-level declaration without an explicit type signature.
docs/source/types.rstdeleted−173
@@ -1,173 +0,0 @@
1−Types
2−=====
3−
4−The type system defines the following types:
5−
6−- Primitive Types: Number, String, Boolean
7−- Arrays
8−- Records
9−- Tagged Unions
10−- Newtypes
11−- Functions
12−- Polymorphic Types
13−- Constrained Types
14−- Type Synonyms
15−- Rows
16−
17−Primitive Types
18−---------------
19−
20−The three primitive types ``String``, ``Number`` and ``Boolean`` correspond to their Javascript equivalents at runtime.
21−
22−Arrays
23−------
24−
25−PureScript arrays correspond to Javascript arrays at runtime, but all elements in an array must have the same type.
26−
27−Records
28−-------
29−
30−PureScript records correspond to Javascript objects. They may have zero or more named fields, each with their own types.
31−
32−Tagged Unions
33−-------------
34−
35−Tagged unions consist of one or more constructors, each of which takes zero or more arguments.
36−
37−Tagged unions can only be created using their constructors, and deconstructed through pattern matching (see later).
38−
39−For example::
40−
41− data Foo = Foo | Bar String
42−
43− runFoo Foo = "It's a Foo"
44− runFoo (Bar s) = "It's a Bar. The string is " ++ s
45−
46− test = runFoo Foo ++ runFoo (Bar "Test")
47−
48−In the example, Foo is a tagged union type which has two constructors. Its first constructor ``Foo`` takes no arguments, and its second ``Bar`` takes one, which must be a String.
49−
50−``runFoo`` is an example of pattern matching on a tagged union type to discover its constructor, and the last line shows how to construct values of type ``Foo``.
51−
52−Newtypes
53−--------
54−
55−Newtypes are like data types introduced with the ``data`` keyword, but are restricted to a single contructor which contains a single argument. Newtypes are introduced with the ``newtype`` keyword::
56−
57− newtype Percentage = Percentage Number
58−
59−The representation of a newtype at runtime is the same as the underlying data type. For example, a value of type ``Percentage`` is just a JavaScript number at runtime.
60−
61−Newtypes can be assigned their own type class instances, so for example, ``Percentage`` can be given its own ``Show`` instance::
62−
63− instance showPercentage :: Show Percentage where
64− show (Percentage n) = show n ++ "%"
65−
66−Functions
67−---------
68−
69−Functions in PureScript are like their Javascript counterparts, but always have exactly one argument.
70−
71−Polymorphic Types
72−-----------------
73−
74−Expressions defined at the top level may have polymorphic types.
75−
76−Here is an example::
77−
78− identity x = x
79−
80−``identity`` is inferred to have (polymorphic) type ``forall t0. t0 -> t0``. This means that for any type ``t0``, ``identity`` can be given a value of type ``t0`` and will give back a value of the same type.
81−
82−A type annotation can also be provided::
83−
84− identity :: forall a. a -> a
85− identity x = x
86−
87−Row Polymorphism
88−----------------
89−
90−Polymorphism is not limited to abstracting over types. Values may also be polymorphic in types with other kinds, such as rows or effects (see "Kind System").
91−
92−For example, the following function accesses two properties on a record::
93−
94− addProps o = o.foo + o.bar
95−
96−The inferred type of ``addProps`` is::
97−
98− forall r. { foo :: Number, bar :: Number | r } -> Number
99−
100−Here, the type variable ``r`` has kind ``# *`` - it represents a `row` of `types`. It can be instantiated with any row of named types.
101−
102−In other words, ``addProps`` accepts any record which has properties ``foo`` and ``bar``, and *any other record properties*.
103−
104−Therefore, the following application compiles::
105−
106− addProps { foo: 1, bar: 2, baz: 3 }
107−
108−even though the type of ``addProps`` does not mention the property ``baz``. However, the following does not compile::
109−
110− addProps { foo: 1 }
111−
112−since the ``bar`` property is missing.
113−
114−Rank N Types
115−------------
116−
117−It is also possible for the ``forall`` quantifier to appear on the left of a function arrow, inside types record fields and data constructors, and in type synonyms.
118−
119−In most cases, a type annotation is necessary when using this feature.
120−
121−As an example, we can pass a polymorphic function as an argument to another function::
122−
123− poly :: (forall a. a -> a) -> Boolean
124− poly f = (f 0 < 1) == f true
125−
126−Notice that the polymorphic function's type argument is instantiated to both ``Number`` and ``Boolean``.
127−
128−An argument to ``poly`` must indeed be polymorphic. For example, the following fails::
129−
130− test = poly (\n -> n + 1)
131−
132−since the skolemized type variable ``a`` does not unify with ``Number``.
133−
134−Rows
135−----
136−
137−A row of types represents an unordered collection of named types without duplicates.
138−
139−Rows have kind ``# k`` for some kind ``k``, and so values do not have types which are rows. Rather, rows can be used in type signatures to define record types or other type where labelled, unordered types are useful.
140−
141−To denote a closed row, separate the fields with commas, with each label separated from its type with a double colon::
142−
143− (name :: String, age :: Number)
144−
145−It may be necessary, depending on the context, to surround a row in parentheses.
146−
147−To denote an open row (i.e. one which may unify with another row to add new fields), separate the specified terms from a row variable by a pipe::
148−
149− (name :: String, age :: Number | r)
150−
151−Type Synonyms
152−-------------
153−
154−For convenience, it is possible to declare a synonym for a type using the ``type`` keyword. Type synonyms can include type arguments.
155−
156−For example::
157−
158− type Foo = { foo :: Number, bar :: Number }
159−
160− addFoo :: Foo -> Number
161− addFoo = \o -> o.foo + o.bar
162−
163−Constrained Types
164−-----------------
165−
166−Polymorphic types may be predicated on one or more ``constraints``. See the chapter on type classes for more information.
167−
168−Type Annotations
169−----------------
170−
171−Most types can be inferred (not including Rank N Types and constrained types), but annotations can optionally be provided using a double-colon::
172−
173− one = 1 :: Number
prelude/README.md+4−8
@@ -9,7 +9,7 @@
9 GT :: Ordering
9 GT :: Ordering
10 EQ :: Ordering
10 EQ :: Ordering
11
11
12− data Unit where
12+ newtype Unit where
13 Unit :: { } -> Unit
13 Unit :: { } -> Unit
14
14
15
15
@@ -17,10 +17,6 @@
17
17
18![Prelude](images/Prelude.png)
18![Prelude](images/Prelude.png)
19
19
20− class Alternative f where
21− empty :: forall a. f a
22− (<|>) :: forall a. f a -> f a -> f a
23−
24 class (Apply f) <= Applicative f where
20 class (Apply f) <= Applicative f where
25 pure :: forall a. a -> f a
21 pure :: forall a. a -> f a
26
22
@@ -265,8 +261,8 @@
265
261
266### Types
262### Types
267
263
268− data Ref a where
264+ newtype Ref a where
269− Ref :: a -> Ref a
265+ Ref :: a -> Ref
270
266
271
267
272### Type Class Instances
268### Type Class Instances
@@ -367,7 +363,7 @@
367
363
368 newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
364 newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
369
365
370− peekSTArray :: forall a h r. STArray h a -> Eff (st :: ST h | r) a
366+ peekSTArray :: forall a h r. STArray h a -> Number -> Eff (st :: ST h | r) a
371
367
372 pokeSTArray :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) a
368 pokeSTArray :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) a
373
369
prelude/images/Prelude.png

Binary file not shown.

prelude/updateDocs.sh+3−3
@@ -1,11 +1,11 @@
1../dist/build/docgen/docgen --hierarchy-images prelude.purs > README.md
1../dist/build/docgen/docgen --hierarchy-images prelude.purs > README.md
2../dist/build/hierarchy/hierarchy prelude.purs -o prelude
2../dist/build/hierarchy/hierarchy prelude.purs -o prelude
3+
3mkdir -p images
4mkdir -p images
4−mkdir -p ../docs/source/images
5+
5for f in prelude/*; do
6for f in prelude/*; do
6 BASE=$(basename "$f")
7 BASE=$(basename "$f")
7 dot -Tpng -o images/"$BASE".png "$f"
8 dot -Tpng -o images/"$BASE".png "$f"
8− cp images/"$BASE".png ../docs/source/images/"$BASE".png
9done
9done
10+
10rm -r prelude
11rm -r prelude
11−pandoc -o ../docs/source/prelude.rst README.md