A strongly-typed language that compiles to JavaScript
OTHER License
Bot releases are hidden (Show)
Published by paf31 over 7 years ago
This release includes several breaking changes, in preparation for the 1.0 release, as well as many enhancements and bug fixes.
Most users will probably want to wait until all aspects of the release have been finalized. Progress on libraries and tools is being tracked here.
Many thanks to the contributors who helped with this release!
(@garyb, @paf31)
=>
now acts like a binary type operatorIt was previously possible to specify many constraints in the same context by
separating them with commas inside parentheses on the left of the =>
:
runFreeT :: ∀ m f. (Functor f, Monad m) => ...
This is no longer allowed. Instead, =>
now acts like a binary operator, with a
constraint on the left and a type on the right. Multiple constraints must be
introduced using currying, as with regular function arguments:
runFreeT :: ∀ m f. Functor f => Monad m => ...
This is in preparation for adding constraint kinds, at which point =>
will become
an actual binary type operator, defined in Prim
.
*
and !
kinds have been removedThe kind symbols *
(for the kind of types) and !
(for the kind of effects) have been
removed from the parser. Instead of *
, use Type
, which is defined in Prim
.
Instead of !
, use Effect
, which can now be imported from Control.Monad.Eff
.
The #
symbol, which is used to construct a row kind, is still supported. We cannot move this kind into Prim
(because it is polykinded, and we do not support kind polymorphism).
The various psc-*
executables have been replaced with a single executable called purs
.
The various subcommands are documented on the --help
page:
bundle Bundle compiled PureScript modules for the browser
compile Compile PureScript source files
docs Generate Markdown documentation from PureScript source files
hierarchy Generate a GraphViz directed graph of PureScript type classes
ide Start or query an IDE server process
publish Generates documentation packages for upload to Pursuit
repl Enter the interactive mode (PSCi)
Wrapper scripts will be provided in the binary distribution.
psc-package
was removedpsc-package
has been removed from the main compiler distribution. It will still
be maintained along with the package sets repo, but will not be bundled with the compiler.
A binary distribution which is compatible with this release is available.
do
blocks now raise errorsCode which discards the result of a computation in a do
block:
duplicate :: Array a -> Array a
duplicate xs = do
x <- xs
[true, false] -- the result here is discarded
pure x
will now raise an error. The compiler allows values of certain types to be discarded,
based on the Discard
class in Control.Bind
. The only type which can be discarded is
Unit
, but the feature was implemented using a type class to enable support for
alternative preludes.
In addition to removing psc-package
from the compiler distribution, we have also
removed any explicit dependency on the Bower executable. The compiler will not assume
use of any particular package manager, but will aim to provide generic support for
package managers generally, via command line options and hooks.
purs publish
will continue to use the Bower JSON formats. The bower.json
format
is now referred to as the "manifest file", while the output of bower list --json
,
which is used by purs publish
internally, is referred to as the "resolutions file".
(@alexbiehl)
In addition to regular guards:
foo x | condition x = ...
the compiler now supports pattern guards, which let the user simultaneously
test a value against a pattern, and bind names to values.
For example, we can apply a function fn
to an argument x
, succeeding only if
fn
returns Just y
for some y
, binding y
at the same time:
bar x | Just y <- fn x = ... -- x and y are both in scope here
Pattern guards can be very useful for expressing certain types of control flow when
using algebraic data types.
(@hdgarrood)
The --format html
option has been added to purs docs
. The HTML format uses
the Pursuit template, and is very useful for rendering documentation for offline
use.
Here is an example of the generated HTML.
(@paf31)
Row types now support duplicate labels, which can be useful when using the Eff
monad. For example, we could not previously use the catchException
function if
the resulting action also required the EXCEPTION
effect, since otherwise the
type of the inner action would contain a duplicate label.
Rows are now unordered collections (of labels and types) with duplicates. However,
the collection of types for a specific label within a row is ordered.
Conceptually, a row can be thought of as a type-level Map Label (NonEmptyList Type)
.
A type constructor (such as Record
) which takes a row of types as an argument should
define what its meaning is on each row. The meaning of a value of type Record r
is a JavaScript object where the type of the value associated with each label is given
by the head element of the non-empty list of types for that label.
(@doolse, @paf31)
A new constraint called Union
has been added to Prim
. Union
is a three-way relation between
rows of types, and the compiler will solve it automatically when it is possible to do so.
Union
is a left-biased union of rows which takes into account duplicate labels. If the same label appears in rows l
and r
, and Union l r u
holds, then the label will appear twice in u
.
Union
makes it possible to give a type to the function which merges two records:
merge :: forall r1 r2 r3. Union r1 r2 r3 => Record r1 -> Record r2 -> Record r3
Note that this is a left-biased merge - if the two input record contain a common label, the type of the
label in the result will be taken from the left input.
let
expressions(@noraesae)
Let expressions and where
clauses can now use binders on the left hand side of
a declaration:
map f xs =
let { head, tail } = uncons xs
in [f head] <> map f tail
Unlike in Haskell, declarations with these patterns cannot appear in dependency cycles, and bound names can only be used in declarations after the one in which they are brought into scope.
(@kRITZCREEK)
Type-directed search will now include results for record accessors. This can
be very useful when working with extensible records with a type-driven programming
workflow.
Prim
(@hdgarrood)_
instead of false
case for if then else
to improve optimizations (@rightfold)InvalidDerivedInstance
error to improve errors for derived instances (@paf31)purs ide
purs ide
now uses a new import parser, which allows purs ide
to handle any(@kRITZCREEK)
purs ide
will now no longer leave empty output/ directories behind when it is
started in a directory that is not a PureScript project.
(@kRITZCREEK)
purs ide
collects instances and stores them with their respective type class.
There's no way to retrieve these yet, but we will extend the protocol soon.
psc-ide
shouldn't crash when building a non-existent file) (@kRITZCREEK)purs ide
imports list (@nwolverson)--debug
option (@kRITZCREEK)purs repl
.purs-repl
file support (@paf31):clear
(@noraesae)let
(@noraesae)everythingWithScope
traversal bug #2718 (@paf31)Generic
deriving with synonyms (@paf31)--dump-corefn
(@paf31)purs publish
(@mcoffin)purs publish --dry-run
(@hdgarrood)keepImp
(@paf31)nub
with ordNub
(@matthewleon)HasCallStack
to internalError (@alexbiehl)Published by paf31 over 7 years ago
Release candidate. Use 0.11.0 instead.
Published by paf31 over 7 years ago
This release contains a bug fix for a bug in psc-bundle
which was introduced in 0.10.6.
Published by paf31 over 7 years ago
Warn
type class (@LiamGoodacre, blog post)unsafePartial
(@paf31)bind
is brought into scope inside do
(@paf31)--dump-corefn
(@paf31)TypeLevelString
/TypeConcat
should not be quoted (@michaelficarra)negateInt
(@paf31)psc-ide
psc-ide
imports list (@nwolverson)psc-publish
psc-publish --dry-run
(@hdgarrood)psc-publish
(@hdgarrood)psc-publish
JSON (@hdgarrood)Docs.Bookmarks
(@hdgarrood)Map.foldlWithKey'
instead of foldl
(@hdgarrood)Language.PureScript.Docs
(@hdgarrood)HasCallStack
to internalError
(@alexbiehl)psc-package
to use turtle 1.3 (@taktoa)JSAccessor
; replace with JSIndexer
(@michaelficarra)RenderedCode
(@hdgarrood)Published by paf31 almost 8 years ago
PSString
(@hdgarrood)bower-json
to 1.0.0.1 (@hdgarrood)Published by paf31 almost 8 years ago
Functor
(@LiamGoodacre, #2515)
The Functor
type class can now be derived using the standard derive instance
syntax:
newtype F a = F { foo :: Array a, bar :: a }
derive instance functorF :: Functor F
(@LiamGoodacre, #2486)
Custom kinds can now be defined using the foreign import kind
syntax:
foreign import kind SymbolList
Custom kinds can be ascribed to types using foreign import data
declarations, as usual:
foreign import data Nil :: SymbolList
foreign import data Cons :: Symbol -> SymbolList -> SymbolList
Note that kind arguments are not supported.
User defined kinds can be imported/exported using the kind
prefix, for example:
import Type.SymbolList (kind SymbolList)
psc-bundle
(@nwolverson)
psc-bundle
will now generate source maps if the--source-maps
flag is used.
CompareSymbol
and AppendSymbol
(@LiamGoodacre, #2511)
Support for the new purescript-typelevel-prelude
library has been added to the compiler. CompareSymbol
and AppendSymbol
constraints will now be solved automatically for literal symbols.
psc-package
Features(@paf31)
Two new commands have been added to psc-package
to support library authors and package set curators.
updates
command (#2510) is used to update packages in the set.verify-set
command (#2459) is used to verify the health of a package set. This command replicates the work done by the package-sets
CI job, and can be used to test modifications to the package set locally before making a pull request.--node-path
option to PSCi to modify the path to the Node executable (#2507, @paf31)Prim
docs to the library (#2498, @hdgarrood)KindedType
when instance solving (@LiamGoodacre)psc-ide
tests on windows (@kRITZCREEK)Text
in the Docs
modules (#2502, @hdgarrood)turtle
, fixes #2472, (@hdgarrood)language-javascript
(@hdgarrood)Published by paf31 almost 8 years ago
IsSymbol
instances(@LiamGoodacre)
The compiler will now derive Data.Symbol.IsSymbol
instances for type-level string literals.
This enables interesting type-level programming features, such as deriving Show
instances using Data.Generics.Rep
.
(@LiamGoodacre)
The compiler now allows rows to appear in type class instance heads, but only in type arguments which are fully determined by some functional dependency.
This allows instances like
MonadState { field :: Type } MyAppMonad
and also Newtype
instances for newtypes which contain records.
(@kRITZCREEK)
The use of String
has been replaced by Text
in the compiler, resulting in some non-trivial performance improvements.
psc-docs
output(@soupi, #2439)
psc-docs
now includes functional dependency information when rendering type classes.
psc-package
Commandsavailable
command (@andyarvanitis) shows all available packages in the current package setuninstall
command (@joneshf) removes a package from the set of active packages and updates the package configuration file.A warning was added for shadowed type variables in type class declarations.
psc-package
: display full path in 'packages.json does not exist' error messsage (@andyarvanitis)writeUTF8File
in psc-bundle
(@hdgarrood)ErrorInDataBindingGroup
to include participating identifiers (@LiamGoodacre)psc-ide
psc
tests to file (@andyarvanitis, #2453)psc-package
to release bundle (@marsam)language-javascript
(@tmcgilchrist)CONTRIBUTING.md
(@osa1)Published by paf31 almost 8 years ago
This extends the typed holes error messages to include suggested replacements for a typed hole, by using type subsumption to determine which identifiers in scope are appropriate replacements.
A blog post will accompany this feature soon.
psc-package
(@paf31)This is an experimental package manager for PureScript packages. It supports the following commands:
init
- create a new project using the package set for the current compiler versionupdate
- sync the local package collection with the package setinstall
- install a specific package from the current set and add it to the package configbuild
- run psc
on any active packagessources
- list source globs for active package versionsdependencies
- list transitive dependencies of the current projectFor example:
$ psc-package init
$ psc-package install transformers
$ psc-package build
Eventually, psc-package
might replace the use of Bower, but that will require support from tools like Pulp. For now, package authors should continue to publish packages using Bower and Pursuit.
Data.Generic.Rep.Generic
Deriving (@paf31)This is an alternative generic programming implementation based on GHC.Generics
. It should allow deriving of more interesting classes, such as Semigroup
. See the purescript-generics-rep
package for examples.
Data.Array.unsafeIndex
(@brandonhamilton)TypeLevelString
when checking orphans (@joneshf)lens
(@kRITZCREEK)Language.PureScript.Interactive.IO
(@phiggins)Text
(@kRITZCREEK)Published by paf31 about 8 years ago
The new functional dependencies feature fixes type inference in some cases involving multi-parameter type classes. However, due to a bug in the compiler, some of those expressions were previously type checking where they should not have. As a result, it is necessary to add functional dependencies to some classes in order to make previous code type-check in some cases. Known examples are:
MonadEff
and MonadAff
MonadState
, MonadReader
, and the rest of the MTL-style classes in transformers
Data.Newtype
Deriving(@garyb)
It is now possible to derive the Newtype
class for any data declaration which is a newtype
, using the existing deriving instance
syntax:
newtype Test = Test String
derive instance newtypeTest :: Newtype Test _
Note that the second type argument should be specified as a wildcard, and will be inferred.
(@FrigoEU)
The Prim
module now defines the TypeString
and TypeConcat
type constructors, which can be used to build more descriptive error messages which can depend on types, using the Fail
constraint:
instance cannotShowFunctions
:: Fail ("Function type " <> TypeString (a -> b) <> " cannot be shown.")
=> Show (a -> b) where
show _ = "unreachable"
infixl 6 type TypeConcat as <>
--dump-corefn
(@rightfold)
The compiler now supports the --dump-corefn
option, which causes the functional core to be dumped in output/**/corefn.json
. This should be useful for implementing new backends which interpret the functional core.
(@paf31)
It is now possible to derive type class instances for newtype
s, by reusing the instance for the underlying type:
newtype X = X String
derive newtype instance showX :: Show X
Note that it is possible to derive instances for multi-parameter type classes, but the newtype must only appear as the last type argument.
_.a.b
)(@rvion)
Anonymous record accessor syntax has been extended to work with chains of one or more accessors:
getBaz = _.foo.bar.baz
The type class solver now supports functional dependencies. A multi-parameter type class can define dependencies between its type arguments by using the ->
operator:
class Stream el s | s -> el where
cons :: el -> (Unit -> s) -> s
uncons :: s -> { head :: el, tail :: s }
Here, the s
and el
type arguments are related by a single functional dependency, which ensures that there is at most one instance for any given type s
. Alternatively, the type s
determines the type el
, i.e. there is an implicit function from types s
to types el
. This information can be used by the solver to infer types where it was previously not possible.
See the following examples for more information:
psc-bundle
(@kRITZCREEK)UnusedDctorImport
warning (@FrigoEU)$
and #
operators (@garyb)everywhereOnTypesTopDown
(@ianbollinger)aeson-1.0
(@phadej)http-client-0.5
(@phadej)desugarDecl
from Sugar.ObjectWildcards
(@rvion)ObjectGetter
and update doc (@rvion)Published by paf31 about 8 years ago
Published by paf31 about 8 years ago
Published by paf31 over 8 years ago
@kRITZCREEK has added the ability to return position information for expressions in psc-ide
. This can be used to implement a Goto Definition feature in IDEs which use psc-ide-server
as the backend.
(@paf31)
PSCi now features an alternative backend, which can run commands in the browser via a websocket. To use this mode, simply pass the --port
option on the command line:
$ pulp psci --port 9000
and open your web browser to localhost
on that port.
See https://github.com/paf31/psci-experiment for a demonstration.
psc-ide
architecture changes@kRITZCREEK has worked on changing the architecture of psc-ide
generally, to load data in multiple phases and asynchronously. This enables new features like Goto Definition above.
pipes
version 4.2 (@felixonmars)psc-ide
Published by paf31 over 8 years ago
PureScript 0.9.1 is a major stable release of the compiler. It removes features which were deprecated in the 0.8.x series, and contains several useful enhancements and bug fixes.
This release will be accompanied by new releases of the core libraries and a compatible version of Pulp, which have been updated to work with this version.
Due to the relatively large number of breaking changes, library authors are advised that they will probably need to update their libraries to maintain compatibility. Users may prefer to continue using version 0.8.5 until their dependencies have been updated.
(@garyb)
The way names are resolved has now been updated in a way that may result in some breakages. The short version is: now only names that have been imported into a module can be referenced, and you can only reference things exactly as you imported them.
Some examples:
Import statement | Exposed members |
---|---|
import X |
A , f
|
import X as Y |
Y.A Y.f
|
import X (A) |
A |
import X (A) as Y |
Y.A |
import X hiding (f) |
A |
import Y hiding (f) as Y |
Y.A |
Qualified references like Control.Monad.Eff.Console.log
will no longer resolve unless there is a corresponding import Control.Monad.Eff.Console as Control.Monad.Eff.Console
. Importing a module unqualified does not allow you to reference it with qualification, so import X
does not allow references to X.A
unless there is also an import X as X
.
Although the new scheme is stricter it should be easier to understand exactly what the effect of any given import statement is. The old resolution rules for qualified names were obscure and unexpected results could arise when locally-qualified module names overlapped with "actual" module names.
Module re-exports have also been tightened up as a result of these rules. Now if module X
is only imported as Y
, the re-export must list module Y
also. If a module is imported without being re-qualified then the original name is used.
(@garyb, @paf31)
The compiler will now generate an error for a missing Partial
constraints, where it would previously have issued a warning.
(@garyb, @paf31)
These restrictions will allow us to improve incremental build times in future, since we will only need to parse a small prefix of each file in order to figure out what needs to be rebuilt. Right now, we need to parse every file fully.
(@paf31)
Foreign modules are now found by filename rather than by searching for a custom JavaScript comment. The foreign module is found by changing the extension of the corresponding PureScript module from .purs
to .js
.
This change was made to be more consistent with psc-ide
, and also to adopt a simple convention which will port well to other backends.
(@garyb)
All operators must be defined as aliases from now on. That is, it is no longer valid to define an operator as a name in local scope (e.g. let (#) x y = x y in ...
). This change makes it possible to generate better JavaScript code for operators, by desugaring them to the functions they alias.
Deprecated class import/export syntax has been removed (@LiamGoodacre). Classes are now imported using the class
keyword, and exported similarly:
import Prelude (class Show, show)
Remove support for =
in record binders (@paf31).
Record binders such as
f { x = 0 } = true
are no longer supported. Record binders must now use :
instead:
f { x: 0 } = true
Prim.Object
has been renamed to Prim.Record
(#1768, @paf31)
(@paf31)
Constraints can now contain type-level strings which can be used as custom error messages using the Fail
constraint. For example, one can now document the fact that foreign types such as JSDate
cannot be made instances of Generic
:
instance dateIsNotGeneric
:: Fail "JSDate is not Generic. Consider using Int with toEpochMilliseconds instead."
=> Generic JSDate where
fromSpine = crashWith "fromSpine: unreachable"
toSpine = crashWith "toSpine: unreachable"
toSignature = crashWith "toSignature: unreachable"
Attempting to derive a Generic
instance for a type containing JSDate
will then result in
A custom type error occurred while solving type class constraints:
JSDate is not Generic. Consider using Int with toEpochMilliseconds instead.
(#2070, @paf31)
Typed hole error messages now include the types of any names in scope, to assist with type-driven development:
> :t \x -> maybe 0 ?f x
Error found:
in module $PSCI
at line 1, column 8 - line 1, column 22
Hole 'f' has the inferred type
t0 -> Int
in the following context:
it :: Maybe t0 -> Int
x :: Maybe t0
in value declaration it
where t0 is an unknown type
psc-ide
, which improves completion support for editor plugins. (@kRITZCREEK)reset
command was added to psc-ide
(@kRITZCREEK)MissingTypeDeclaration
and TypeWildCard
warnings (@nwolverson)(@paf31)
psc-ide
. This means that the :load
and :foreign
commands have been removed, since dependencies are fixed and pre-compiled when PSCi loads.purescript-psci-support
for its supporting code.Types and values will now be highlighted in error messages, when the terminal supports it (MacOS and Linux for now) (@soupi).
Prime characters are now allowed in type names. (@garyb)
(..)
(@garyb):show import
were fixed (@LiamGoodacre)psc-ide
(#2064, @kika)psc-publish
were improved (@hdgarrood)main
function (@hdgarrood)NoImplicitPrelude
and enable some global extensions (@garyb)Published by paf31 over 8 years ago
This is pre-release software
This release is provided so that library developers can test the new compiler features.
Published by paf31 over 8 years ago
Fast recompilation for single files in psc-ide-server
#1712 (@kRITZCREEK, @paf31)
The pscid
project makes use of this to watch files as you work and raise errors and warnings when they occur with near instant feedback.
Operator aliases can now be declared for types #416 (@garyb)
infixr 6 type Natural as ~>
Underscore wildcards can now be used in case
and if
expressions #1558 (@garyb)
case _ of
Something -> ...
-- underscores can optionally be used in any part of an `if` expression
cond = if _ then _ else _
picker = if _ then "x" else "y"
Typed holes #1283 (@garyb)
example :: forall a. Maybe a -> Unit
example ma = ?umm
Hole 'umm' has the inferred type
Unit
in value declaration example
You can use any identifier name after the question mark and that will be used to label the hole in the raised error message.
x :: a == y
will be now parsed as x :: (a == y)
instead of (x :: a) == y
.psc-publish
now allows publishing of packages with a valid SPDX license field in bower.json
#1985 (@hdgarrood)psc-ide
now creates the output
folder on startup if it is missing #2030 (@kRITZCREEK)DuplicateSelectiveImport
would not fire when it should #2004 (@garyb)hiding
import will no longer raise an "unspecified imports" error #2017 (@garyb)psci
now shows qualified imports correctly #2040 (@LiamGoodacre)Published by paf31 over 8 years ago
This is an interim bug fix release before 0.9.0.
Check that FFI imports match with implementations (@hdgarrood)
This is technically a breaking change, since some existing code might fail to compile if it has missing FFI code (purescript-dom
is an example), but these libraries should be fixed soon.
Import helper commands in psc-ide (@kRITZCREEK)
Published by paf31 over 8 years ago
Infer types with class constraints (@paf31)
For example, this simple code would previously have failed with a confusing NoInstanceFound
error:
add x y = x + y
The compiler will now infer the most general type, namely forall a. (Semiring a) => a -> a -> a
.
Note that constraints can only be inferred if they only mention type variables; inference of arbitrary types in constraints is not (yet) supported. So, for example, you would still have to write a type signature for a function which had a constraint such as (MonadEff (console :: CONSOLE | eff) m)
.
Default require path to ../
(@nwolverson)
The previous default behavior was no require path prefix, which was confusing for some workflows. The new default is ../
, which is the prefix used in purs-loader
. This option will be removed completely in 0.9.
Expose hiding import suggestion in JSON (@nwolverson)
Error on missing LICENSE
file or missing license field in bower.json
(@faineance)
true
not being treated as an infallible guard (@garyb)--help
commands to the psc-ide
executables (@kRITZCREEK)acceptCommand
(@kRITZCREEK)optparse-applicative
dependency was updated to >= 0.12.1
(@stevejb71)bower-json
dependency was bumped (@hdgarrood)psc-publish
tests (@kRITZCREEK)Published by paf31 over 8 years ago
None
psc-ide
is now distributed with the compiler! (@kRITZCREEK)
The psc-ide-server
and psc-ide-client
executables are now maintained and
distributed alongside the compiler. This will ensure that the externs file
format used by psc-ide-server
is kept in sync with changes in the compiler.
Source maps (@nwolverson)
Source maps can be generated using the --source-maps
flag. See the
example repository for a full demonstration of source maps using Webpack.
Operator aliases for data constructors (@garyb)
Aliases can now be defined for data constructors. For example:
data List a = Nil | Cons a (List a)
infixr 6 Cons as :
Here, the :
operator can be used as a function to replace the Cons
constructor,
and also in binders.
Eq
and Ord
deriving (@paf31)
Eq
and Ord
instances can now be derived, using the derive instance
syntax:
derive instance eqList :: (Eq a) => Eq (List a)
derive instance ordList :: (Ord a) => Ord (List a)
Types are now inferred in psc-docs
and psc-publish
(@hdgarrood)
If type annotations are missing in source files, they will be inferred by
psc-docs
and psc-publish
before documentation generation.
Initial version of new syntax for operator sections (#1846, @paf31)
Operator sections can now be written using underscores. For example:
decrementAll :: Array Int -> Array Int
decrementAll = map (_ - 1)
which is equivalent to:
decrementAll :: Array Int -> Array Int
decrementAll = map (\x -> x - 1)
Allow one open import without warning (@garyb)
Warnings for open imports were a pain point for some users after the 0.8 release.
This change allows a single open import without a warning. This is still safe
in the presence of dependency updates, and does not lead to ambiguity for editor
plugins searching for declaration sites.
Published by paf31 over 8 years ago
You are recommended to use v0.8.2 instead.