An unofficial FAQ for the PureScript language.
This is a work-in-progress, so please suggest addition questions and/or answers.
See the Getting Started Guide.
The simplest option is with spago bundle-app
. This produces a single .js
file that you can execute in node
or include as a script (for example in your index.html
). This runs dead code elimination, and that added delay is not ideal for quick iterations during development.
Some faster bundling option are:
The bundling process should improve once the PS compiler is modified to output ES modules.
An issue tracking the start of a CSS guide.
- Halogen + (optional) Hooks
- react-basic
- Concur with React or Halogen (in-progress) backend
- Halogen is written entirely in PureScript.
- React-basic enables easy interop with the React ecosystem.
- Concur focuses on simple composition of
Widgets
(components).
You may have to dive into the framework docs and look at some examples to get a better sense of the differences.
The Intended to be Implemented page provides some visibility into items on the todo list, but could be clarified with more details on planned sequence. Ideally, we'd have a "roadmap summary" page, but until then, here's a short summary:
- 0.14.0 - Current release
- 0.15.0 - ES Modules
- New package registry
- ES6 modules
- Better dead code elimination and bundling
- Complete documentation
- Smooth new-user experience
No. The docs referring to bower
are outdated. Spago is the recommended package management tool.
Pursuit lists all published packages, but not all of these make it into the package set accessible to spago. It is encouraged to open PRs to add these missing packages to the package set.
You may alternatively consult Starsuit, which is a Pursuit clone that is synced to the latest package set.
Pursuit plans to be better synced with the new registry.
A list of available editor options.
Some framework templates also demonstrate how to setup a project with automatic rebuild and webpage refresh upon saving changes:
Yes. The purty
formatter. Note that there are still some formatting issues to fix.
For editor integrations:
- VSCode - vscode-purty extension
- Vim/Neovim with coc.nvim - coc-purty
There's a task for putting together these summaries. Feel free to contribute.
The cookbook aims to provide lots of miscellaneous examples. Feel free to request additional examples.
Records serve the same niche and are more readable. Also, built-in tuples, if added, are one more feature to maintain in the PureScript compiler and one that is easily expressed without built-in support. For example, using purescript-tuples
, you can write the following code:
module Foo where
import Data.Tuple (Tuple(..), (/\), type (/\))
tuple :: Tuple Int String
tuple = Tuple 1 "bar"
-- You can also use `/\` to write tuples
conciseTuple :: Int /\ String
conciseTuple = 1 /\ "bar"
Relevant links:
- https://github.com/purescript/documentation/blob/master/language/Differences-from-Haskell.md#tuples
- purescript/purescript#1687
We chose to match the syntax and capabilities of Haskell's Category
class (we call it Semigroupoid
and drop the identity requirement). Note that <<<
in PureScript and Haskell (in Haskell it's an alias for .
) allow for composing more than just functions, while <<
in Elm only works for functions. See Differences from Haskell.
Additionally, while not essential, it is common to use Semigroupoid
composition with operators in the Functor
hierarchy (eg., >>=
, >=>
, <$>
, <*>
), and using a three-character operator keeps code in alignment when split over multiple lines.
Original question:
For dependent typeclasses (e.g.
Eq
andOrd
) the operations from one are (always? sometimes?) strictly more powerful than the operations in the other (i.e. you can expresseq
viacompare
). Why is it then that if I defineOrd
for a type, I still need to explicitly defineEq
? Shouldn'tEq
be automatically derivable by having an instance ofOrd
?
A seemingly-redundant definition of Eq
is required to avoid creating orphan instances. Imagine if Ord
and Eq
were in separate libraries, and the author of the Ord
library defined an Ord
instance for some type which didn’t have an Eq
instance. If instances worked that way, that type would automatically get an Eq
instance too. Now suppose the author of the Eq
library adds a direct Eq
instance for that type which doesn’t agree with the one via Ord
. What should we do now?