A strongly-typed language that compiles to JavaScript
OTHER License
Bot releases are visible (Hide)
Published by JordanMartinez over 3 years ago
New features:
Display kind signatures and their comments in documentation (#4100 and #4119 by JordanMartinez)
The compiler now displays kind signatures for data, newtype, type
synonym, and type class declarations in generated documentation. The
compiler now also includes documentation-comments (i.e. those which start
with a |
character) both above and below the associated kind signature
declaration (if any) in generated documentation, whereas previously
documentation-comments above a kind signature declaration were ignored.
Both explicitly declared and inferred kinds are included in documentation.
The compiler omits including a kind signature in generated documentation
only when the kind is considered "uninteresting". An uninteresting kind is
defined as one where all of the declaration's type parameters have kind
Type
.
Bugfixes:
Ensure unnamed instances appear in documentation (#4109 by @JordanMartinez)
Allow fixity, kind, role declarations in REPL (#4046, @rhendric)
Pin OS versions used in CI (#4107, @f-f)
Fix UnusedName warnings for multiple non-recursive let bindings (#4114 by @nwolverson)
Remove generated names from errors about instances (#4118 by @rhendric)
Internal:
Fix for Haddock (#4072 by @ncaq and @JordanMartinez, #4139 by @JordanMartinez)
Update RELEASE_GUIDE.md with more details (#4104 by @JordanMartinez)
Use GenIdent for anonymous instances (#4096, @rhendric)
Desugar type class instance names in type class desugaring pass (#4099 by @JordanMartinez)
Published by JordanMartinez over 3 years ago
Make type class instance names optional (#4085, @JordanMartinez)
Previously, one would be required to define a unique name for a type class
instance. For example
-- instance naming convention:
-- classNameType1Type2Type3
instance fooIntString :: Foo Int String
Now, the name and ::
separator characters are optional. The above instance
could be rewritten like so:
instance Foo Int String
and the compiler will generate a unique name for the instance
(e.g. $dollar_FooIntString_4
where 4
is a randomly-generated number
that can change across compiler runs). This version of the instance name
is not intended for use in FFI.
Note: if one wrote
instance ReallyLongClassName Int String
the generated name would be something like
$dollar_ReallyLongClassNameIntStr_87
rather than
$dollar_ReallyLongClassNameIntString_87
as the generated part
of the name will be truncated to 25 characters (long enough to be readable
without being too verbose).
Unused identifier warnings now report smaller and more relevant source spans (#4088, @nwolverson)
Also fix incorrect warnings in cases involving a let-pattern binding shadowing
an existing identifier.
Drop libtinfo dependency (#3696, @hdgarrood)
Changes the build configuration so that by default, compiler binaries will
not have a dynamic library dependency on libncurses/libtinfo. This should
alleviate one of the most common pains in getting the compiler successfully
installed, especially on Linux. The cost is a slight degradation in the REPL
experience when editing long lines, but this can be avoided by building the
compiler with the libtinfo dependency by setting the terminfo
flag of the
haskeline
library to true
.
Migrate CI from Travis to GitHub Actions (#4077, @rhendric)
Remove tasty from test suite and just use hspec (#4056, @hdgarrood)
Avoid compiling tests with diagnostics twice in test suite (#4079, @hdgarrood)
Do less work in test initialization (#4080, @rhendric)
Follow more HLint suggestions (#4090, @rhendric)
Export rebuildModule'
to speed up Try PureScript! slightly (#4095 by @JordanMartinez)
Merge purescript-ast
into purescript-cst
(#4094 by @JordanMartinez)
Published by hdgarrood over 3 years ago
Support TCO for functions with tail-recursive inner functions (#3958, @rhendric)
Adds support for optimizing functions that contain local functions which call
the outer function in tail position, as long as those functions themselves
are only called from tail position, either in the outer function or in other
such functions.
This enables hand-written mutually-tail-recursive function groups to be
optimized, but more critically, it also means that case guards which desugar
to use local functions don't break TCO.
Add warnings for unused names and values (#3819, @nwolverson)
The compiler now emits warnings when it encounters unused names in binders
and unused value declarations. A declaration is considered to be unused if it
is not exported and is also not reachable by any of the exported
declarations. The compiler will not currently produce unused warnings about
other kinds of declarations such as data and type class declarations, but we
intend to produce warnings for these in the future as well.
Make close punctuation printable in errors (#3982, @rhendric)
Desugar type operators in top-level kind signatures (#4027, @natefaubion)
Use type annotation hint only when needed (#4025, @rhendric)
Fix pretty printing of "hiding" imports (#4058, @natefaubion)
Instantiate polymorphic kinds when unwrapping newtypes while solving Coercible constraints (#4040, @kl0tl)
Fix row unification with shared unknown in tails (#4048, @rhendric)
Fix kinded declaration reordering in desugaring (#4047, @rhendric)
Fix wildly off kind unification positions (#4050, @natefaubion)
Fix incorrect incremental builds with different --codegen
options (#3911, #3914, @hdgarrood)
This bug meant that after invoking the compiler with different --codegen
options, it was easy to end up with (for example) an outdated docs.json or
corefn.json file in your output directory which would be incorrectly
considered up-to-date by the compiler.
Add white outline stroke to logo in README (#4003, @ptrfrncsmrph)
The previous logo.png
was not legible against a dark background (#4001).
Show the constraints that were being solved when encountering a type error (@nwolverson, #4004)
Removed all shift/reduce conflicts in parser (#4063, @JordanMartinez).
Happy defaults to using "shift" rather than "reduce" in shift/reduce
conflicts. This change merely makes explicit what is already happening
implicitly.
Published by kl0tl over 3 years ago
Polymorphic kinds, based on the Kind Inference for Datatypes paper (#3779, #3831, #3929, #4007, @natefaubion, @kl0tl)
Just as types classify terms, kinds classify types. But while we have polymorphic types, kinds were previously monomorphic.
This meant that we were not able to abstract over kinds, leading for instance to a proliferation of proxy types:
data Proxy (a :: Type) = Proxy
data SProxy (a :: Symbol) = SProxy
data RProxy (row :: # Type) = RProxy
data RLProxy (row :: RowList) = RLProxy
Now we can have a single proxy type, whose parameter has a polymorphic kind.
The old Kind
data type and namespace is gone. Kinds and types are the same and exist in the same namespace.
Previously one could do:
foreign import kind Boolean
foreign import data True :: Boolean
foreign import data False :: Boolean
Where the kind Boolean
and type Boolean
were two different things. This is no longer the case. The Prim
kind Boolean
is now removed, and you can just use Prim
type Boolean
in the same way. This is a breaking change.
The compiler still supports the old foreign import kind
syntax but it warns that it's deprecated.
foreign import kind Foo
Foreign kind imports are deprecated and will be removed in a future release. Use empty 'data' instead.
It is treated internally as:
data Foo
Note that foreign import data
declarations are not deprecated. They are still necessary to define types with kinds other than Type
since constructors are not lifted as in GHC with DataKinds.
Likewise, kind
imports and exports are deprecated and treated the same as a type import or export.
Kind imports are deprecated and will be removed in a future release. Omit the 'kind' keyword instead.
The special unary #
syntax for row kinds is still supported, but deprecated and will warn. There is now Prim.Row :: Type -> Type
which can be used like a normal type constructor.
Unary '#' syntax for row kinds is deprecated and will be removed in a future release. Use the 'Row' kind instead.
All of these deprecations have suggested fixes in the JSON output, so tools like purescript-suggest
(or your IDE plugin) can automatically apply them.
With PolyKinds, all type-level declarations are generalized.
data Proxy a = Proxy
Previously, this had the Type
-defaulted kind Type -> Type
. Now this will be generalized to forall k. k -> Type
. Such signature can be written with a kind signature declarations, similar to standalone kind signatures in GHC.
data Proxy :: forall k. k -> Type
data Proxy a = Proxy
In GHC, all signatures use the type
prefix, but we reuse the same keyword as the subsequent declaration because we already have foreign import data
(rather than foreign import type
) and because it makes things align nicer. Signatures have the same rule as value-level signatures, so they must always be followed by the "real" declaration.
It's better to be explicit about polymorphism by writing signatures. Since we don't really quantify over free type variables, it's also necessary in the case that two poly-kinded arguments must have the same kind. The compiler will warn about missing kind signatures when polymorphic kinds are inferred.
Classes can have signatures too, but they must end with the new Constraint
kind instead of Type
. For example, here's the new definition of Prim.Row.Cons
:
class Cons :: forall k. Symbol -> k -> Row k -> Row k -> Constraint
class Cons label a tail row | label a tail -> row, label row -> a tail
Coercible constraints, based on the Safe Zero-cost Coercions for Haskell paper (#3351, #3810, #3896, #3873, #3860, #3905, #3893, #3909, #3931, #3906, #3881, #3878, #3937, #3930, #3955, #3927, #3999, #4000, @lunaris, @rhendric, @kl0tl, @hdgarrood)
Prim.Coerce.Coercible
is a new compiler-solved class, used to relate types with the same runtime representation. One can use Safe.Coerce.coerce
(from the new safe-coerce
library) instead of Unsafe.Coerce.unsafeCoerce
to safely turn a a
into a b
when Coercible a b
holds.
Types parameters now have roles, which depend on how they affect the runtime representation of their type. There are three roles, from most to least restrictive:
nominal parameters can only be coerced to themselves.
representational parameters can only be coerced to each other when a Coercible constraint holds.
phantom parameters can be coerced to anything.
The compiler infers nominal roles for foreign data types, which is safe but can be too constraining sometimes. For example this prevents the coercion of Effect Age
to Effect Int
, even though they have the same runtime representation.
The roles of foreign data types can thus be loosened with explicit role annotations, similar to the RoleAnnotations GHC extension.
Here's the annotation we added to Effect
:
type role Effect representational
Conversely, we might want to strengthen the roles of parameters with invariants invisible to the type system. Maps are the canonical example of this: the shape of their underlying tree rely on the Ord
instance of their keys, but the Ord
instance of a newtype may behave differently than the one of the wrapped type so it would be unsafe to allow coercions between Map k1 a
and Map k2 a
, even when Coercible k1 k2
holds.
In order to forbid such unsafe coercion we added a nominal annotation to the first parameter of Map
:
type role Map nominal representational
Annotated roles are compared against the roles inferred by the compiler so it is not possible to compromise safety by ascribing too permissive roles, except for foreign types.
Coercible
based Newtype
(#3975, @fsoikin)We added a Coercible
superclass to Data.Newtype.Newtype
in order to implement unwrap
, wrap
and most newtype combinators with coerce
(see https://github.com/purescript/purescript-newtype/pull/22). This is only a breaking change for non derived instances because the Newtype
class has no members anymore and can now only be implemented for representationally equal types (those satisfying the new superclass constraint).
For example the instance for newtype Additive a = Additive a
no longer implements unwrap
and wrap
:
+instance newtypeAdditive :: Newtype (Additive a) a
-instance newtypeAdditive :: Newtype (Additive a) a where
- wrap = Additive
- unwrap (Additive a) = a
Derived instances don't require any modifications.
Quotes behaved rather unexpectedly in various edge cases inside raw strings. This clears things up by enforcing the following specification:
'"""' '"'{0,2} ([^"]+ '"'{1,2})* [^"]* '"""'
Meaning that raw strings can contain up to two successive quotes, any number of times, but three successive quotes are not allowed inside.
It used to be possible to match on negative literals, such as -1
, but this prevented parsing matches on constructors aliased to -
. The compiler will reject matches on bare negative literals, but they can still be matched by wrapping them in parentheses.
Exporting only some of the constructors of a type meant that changes internal to a module, such as adding or removing an unexported constructor, could cause unexhaustive pattern match errors in downstream code. Partial explicit export lists will have to be completed with the missing constructors or replaced by implicit export lists.
Compiler errors and warnings arising from your code are now printed to stdout rather than stderr, and progress messages such as "Compiling Data.Array" are now printed to stderr rather than stdout. Warnings and errors arising from incorrect use of the CLI, such as specifying input files which don't exist or specifying globs which don't match any files, are still printed to stderr (as they were before). This change is useful when using the --json-errors
flag, since you can now pipe JSON errors into other programs without having to perform awkward gymnastics such as 2>&1
.
Only include direct dependencies in the output for purs graph
instead of their transitive closure (#3993, @colinwahl)
Fix the reversal of the qualifier of qualified operators (#3971, @rhendric)
Qualified operators, for instance Data.Array.(!)
, were interpreted with a reversed qualifier, like Array.Data.(!)
.
The compiler was not catching recursive type synonyms when some recursive paths were guarded by data types or newtypes.
The compiler did not accept type operators inside parens in prefix position, except (->)
.
Allowing the compiler to be built against various versions of language-javascript
meant that multiple builds of the same version of the compiler could accept different syntaxes for JavaScript foreign modules, depending on how they were built.
The IDE server now respond with more descriptive error messages when failing to parse a command. This should make it easier to contribute fixes to the various clients.
By exposing the declaration type (value, type, typeclass, etc.) downstream tooling can annotate imports with this info so users know what they are about to import. The info can also be mapped to a namespace filter to allow importing identifiers that appear more than once in a source file which throws an exception without such a filter.
negate
isn't imported (#3952, @mhmdanas)This shows a specific message when using negative literals but Data.Ring.negate
is out of scope, similar to the messages shown when using do notation if Control.Bind.bind
and Control.Bind.discard
are out of scope.
PartiallyAppliedSynonym
errors (#3951, @rhendric)PartiallyAppliedSynonym
errors were usually rethrown with the appropriate source span, but not when deriving instances. This annotates those errors with the source span of the partially applied synonyms themselves, which is more robust and accurate than rethrowing the error with an approximate source span.
This allows declarations such as
type Env = { port :: Int }
newtype App a = App (ReaderT Env Aff a)
derive newtype instance monadAskApp :: MonadAsk Env App
or
class (Monad m, MonadAsk Env m) <= MonadAskEnv m
Generic
or Newtype
instances (#3907, @kl0tl)Types with hidden constructors are supposed to be opaque outside of their module of definition but Generic
and Newtype
instances allow to construct them with Data.Generic.Rep.to
or Data.Newtype.wrap
and examine their content with Data.Generic.Rep.from
or Data.Newtype.unwrap
, thus making void any invariant those types may witness.
This is the first step towards smarter incremental rebuilds, which could skip rebuilding downstream modules when the interface of a module did not change (see #3724).
Add a printer for CST modules (#3887, @kritzcreek)
Deprecate constraints in foreign imports (#3829, @kl0tl)
Constrained foreign imports leak instance dictionaries, hindering the compiler ability to optimize their representation. Manipulating dictionaries in foreign code should be avoided and foreign imports should accept the class members they need as additional arguments instead of being constrained.
'
character) in identifiers exported from foreign modules (#3792, @kl0tl)We are going to output ES modules instead of CommonJS in the next breaking release but named exports of ES modules, unlike CommonJS exports, have to be valid JavaScript identifiers and so cannot contain primes.
Generate a changelog from the GitHub releases and add a pull request template (#3989, @JordanMartinez)
Detail license related error messages and fix incorrect SPDX sample licenses (#3970, @fsoikin)
Remove a spurious doc comment on the CoreFn Module type (#3552, @jmackie)
Add a link to the releases page (#3920, @milesfrain)
Update CONTRIBUTING.md (#3924, @hdgarrood)
Add troubleshooting steps for libtinfo and EACCES errors (#3903, @milesfrain)
Update an outdated link to the book (#3916, @sumew)
Simplify the Ord
instances of some AST types (#3902, @milesfrain)
Update the desugaring pipeline to work on individual modules (#3944, @kl0tl)
Remove the unmaintained and ignored core libraries tests (#3861, @kl0tl)
Configure Travis to run hlint
(#3816, #3864, @joneshf, @hdgarrood)
Remove support for the legacy Bower resolutions format in purs publish
(#3847, @kl0tl)
Add GitHub issue templates for bugs and proposals (#3853, @joneshf)
Add support for Happy >=1.19.10 (#3837, @arrowd)
Use the same default extensions in all packages (#3823, #3908, @natefaubion, @i-am-the-slime)
Relax purescript-ast
dependency on microlens-platform
to microlens
(#3817, @joneshf)
Extract the AST and CST types, and related functions, into their own purescript-ast
and purescript-cst
packages for ease of consumption by external tooling (#3793, #3821, #3826, @joneshf, @natefaubion)
Fix various typos in documentation, comments and bindings names (#3795, @mhmdanas)
Add golden tests for errors and warnings (#3774, #3811, #3808, #3846, @dariooddenino, @rhendric, @kl0tl)
More descriptive protocol errors from the ide server (@kritzcreek)
Published by kl0tl almost 4 years ago
Release candidate for use in preparing for the upcoming v0.14.0 release. Release notes coming soon.
Published by hdgarrood about 4 years ago
Release candidate for use in preparing for the upcoming v0.14.0 release. Release notes coming soon.
Published by hdgarrood about 4 years ago
Release candidate for use in preparing for the upcoming v0.14.0 release. Release notes coming soon.
Published by hdgarrood over 4 years ago
Update incremental build cache information properly on IDE rebuilds (#3789, @kritzcreek)
Fixes a bug where triggering a rebuild via the IDE would not update the
output/cache-db.json
file, which in certain situations could lead to
unnecessary rebuilds, as well as modules not being rebuilt when they should
have been.
Don't include compiler-internal declarations in IDE completions (#3850, @kritzcreek)
IDE completions would previously include pseudo-declarations such as
RowToList$Dict
which only exist internally, due to how type class
desugaring inside the compiler works. These declarations are now suppressed.
Fix corefn JSON version parsing (#3877, @paulyoung)
Fixes a bug where the parser for the functional core (or "corefn") JSON
format would ignore all but the first component of the compiler version
stored in the JSON. This does not affect the compiler directly, but will be
useful for other tooling which depends on the corefn JSON parser provided by
the compiler library.
Add purs graph
subcommand for graphing module dependencies (#3781, @jmackie, @f-f)
This adds a new graph
subcommand which allows tools to consume information
about which modules depend on which other modules. The format is as follows:
{ "Prelude":
{ "path": "src/Prelude.purs"
, "depends": ["Data.Semiring", "Data.Ring", ...]
},
"Data.Ring":
{ "path": "src/Data/Ring.purs"
, "depends": []
},
...
}
Each property in the returned object has exactly two properties; path
,
which is a string containing the file path relative to the directory where
the command was run, and depends
, which is an array of the names of all
directly imported modules.
purs ide is better at reloading changes (#3799, @kritzcreek)
The IDE would previously sometimes miss changes that were made outside of the
editor, like building with new dependencies or recompiling larger parts of
the project on the console.
The IDE will now notice when this happened on the next command issued to it
and refresh its state before processing that command. This might cause the
first command after an external change to take a long time to execute, but
should increase reliability in general.
Switch to a binary encoding for externs files (#3841, @kritzcreek)
This change should result in significant performance improvements in both IDE
load times and incremental builds where lots of modules are already built.
Represent module names as a single Text value internally (#3843, @kritzcreek)
Boosts compiler performance by representing module names as a single Text
value, rather than a list of Text values as it was previously.
Extract documentation for type classes in purs ide (#3856, @kritzcreek)
This changes makes documentation comments on type classes visible to the IDE.
Published by hdgarrood over 4 years ago
release withdrawn due to CI mishap
Published by natefaubion almost 5 years ago
Reset IDE state before performing a full reload. (#3766, @kritzcreek)
This prevents a space leak in the IDE.
Added source spans to ado desugaring. (#3758, @dariooddenino)
Previously errors in ado desugaring might have had no line information.
Generate correct arity failure case for some guarded matches. (#3763, @nwolverson)
Specifically when a multi-way case contains a pattern guard or multiple
guard expressions, the desugared case expression could contain a guard with
a different arity to the matched expressions, resulting in an error.
Improved ambiguous variable check for functional dependencies. (#3721, @MonoidMusician)
Previously the compiler might warn about ambiguous variables that aren't actually ambiguous
due to functional dependencies. This check now fully takes functional dependencies into
consideration.
Optimize import desugaring for full builds (#3768, @colinwahl)
The compiler was performing redundant work when resolving dependencies for modules resulting
in poor asymptotics. This work is now shared across modules yielding a 30-40% improvement in
build times for full builds.
Use PureScript escapes in string pretty-printing (#3751, @hdgarrood)
Previously the compiler might print invalid escape sequences when pretty-printing code for
error messages. It now prints correctly escaped code based on PureScript's lexical grammar.
Optimize away binds to wildcards in do-notation (#3220, @matthewleon, @hdgarrood)
This avoids generating variable assignments if no variables are actually bound in do-notation.
Previously the compiler would emit a unique variable name that went unused.
Output docs.json files for Prim modules (#3769, @f-f)
This change allows downstream tools such as spago to obtain documentation data for Prim modules.
Please note, however, that the API for the docs.json files is unstable and may change without warning.
This is a small bugfix release to address some issues which were introduced in 0.13.4.
Fix "too many open files" during compiling (#3743, @hdgarrood)
The compiler would not promptly close files after opening them, which could easily lead to reaching the open file limit, causing the compiler to crash.
Fix incorrect unused import warnings when kinds are re-exported (#3744, @hdgarrood)
Fixes a bug in which unused import warnings were generated for kinds which were re-exported (and therefore should have been considered "used").
Published by hdgarrood almost 5 years ago
Use content hashes when determining whether a file needs rebuilding (#3708, @hdgarrood)
We now calculate and store content hashes of input files during compilation. If a file's modification time has changed since the last compile, we compare the hash to the previous hash; if the hash is unchanged, this allows us to skip rebuilding this file, speeding up the build.
Include import declaration qualifiers in unused import warnings (#3685, @matthew-hilty)
Previously, warnings didn't distinguish between import declarations from the same module. Code like the following
import A.B (x) -- `x` is used.
import A.B (y) as C -- `y` is not used.
would induce a warning like The import of module A.B is redundant
even though only the qualified import declaration C
is actually redundant. The warning now would be The import of module A.B (qualified as C) is redundant
.
Include kind imports when determining unused import warnings (#3685, @matthew-hilty)
Previously, kind imports were ignored. The linter wouldn't emit any warnings for code like the following.
import A.B (kind K) -- `kind K` is not used.
And the linter, disregarding kind K
, would emit an UnusedImport
instead of an UnusedExplicitImport
for code like the following.
import A.B (x, kind K) -- `x` is not used, but `kind K` is.
Better reporting of I/O errors (#3730, @hdgarrood)
If an unexpected I/O error occurs during compiling, we now include details in the error message. For example, when trying to write compilation results onto a device which has run out of space, we previously would have received a "CannotWriteFile" error with no further information. Now, we receive the underlying error message too:
I/O error while trying to write JSON file: ./output/cache-db.json
./output/cache-db.json: hClose: resource exhausted (No space left on device)
Improve type class resolution in the presence of constrained higher-order functions (#3558, @matthew-hilty)
This is perhaps best illustrated with an example.
newtype LBox row a = LBox (∀ r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ SProxy lbl → r) → r)
unLBox ∷ ∀ row a r. (∀ lbl _1. Row.Cons lbl a _1 row ⇒ IsSymbol lbl ⇒ SProxy lbl → r) → LBox row a → r
unLBox g (LBox f) = f g
read ∷ ∀ row a. Record row → LBox row a → a
read rec = unLBox \lbl → Record.get lbl rec
The read
function would previously fail with the error
No type class instance was found for
Prim.Row.Cons lbl4
a5
t2
row6
although that dictionary should have been available in the function passed to unLBox
. Now, it type checks successfully.
Fix cache invalidation false negatives by storing timestamps (#3705, @hdgarrood)
Previously, an input file would be considered 'modified', and thus requiring rebuilding on a subsequent compile, if its modification time specifies a point in time after any of the modification times of the corresponding output files. This has turned out to be insufficient; files can often change in a way that this algorithm misses, because the input file might still have a timestamp older than the output files. Often this can happen by switching between git
branches or by updating a dependency.
This problem can manifest as compiler errors which don't appear to make sense or correspond to what is inside a source file, and which (until now) would need to be fixed by a clean rebuild (e.g. rm -r output
).
We now make a note of the modification time when we read an input file, and we consider that input file to have changed on a subsequent compile if the modification time is different to what it was before.
The hope with this fix is that it should never be necessary to remove an output directory to get a build to run successfully. If you do run into this problem again, it is a bug: please report it.
Fix exports incorrectly being identified as unused in purs bundle (#3727, @rhendric)
References to properties on the exports
object would previously not be picked up by purs bundle
as uses of those properties, which could lead to them being incorrectly removed. For example:
'use strict';
exports.foo = 1;
exports.bar = exports.foo;
would remove the exports.foo = 1;
statement, breaking the assignment to exports.bar
, if foo
were not used elsewhere. This statement is now no longer removed.
Show entire rows in type errors in the presence of the --verbose-errors
flag (#3722, @Woody88)
The row diffing feature, which elides common labels in rows occurring in type errors, did not previously respect the --verbose-errors
flag, giving the same output regardless of whether it was set or not. Now, if the flag has been supplied, we always show the entire row.
Add Makefile command to run license generator (#3718, @hdgarrood)
Update language-javascript to 0.7.0.0 (@rhendric, @hdgarrood)
This enables a number of newer JavaScript syntactic constructs to be used in FFI files. Please see the language-javascript release notes for details.
Fix for object shorthand syntax in FFI files (#3742, @hdgarrood)
Eliminate empty type class dictionaries in generated code (#2768, @LiamGoodacre)
Empty type class dictionaries — dictionaries which do not contain any type class member implementations at runtime — are often used to provide evidence at compile-time to justify that a particular operation will not fail; for example, Prim.Row.Cons
can be used to justify that we can expect a record to contain a particular field with a particular type. Unfortunately, constructing empty dictionaries can be costly, especially in more complex scenarios such as type-level programming. This release implements a new optimization which avoids the need to build empty dictionaries at runtime by instead inserting undefined
into the generated code. This optimization can both reduce code size and improve performance in certain contexts.
Render doc-comments for data constructors and type class members in HTML documentation (#3507, @marcosh)
Documentation comments for data constructors and type class members are now picked up by purs docs
, and will soon start appearing in Pursuit too. For example:
-- | Doc-comments like this one were always rendered in Pursuit
data Maybe a =
-- | Now this one (for the Just constructor) will be rendered too
= Just a
-- | And this one (for Nothing)
| Nothing
-- | Doc-comments like this one were always rendered in Pursuit
class Eq a where
-- | Now this one (for the `eq` method) will be rendered too
eq :: a -> a -> Boolean
Show diffs of rows in errors and hints (#3392, @dariooddenino)
In type mismatches between rows, we now elide common labels so that the problem is easier to identify. For example, consider the following code, which has a type error due to the types of the b
fields in the two records not matching:
foo =
{ a: 1, b: "hi", c: 3, d: 4, e: 5 }
bar =
{ a: 1, b: 2, c: 3, d: 4, e: 5 }
baz =
[ foo, bar ]
Previously, the type error would include the entirety of each record type:
Could not match type
String
with type
Int
while trying to match type ( a :: Int
, b :: String
, c :: Int
, d :: Int
, e :: Int
)
with type ( a :: Int
, b :: Int
, c :: Int
, d :: Int
, e :: Int
)
This can become quite difficult to read in the case of large record types. Now, we get this:
Could not match type
String
with type
Int
while trying to match type
( b :: String
...
)
with type
( b :: Int
...
)
Remove more dead code in purs bundle
(#3551, @rhendric)
The dead code elimination in purs bundle
now no longer incorrectly considers declarations to be used in the presence of local variables which happen to share their names, and is therefore able to remove these declarations when they are unused.
Fix parsing of comma-separated guards in let statements (#3713, @natefaubion)
The 0.13 parser would previously choke on guards separated by commas in let statements within do/ado blocks, such as
test = ado
let
foo
| bar
, baz =
42
| otherwise = 100
in
foo
This has now been fixed.
Published by hdgarrood over 5 years ago
Add --debug flag to purs bundle
command (#3666, @rhendric)
This flag causes an optimized-for-humans JSON representation of the modules
being bundled to be dumped to stderr, prior to dead code elimination.
Ignore duplicate file inputs to CLI commands (#3653, @dyerw)
If, after expanding globs, a particular file path appears more than once, the
compiler will now ignore the extra occurrences, instead of emitting a
DuplicateModule
error.
Published by hdgarrood over 5 years ago
Notice: This release has been unpublished due to an error in the package tarball.
Published by natefaubion over 5 years ago
0.13
is a very exciting release for me (@natefaubion). For the past few months I've been working on a complete rewrite of the existing parser. The old parser has served us very well, but it has grown very organically over the years which means it's developed some unsightly limbs! Throughout the process I've tried to iron out a lot of dark corner cases in the language grammar, and I hope this release will set us on a firm foundation so we can start to specify what "PureScript the Language" actually is. This release is definitely breaking, but I think you'll find the changes are modest. I also hope that this release will open up a lot of opportunities for syntactic tooling, both using the existing parser or even using alternative parsers (which are now possible).
There are a number of breaking changes, but I think you'll find that most code will continue to parse fine. We've tested the parser against the existing ecosystem and several large production applications at Awake, Lumi, and SlamData. The migration burden was either non-existent or only involved a few changes.
\n\r\t\'\"\\
, \x[0-9a-fA-F]{1,6}
(unicode hex escape), and \[\r\n ]+\
(gap escapes). We had inherited a vast zoo of escape codes from the Parsec Haskell Language parser. We decided to minimize what we support, and only add things back if there is significant demand.\
is no longer a valid operator. It conflicts with lambda syntax.@
is no longer a valid operator. It conflicts with named binder syntax.forall
is no longer a valid identifier for expressions. We wanted a consistent rule for type identifiers and expression identifiers.a@Foo b
must be a@(Foo b)
).a :: Type -> Type b :: Type
must now be (a :: Type -> Type) (b :: Type)
).::
has lowest precedence, rather than sitting between operators and function application).where
is still only sugar for let
(it does not introduce bindings over guards), but it is now usable in case
branches in the same manner as declarations._
is now allowed in numeric literals, and is an ignored character (ie. 1_000_000 == 1000000
)."""hello "world"""" == "hello \"world\""
).forall
contexts (#3576 @colinwahl).purs compile
. This means that time to start compiling is faster, and incremental builds are faster. In my testing, a noop call to purs compile
on the Awake codebase went from ~10s to ~3s.TransitiveExportError
for a class (#3612 @colinwahl).docs
is now a codegen target for purs compile
where documentation is persisted as a docs.json
file in the output
directory.NoMonadFailDesugaring
extension (#3610 @adnelson).This small release fixes three issues which were introduced in 0.12.4.
When determining candidates for imports, ignore modules. This allows you to easily import types which come from modules of the same name, like Effect
. (@kRITZCREEK)
Running purs ide server
on macOS would immediately crash with the error purs: Network.Socket.listen: unsupported operation (Operation not supported on socket)
; this has now been fixed. (@f-f)
When checking for cycles in type classes, the compiler is now able to distinguish classes which have come from different modules, meaning that e.g. class SomeOtherModule.Foo <= Foo
is no longer incorrectly reported as a class having itself as a superclass. (@hdgarrood)
Published by hdgarrood over 5 years ago
This means we can now complete module names with the completion API as well as being able to query for module level documentation and goto-defintion for module names.
The list loadedModules command has also been deprecated, since you can now use the completion command with a filter for modules instead. (@kRITZCREEK)
Large types in error messages are now truncated. For example:
module Main where
data Id a = Id a
foo :: Id (Id (Id (Id (Id Int))))
foo = "hi"
now produces
Could not match type
String
with type
Id (Id (Id (... ...)))
The previous behaviour of printing the types in full may be recovered by passing the --verbose-errors
flag to the compiler. (@hdgarrood)
In both CommonJS compiler output and JavaScript purs bundle
output, we no longer emit JS imports for modules whose use sites have all been optimized out. This reduces the number of warnings produced by other JavaScript bundlers or compressors such as "Side effects in initialization of unused variable Control_Category". (@rhendric)
purs publish
resolutions format (#3565)The format for resolutions files passed via the CLI to purs publish
has been simplified. A new-style resolutions file should look something like this:
{
"purescript-prelude": {
"version": "4.0.0",
"path": "bower_components/purescript-prelude"
},
"purescript-lists": {
"version": "6.0.0",
"path": "bower_components/purescript-lists"
},
...
}
The version
field is used for generating links between packages on Pursuit, and the path
field is used to obtain the source files while generating documentation: all files matching the glob "src/**/*.purs" relative to the
path
directory will be picked up.
The version
field is optional, but omitting it will mean that no links will be generated for any declarations from that package on Pursuit. The "path" field is required.
The old format is still accepted, but it has been deprecated, and purs publish
will now produce a warning when consuming it.
This change allows us to work around a bug in Bower which prevented packages with larger dependency trees (such as Halogen) from being uploaded to Pursuit (https://github.com/purescript-contrib/pulp/issues/351). (@hdgarrood)
A cycle in type class declarations, such as
class C a <= D a
class D a <= C a
now produces a more informative error, which no longer confusingly refers to type synonyms, and which displays all of the classes involved in the cycle. (@Saulukass)
PS
no longer causes JS runtime errors when using purs bundle
(#3505, @mhcurylo)purs publish
now warns instead of failing if not all dependencies have a resolved version, e.g. if some have been installed via a branch or commit reference instead of a version range (#3061, @hdgarrood)purs bundle
(#3581, @rhendric)purs bundle
(#3533, @mhcurylo)purs bundle
(#3579, @rhendric)