A strongly-typed language that compiles to JavaScript
OTHER License
Bot releases are hidden (Show)
Published by JordanMartinez 8 months ago
New features:
Add --exclude-file
to more commands (#4530 by @JordanMartinez)
This CLI arg was added to the compile
command, but not to other commands
where such a usage would be relevant (e.g. docs
, repl
, graph
, and ide
).
Enable passing source input globs via --source-globs-file path/to/file
(#4530 by @JordanMartinez)
--source-globs-file
support has been added to the following commands:
compile
, docs
, graph
, ide
, and publish
.
Due to a shell character limitation on Windows where a large list of
source globs cannot be passed (e.g. purs compile ... glob1000/src/**/*.purs
),
source globs can be stored in a file according to the format below
and the file is passed in instead via purs compile ---source-globs-file path/to/file
.
# Lines starting with '#' are comments.
# Blank lines are ignored.
# Otherwise, every line is a glob.
.spago/foo-1.2.3/src/**/*.purs
.spago/bar-2.3.3/src/**/*.purs
my-package/src/**/*.purs
my-package/tests/**/*.purs
--source-globs-file
is an optional argument. Mixing it with the normal source globs is fine.
Assuming .spago/source-globs
contains src/**/*.purs
, each command below will use
the same input globs:
purs compile src/**/*.purs
purs compile --source-globs .spago/source-globs
purs compile --source-globs .spago/source-globs src/**/*.purs
In the command...
purs compile inputGlob1 inputGlob2 --source-globs-file fileWithMoreGlobs --exclude-files excludeGlob1
the files passed to the compiler are: all the files found by
inputGlob1
, inputGlob2
, and all the globs listed in fileWithMoreGlobs
minus the files found by excludeGlob1
.
Published by JordanMartinez 10 months ago
Bugfixes:
Fix a compilation memory regression for very large files (#4521 by @mjrussell)
When compiling a a very large file (>12K lines)
the CSE pass could balloon memory and result in increased
compilation times.
This fix uses a strict Map instead of a lazy Map to avoid
building up unnecessary thunks during the optimization pass.
Fix two space leaks while compiling many modules (#4517 by @MonoidMusician)
The first would interleave compilation of too many modules at once, which
would increase memory usage, especially for single threaded builds with
+RTS -N1 -RTS
. Now the number of concurrent modules is limited to
the number of threads available to the
GHC runtime system.
The second would hold on to memory from modules that compiled with warnings
until the end of the build when the warnings were printed and the memory freed.
This is now fixed with additional NFData
instances.
Published by JordanMartinez 11 months ago
New features:
Replace UnusableDeclaration
with updated NoInstanceFound
(#4513 by @JordanMartinez)
Previously, the following type class would be invalid
because there was no way for the compiler to infer
which type class instance to select because
the type variable in the class head a
was
not mentioned in bar
's type signature:
class Foo a where
bar :: Int
The recently-added visible type applications (VTAs)
can now be used to guide the compiler in such cases:
class Foo a where bar :: Int
instance Foo String where bar = 0
someInt = bar @String -- use the `String` instance
Without VTAs, the compiler
will still produce an InstanceNotFound
error, but this error
has been updated to note which type variables in the class head
can only be disambiguated via visible type applications.
Given the following code
class Single tyVarDoesNotAppearInBody where
useSingle :: Int
single :: Int
single = useSingle
The error reported for useSingle
will be:
No type class instance was found for
Main.Single t0
The instance head contains unknown type variables.
Note: The following type class members found in the expression require visible type applications
to be unambiguous (e.g. tyClassMember @Int).
Main.useSingle
tyNotAppearInBody
For a multiparameter typeclass with functional dependencies...
class MultiFdBidi a b | a -> b, b -> a where
useMultiFdBidi :: Int
multiFdBidi :: Int
multiFdBidi = useMultiFdBidi
...the "Note" part is updated to read
Note: The following type class members found in the expression require visible type applications
to be unambiguous (e.g. tyClassMember @Int).
Main.useMultiFdBidi
One of the following sets of type variables:
a
b
Published by JordanMartinez about 1 year ago
New features:
Move the closed record update optimization (#4489 by @rhendric)
For consumers of CoreFn like alternate backends, the optimization of
replacing a closed record update with an object literal has now been moved to
the point of desugaring CoreFn into JS. The ObjectUpdate
expression
constructor now contains a Maybe
field holding a list of record labels to
be copied as-is, for backends that want to perform this optimization also.
Allow instances that require Fail
to be empty (#4490 by @rhendric)
A class instance declaration that has Prim.TypeError.Fail
as a constraint
will never be used. In light of this, such instances are now allowed to have
empty bodies even if the class has members.
(Such instances are still allowed to declare all of their members, and it is
still an error to specify some but not all members.)
Bugfixes:
Stop emitting warnings for wildcards in Visible Type Applications (#4492 by @JordanMartinez)
Previously, the below usage of a wildcard (i.e. _
) would
incorrectly cause the compiler to emit a warning.
f :: forall @a. a -> a
f = identity
x :: { x :: Int }
x = f @{ x :: _ } { x: 42 }
Infer types using VTA inside a record (#4501 by @JordanMartinez)
Previously, use
would fail to compile
because the v
type variable would not be inferred
to String
. Now the below code compiles:
reflect :: forall @t v . Reflectable t v => v
reflect = reflectType (Proxy @t)
use :: String
use = show { asdf: reflect @"asdf" }
Internal:
Use gh
for release artifacts (#4493 by @rhendric, #4509 by @JordanMartinez)
Stop triggering CI on non-code-related changes (e.g. Readme) (#4502 by @JordanMartinez)
Published by JordanMartinez about 1 year ago
New features:
Move the closed record update optimization (#4489 by @rhendric)
For consumers of CoreFn like alternate backends, the optimization of
replacing a closed record update with an object literal has now been moved to
the point of desugaring CoreFn into JS. The ObjectUpdate
expression
constructor now contains a Maybe
field holding a list of record labels to
be copied as-is, for backends that want to perform this optimization also.
Allow instances that require Fail
to be empty (#4490 by @rhendric)
A class instance declaration that has Prim.TypeError.Fail
as a constraint
will never be used. In light of this, such instances are now allowed to have
empty bodies even if the class has members.
(Such instances are still allowed to declare all of their members, and it is
still an error to specify some but not all members.)
Bugfixes:
Stop emitting warnings for wildcards in Visible Type Applications (#4492 by @JordanMartinez)
Previously, the below usage of a wildcard (i.e. _
) would
incorrectly cause the compiler to emit a warning.
f :: forall @a. a -> a
f = identity
x :: { x :: Int }
x = f @{ x :: _ } { x: 42 }
Infer types using VTA inside a record (#4501 by @JordanMartinez)
Previously, use
would fail to compile
because the v
type variable would not be inferred
to String
. Now the below code compiles:
reflect :: forall @t v . Reflectable t v => v
reflect = reflectType (Proxy @t)
use :: String
use = show { asdf: reflect @"asdf" }
Internal:
Use gh
for release artifacts (#4493 by @rhendric)
Stop triggering CI on non-code-related changes (e.g. Readme) (#4502 by @JordanMartinez)
Published by JordanMartinez over 1 year ago
New features:
Implement visible type applications
The compiler now supports visible type applications, allowing the user to instantiate one or more "visible" type variables to a specific type.
A "visible" type variable is a type variable in a forall
binder that appears prefixed with an @
, like the following example:
id :: forall @a. a -> a -- or with kinds: `forall (@a :: Type). a -> a`
id a = a
We can then use type application syntax to instantiate this binding to a specific type:
idInt :: Int -> Int
idInt = id @Int
example :: Int
example = id @Int 0
Type variables appearing in class
or data
are automatically visible, meaning that they do not require annotations:
data Maybe a = Just a | Nothing
nothingInt :: Maybe Int
nothingInt = Nothing @Int
class Identity a where
identity :: a -> a
instance Identity Int where
identity a = a
identityInt = identity @Int
-- This throws a `NoInstanceFound` error.
identityNumber = identity @Number
Lastly, visible type variables can also be skipped with a wildcard (i.e. _
)
data Either a b = Left a | Right b
example = Left @_ @Number 0
Note that performing a type application with a type that has no visible type variables throws an error:
module Main where
id :: forall a. a -> a
id a = a
idInt = id @Int
{-
Error found:
in module Main
at Main.purs:6:9 - 6:16 (line 6, column 9 - line 6, column 16)
An expression of polymorphic type
with the invisible type variable a:
forall a. a -> a
cannot be applied to:
Int
while inferring the type of id
in value declaration idInt
See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
or to contribute content related to this error.
-}
Similarly, monomorphic types also cannot be used for type applications:
module Main where
idInt :: Int -> Int
idInt a = a
example = idInt @Int
{-
Error found:
in module Main
at Main.purs:6:11 - 6:21 (line 6, column 11 - line 6, column 21)
An expression of monomorphic type:
Int -> Int
cannot be applied to:
Int
while inferring the type of idInt
in value declaration example
See https://github.com/purescript/documentation/blob/master/errors/CannotApplyExpressionOfTypeOnType.md for more information,
or to contribute content related to this error.
-}
Exclude files from compiler input (#4480 by @i-am-the-slime)
The compiler now supports excluding files from the globs given to it as input.
This means there's now a new option for purs compile
, namely
--exclude-files
(or the short version -x
):
> purs compile --help
Usage: purs compile [FILE] [-x|--exclude-files ARG] [-o|--output ARG] ...
Compile PureScript source files
Available options:
-h,--help Show this help text
FILE The input .purs file(s).
-x,--exclude-files ARG Glob of .purs files to exclude from the supplied
files.
...
This allows you to keep related files closer together (that is, colocate them).
Consider a setup like the following:
src/
Main.purs
View/
LoginPage.purs
LoginPageTest.purs
LoginPageStories.purs
In order to exclude the files in the example above you can now invoke purs
like this and it will only compile LoginPage.purs
:
purs compile "src/**/*.purs" --exclude-files "src/**/*Stories.purs" -x "src/**/*Test.purs"
With spago
, the equivalent command is:
spago build --purs-args '-x "src/**/*Test.purs" -x "src/**/*Stories.purs"'
Published by purefunctor over 1 year ago
New features:
Bugfixes:
Fix prerelease version number on macOS (#4461 by @rhendric)
Consider fixity declarations during linting (#4462 by @ozkutuk)
Defer monomorphization for data constructors (#4376 by @purefunctor)
In 0.15.4
and earlier, the compiler monomorphizes type
constructors early, yielding the following type:
> :t Nothing
forall (a1 :: Type). Maybe a1
> :t { a : Nothing }
forall (a1 :: Type).
{ a :: Maybe a1
}
With this change, the monomorphization introduced in
#835 is
deferred to only when it's needed, such as when constructors are
used as values inside of records.
> :t Nothing
forall a. Maybe a
> :t { a : Nothing }
forall (a1 :: Type).
{ a :: Maybe a1
}
Also as a consequence, record updates should not throw
ConstrainedTypeUnified
in cases such as:
v1 :: { a :: Maybe Unit }
v1 = { a : Just Unit }
v2 :: { a :: Maybe Unit }
v2 = let v3 = v1 { a = mempty } in v3
Update installer to version 0.3.5 to support ARM builds (#4468 and #4469 by @rhendric)
Fix exhaustiveness checking to account for case guards (#4467 by @purefunctor)
Internal:
Refactor module imports to make identifiers' origins obvious (#4451 by @JordanMartinez)
Require comments not to cause Haddock warnings (#4456 by @rhendric)
Published by JordanMartinez over 1 year ago
New features:
Generated documentation now supports dark mode (#4438 by @sometimes-i-send-pull-requests)
PureScript documentation has a new dark theme available. It will
automatically be used based on your browser or system's color scheme
preferences.
Bugfixes:
Fix instance deriving regression (#4432 by @rhendric)
Outputs what label the type-error occurred on when types don't match (#4411 by @FredTheDino)
Account for typed holes when checking value declarations (#4437 by @purefunctor)
The compiler now takes into account typed holes when ordering value declarations
for type checking, allowing more top-level values to be suggested instead of
being limited by reverse lexicographical ordering.
Given:
module Main where
newtype K = K Int
aRinku :: Int -> K
aRinku = K
bMaho :: K
bMaho = ?help 0
cMuni :: Int -> K
cMuni = K
dRei :: Int -> K
dRei _ = bMaho
Before:
Hole 'help' has the inferred type
Int -> K
You could substitute the hole with one of these values:
Main.cMuni :: Int -> K
Main.K :: Int -> K
After:
Hole 'help' has the inferred type
Int -> K
You could substitute the hole with one of these values:
Main.aRinku :: Int -> K
Main.cMuni :: Int -> K
Main.K :: Int -> K
Other improvements:
Internal:
Published by JordanMartinez almost 2 years ago
New features:
Allow IDE module rebuilds eschewing the filesystem (#4399 by @i-am-the-slime)
This allows IDE clients to typecheck the module the user is currently typing in without modifying the output.
This allows for faster feedback cycles in editors and avoids producing a broken /output
before the user actually saves the file.
Add purs ide
dependency/imports filter (#4412 by @nwolverson)
This allows IDE tooling to filter type searches according to the imports of a given module,
restricting to identifiers in scope.
Shorten custom user-defined error message's prefix (#4418 by @i-am-the-slime)
Improves clarity and gets to the relevant information faster.
The compiler can now derive instances for more types and type classes (#4420 by @rhendric)
New type classes that the compiler can derive:
Bifunctor
Bifoldable
Bitraversable
Contravariant
Profunctor
Moreover, the compiler can also use these classes when deriving
Functor
, Foldable
, and Traversable
, enabling more instances to be derived
whereas before such instances would need to be written manually.
Bugfixes:
0.3.3
to fix a few installation issues (#4425 by @JordanMartinez)Other improvements:
Improve DuplicateDeclarationsInLet
error so that it mentions what variable names were duplicated, reporting several in separate errors as necessary. (#4405 by @MonoidMusician)
Fix various typos in documentation and source comments. (#4415 by @Deltaspace0)
Bump Stackage snapshot to 2022-11-12 and GHC to 9.2.4 (#4422 by @purefunctor)
Internal:
Organize the compiler's internal constants files (#4406 by @rhendric)
Enable more GHC warnings (#4429 by @rhendric)
Published by JordanMartinez about 2 years ago
Bugfixes:
Make FromJSON
instance for Qualified
backwards compatible (#4403 by @ptrfrncsmrph)
Prior to #4293, Qualified
was encoded to JSON such that
>>> encode $ Qualified Nothing "foo"
[null,"foo"]
>>> encode $ Qualified (Just $ ModuleName "A") "bar"
["A","bar"]
The type of Qualified
has changed so that null
no longer appears in JSON output, but for sake of backwards-compatibility with JSON that was produced prior to those changes (pre-v0.15.2
), we need to accept null
, which will be interpreted as Qualified ByNullSourcePos
.
Fix extraneous qualifiers added to references to floated expressions (#4401 by @rhendric)
Published by purefunctor about 2 years ago
New features:
Increases the max number of typed holes displayed from 5 up to 30 (#4341 by @JordanMartinez)
Add a compiler optimization for ST
functions with up to 10 arity, similar to Effect
optimizations. (#4386 by @mikesol)
Enable the compiler to derive Foldable
and Traversable
instances (#4392 by @rhendric)
These instances follow the same rules as derived Functor
instances.
For details, see the PureScript language reference.
Bugfixes:
Qualify references to expressions floated to the top level of a module by the compiler (#4364 by @rhendric)
Fix replicated type hole suggestions due to malformed source spans (#4374 by @PureFunctor)
In PureScript 0.15.4
, the following code will produce multiple entries in
the type hole suggestions. This is due to malformed source spans that are
generated when desugaring value declarations into case expressions.
module Main where
data F = X | Y
f :: forall a. F -> a -> a
f X b = ?help
f Y b = ?help
Improve error spans for class and instance declarations (#4383 and #4391 by @PureFunctor and @rhendric)
This improves the error spans for class and instance
declarations. Instead of highlighting the entire class or instance
declaration when UnknownName
is thrown, the compiler now
highlights the class name and its arguments.
Before:
[1/2 UnknownName]
5 class G a <= F a
^^^^^^^^^^^^^^^^
Unknown type class G
[2/2 UnknownName]
7 instance G a => F a
^^^^^^^^^^^^^^^^^^^
Unknown type class G
After:
[1/2 UnknownName]
5 class G a <= F a
^^^
Unknown type class G
[2/2 UnknownName]
7 instance G a => F a
^^^
Unknown type class G
Fix a bug where the compiler did not consider interactions of all functional dependencies in classes. (#4195 by @MonoidMusician)
In particular, combinations of multiple parameters determining other parameter(s) were not handled properly,
affecting overlapping instance checks and the selection of which parameters are fully determined.
Other improvements:
macOS-11
(#4372 by @PureFunctor)Internal:
Enable OverloadedRecordDot
extension throughout codebase (#4355 by @JordanMartinez)
Ensure order of args remain unchanged in freeTypeVariables
(#4369 by @JordanMartinez)
Bump HLint to version 3.5 and address most of the new hints (#4391 by @rhendric)
Remove purescript-cst
from Makefile (#4389 by @ptrfrncsmrph)
Bump depend NPM purescript-installer to ^0.3.1 (#4353 by @imcotton)
Remove base-compat as a dependency (#4384 by @PureFunctor)
Published by JordanMartinez over 2 years ago
Bugfixes:
Fix name clash in guard clauses introduced in #4293 (#4385 by @PureFunctor)
As a consequence, a problem with the compiler not being able to see
imported names if they're shadowed by a guard binder is also solved.
import Data.Foldable (fold)
import Data.Maybe (Maybe(..))
import Data.Monoid.Additive (Additive(..))
test :: Maybe Int -> Int
test = case _ of
m | Just fold <- m -> fold
-- Previously would complain about `fold` being undefined
| otherwise -> case fold [] of Additive x -> x
Internal:
Guard
handler for the everywhereWithContextOnValuesM
traversal. (#4385 by @PureFunctor)Published by JordanMartinez over 2 years ago
New features:
Float compiler-synthesized function applications (#3915 by @rhendric)
This is a limited implementation of common subexpression elimination for
expressions created by the compiler in the process of creating and using
typeclass dictionaries. Users can expect code that heavily uses typeclasses
to produce JavaScript that is shorter, simpler, and faster.
Common subexpression elimination is not applied to any expressions explicitly
written by users. If you want those floated to a higher scope, you have to do
so manually.
Add support for optional shebang lines (#4214 by @colinwahl and @JordanMartinez)
One or more shebang line are only allowed as the first lines of a file
#! a shebang line
#! another shebang line
-- | module doc comment
-- other comment
module MyModule where
#! Using a shebang here will fail to parse
foo :: String
foo = ""
Bugfixes:
Stop requiring bower.json
devDependencies
when publishing (#4332 by @JordanMartinez)
Stop emitting source spans with negative line/column numbers (#4343 by @j-nava and @JordanMartinez)
Internal:
Accommodate internally-generated identifiers that start with digits (#4334 by @rhendric)
Enable -Wincomplete-uni-patterns
and -Wincomplete-record-updates
by default (#4336 by @hdgarrood)
Update purescript.cabal
so that the PureScript compiler is built with the
flags -Wincomplete-uni-patterns
and -Wincomplete-record-updates
enabled by default.
Setup infrastructure for testing source maps (#4335 by @JordanMartinez)
Removed a couple of unused SimpleErrorMessage
constructors (#4344 by @hdgarrood)
Compare json files through aeson
in tests (#4354 by @PureFunctor)
This fixes the tests for the graph and source map outputs, as the
ordering is inconsistent between stack test
and cabal test
.
Add version bounds to the test suite's build-depends
. (#4354 by @PureFunctor)
Update GHC to 9.2.3 (#4351 by @hdgarrood and @JordanMartinez)
Add qualification for locally-bound names (#4293 by @PureFunctor)
This change makes it so that Qualified
names can now be qualified by either
a ModuleName
for module-level declarations or the starting SourcePos
for
bindings introduced locally. This makes disambiguation between references to
local bindings much easier in AST-driven analysis.
Published by JordanMartinez over 2 years ago
New features:
Check for partially applied synonyms in kinds, ctors (#4169 by @rhendric)
This check doesn't prevent any programs from compiling; it just makes
sure that a more specific PartiallyAppliedSynonym
error is raised
instead of a KindsDoNotUnify
error, which could be interpreted as
implying that a partially applied synonym has a valid kind and would be
supported elsewhere if that kind is expected.
Support deriving instances for type synonyms (#4315 by @rhendric)
Bugfixes:
Do not emit warnings about type wildcards used in binders (patterns). (#4309 by @fsoikin)
Type wildcards in the following examples no longer trigger a warning:
f :: Int
f = 42 # \(x :: _) -> x
g :: Maybe Int
g = do
x :: _ <- getX
pure $ x + 5
Fix issue with unnamed instances using type operators (#4311 by @rhendric)
Fix incorrect Prim.Int (class Compare)
docs: Int
& Ordering
, not Symbol
(#4313 by @JordanMartinez)
Fix bad interaction between module renaming and inliner (#4322 by @rhendric)
This bug was triggered when modules that the compiler handles specially
are shadowed by local constructors. For example, a constructor named
Prim
could have caused references to Prim_1["undefined"]
to be
produced in the compiled code, leading to a reference error at run time.
Less severely, a constructor named Control_Bind
would have caused the
compiler not to inline known monadic functions, leading to slower and
less readable compiled code.
Update Prim
docs for Boolean, Int, String/Symbol, Number, Record, and Row (#4317 by @JordanMartinez)
Fix crash caused by polykinded instances (#4325 by @rhendric)
A polykinded instance is a class instance where one or more of the type
parameters has an indeterminate kind. For example, the kind of a
in
instance SomeClass (Proxy a) where ...
is indeterminate unless it's somehow used in a constraint or functional
dependency of the instance in a way that determines it.
The above instance would not have caused the crash; instead, instances needed
to be of the form
instance SomeClass (f a) where ...
in order to cause it.
Fix bad interaction between newtype deriving and type synonyms (#4315 by @rhendric)
See #3453.
Fix bad interaction between instance deriving and type synonyms (#4315 by @rhendric)
See #4105.
Fix spurious kind unification error triggered by newtype deriving, type synonyms, and polykinds (#4315 by @rhendric)
See #4200.
Internal:
Deploy builds continuously to GitHub and npm (#4306 and #4324 by @rhendric)
(Builds triggered by changes that shouldn't affect the published package are
not deployed.)
Fix incomplete type traversals (#4155 by @rhendric)
This corrects oversights in some compiler internals that are not known to be
the cause of any user-facing issues.
Drop dependency on microlens libraries (#4327 by @rhendric)
Published by JordanMartinez over 2 years ago
Release skipped; use 0.15.2
instead.
Published by JordanMartinez over 2 years ago
Breaking changes:
Switch from Common JS to ES modules (#4232 by @sigma-andex)
Previously, Purescript used Common JS for FFI declarations.
Before, FFI was declared like this...
const mymodule = require('mymodule')
exports.myvar = mymodule.myvar
...and will be changed to this...
import * as M from 'mymodule';
export const myvar = M.myvar
...or using the short version...
export { myvar } from 'mymodule';
FFI is annotated with /* #__PURE__ */
so that bundlers can perform DCE
The current LTS Node.js version 12
is now the required minimum version
Improve apartness checking (#4149 by @rhendric)
See details in https://github.com/purescript/documentation/blob/master/language/Type-Classes.md#instance-chains
Disable type class constraints in FFI (#4240 by @JordanMartinez)
Previously, one could write FFI like the following:
foreign import foo :: forall a. Show a => a -> String
Type class dictionaries are "magically" handled by the compiler.
By including them in the above FFI, one can depend on their representation.
Since the representation can change without notice, this may silently break
code.
In v0.14.x
, a warning was emitted if these were used. Now it will fail
to compile. Rather, one should write something like the following
where the members of the type class are passed explicitly to
the FFI function as arguments:
foo :: forall a. Show a => a -> String
foo val = fooImpl show val
foreign import fooImpl :: forall a. (a -> String) -> a -> String
Removes deprecated syntax for rows (i.e. #
) and kinds (i.e. kind
-keyword) (#4239 by @JordanMartinez)
Apply precedence rules to operator sections (#4033 by @rhendric)
Previously, (_ * 4 + 1)
would desugar to \x -> x * (4 + 1)
, even
though *
has higher precedence than +
. Conversely, (3 * 2 + _)
would not compile, even though *
has higher precedence than +
. These
bugs have now been fixed; (_ * 4 + 1)
is an error, and (3 * 2 + _)
desugars to \x -> 3 * 2 + x
.
If you have code that relied on the old behavior, add an extra pair of
parentheses around the expression in the section.
If FFI parsing succeeds & CommonJS is detected, fail; otherwise, do not error or warn (#4250 by @sigma-andex)
Previously, the compiler would emit an error if it failed to parse the FFI JavaScript file.
Since the underlying JavaScript parser (i.e. language-javascript
) fails to parse even
valid JavaScript files, we cannot consider every failed parse to mean invalid JS files.
Fixing the parser would require a lot of effort, so we are planning to remove it instead
in v0.16.x
.
If the parse succeeds and a CommonJS module is detected, a compiler error is now emitted.
If the parse fails, we no longer emit a compiler error. While we could emit a warning,
such a warning will quickly become annoying for FFI files that trigger the buggy paths
of language-javascript
. Moreover, we presume that all will be migrating their code to
ES modules now that CommonJS is being deprecated in the larger JavaScript ecosystem.
Warn on ad-hoc non-single-line case expression syntax (#4241 by @JordanMartinez)
The following code will now produce a compiler warning.
These were originally supported to ease the migration
to the new CST parser.
-- before: `arg` isn't indented "past" the `Foo arg` binder
case foo of Foo arg ->
arg
-- after
case foo of Foo arg ->
foo
Dropping the above syntax make case expressions more similar to how let
bindings work:
let ok = 1
let
ok = 1
let ok =
1
let notOk =
1
Drop support for browser backend for repl (i.e. purs repl --port 1234
) (#4255 by @JordanMartinez)
Running this command will print a link that directs users to use
Try PureScript instead.
Remove purs bundle
(#4255 by @JordanMartinez)
Users of purs bundle
should switch to a standalone bundler such as esbuild
, webpack
or parcel
.
Lazy initialization for recursive bindings (#4283 by @rhendric)
This is unlikely to break a working program, but the upshot for users is
that it's now possible to get a run-time error when dereferencing an
identifier in a recursive binding group before it has been initialized,
instead of silently getting an undefined
value and having that maybe
or maybe not lead to an error somewhere else.
This change can cause code that relies on tail-call optimization to no
longer compile with that optimization. If you find that code that
previously compiled to a TCO loop no longer does but does include $lazy
initializers, please report the issue.
Alternate backend maintainers: for you, this change represents a
clarification of a responsibility shared by all backends. The identifiers
bound in a recursive binding group need to behave as if those identifiers
have call-by-need semantics during the initialization of the entire binding
group. (Initializing the binding group entails ensuring every initializer
has been executed, so after the binding group is initialized, these
identifiers can be considered call-by-value again.)
If an identifier is needed during its own call-by-need initialization, the
backend must ensure that an explicit run-time error is raised appropriate for
your target platform. This error may be raised at compile time instead if the
backend can determine that such a cycle is inevitable. Returning your
target language's equivalent of JavaScript's undefined
, as purs
did in
earlier releases in some cases, is not permitted.
If your target language natively has call-by-need semantics, you probably
don't have to do anything. If your target language is call-by-value and you
are using PureScript as a library, you can use the function
Language.PureScript.CoreFn.Laziness.applyLazinessTransform
to your CoreFn
input to satisfy this responsibility; if you do, you will need to do the
following:
Translate InternalIdent RuntimeLazyFactory
and InternalIdent (Lazy _)
identifiers to appropriate strings for your backend
Ensure that any output file that needs it has a reference to a function
named InternalIdent RuntimeLazyFactory
, with type forall a. Fn3 String String (Unit -> a) (Int -> a)
, and with the same semantics as the
following JavaScript (though you should customize the error raised to be
appropriate for your target language):
function (name, moduleName, init) {
var state = 0;
var val;
return function (lineNumber) {
if (state === 2) return val;
if (state === 1) throw new ReferenceError(name + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
state = 1;
val = init();
state = 2;
return val;
};
};
If neither of the previous cases apply to you, you can meet this
responsibility most easily simply by ensuring that all recursive bindings are
lazy. You may instead choose to implement some light analysis to skip
generating lazy bindings in some cases, such as if every initializer in the
binding group is an Abs
. You also may choose to reimplement
applyLazinessTransform
, or even develop a more sophisticated laziness
transform for your backend. It is of course your responsibility to ensure
that the result of whatever analysis you do is equivalent to the expected
semantics.
New features:
Implement the Reflectable type class (#4207 by @PureFunctor)
The Reflectable
type class is a common interface for reflecting
type-level values down to the term-level. Its instances are
automatically solved by the compiler, and it allows Symbol
, Int
,
Boolean
, and Ordering
kinded types to be reflected to their
term-level representations.
Implement native type-level integers (#4207 and #4267 by @PureFunctor and @JordanMartinez)
Added support for type-level integers and compiler-solved operations
such as Add
, Mul
, Compare
, and ToString
. Type-level integers use the Int
type as their kind.
Print compilation progress on the command line (#4258 by @PureFunctor)
This feature makes it so purs compile
and purs docs
now show
compilation progress on the command line. Example output:
[ 1 of 59] Compiling Type.Proxy
[ 2 of 59] Compiling Type.Data.RowList
...
[58 of 59] Compiling Effect.Class.Console
[59 of 59] Compiling Test.Main
Restore names of quantified variables during generalization (#4257 by @PureFunctor)
This makes the compiler aware of the names of quantified variables
instantiated into unification variables, such that when the latter
is generalized, semantic information is restored. For example:
addNumberSuffix :: forall a b c d. a -> b -> c -> d -> a
addNumberSuffix a _ _ _ = a
addNumberSuffix' = addNumberSuffix 0
Previously, inferring top-level declarations without type signatures
would use t
suffixed with an integer for type variables.
forall t6 t7 t8. t6 -> t7 -> t8 -> Int
Now, the inferred type would refer back to their original names.
forall b6 c7 d8. b6 -> c7 -> d8 -> Int
Support Glibc versions >= 2.24
(#4228 by @sd-yip)
Previously, purs
required a Glibc version greater than or equal to 2.27
.
This requirement is relaxed to support a Glibc version down to 2.24
.
Bugfixes:
Fix warning suppression for wildcard types (#4269 by @rhendric)
This bug was triggered by defining recursive partial functions or
recursive bindings that contained wildcards in inner type annotations.
Recursive partial function declarations now no longer cause spurious
wildcard warnings to be emitted, and actual user-written wildcards now
accurately emit warnings if and only if they don't appear within a
binding (recursive or otherwise) with a complete (wildcard-free) type
signature.
Remove compiler-generated identifiers from type search results (#4260 by @PureFunctor)
Other improvements:
Improve "Unknown value bind" and "Unknown value discard" errors (#4272 by @mhmdanas)
The previous error implies that do-notation compiles down to only bind
or to
only discard
(depending on whether the symbol not found was bind
or
discard
respectively), which is somewhat misleading, especially in the
latter case. Now, the error states correctly that do-notation compiles down to
both functions.
Internal:
Document the HSPEC_ACCEPT
flag for generating golden files (#4243 by @JordanMartinez)
Fail test if PureScript file(s) don't have a Main
module (#4243 by @JordanMartinez)
Update CI to use windows-2019
since windows-2016
is deprecated (#4248 by @JordanMartinez)
Move lib/purescript-cst
into src/
(#4290 by @JordanMartinez)
Update tests and their bower deps to 0.15.0-compatible versions (#4300 by @JordanMartinez)
Published by JordanMartinez over 2 years ago
Alpha release for use in preparing for the upcoming v0.15.0 release.
Published by JordanMartinez over 2 years ago
Alpha release for use in preparing for the upcoming v0.15.0 release.
Published by JordanMartinez over 2 years ago
Alpha release for use in preparing for the upcoming v0.15.0 release.
Published by JordanMartinez over 2 years ago
Alpha release for use in preparing for the upcoming v0.15.0 release.