A strongly-typed language that compiles to JavaScript
OTHER License
Bot releases are visible (Hide)
This is an automated preview release. Get the latest stable release here.
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 github-actions[bot] 8 months ago
This is an automated preview release. Get the latest stable release here.
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 github-actions[bot] 10 months ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] 10 months ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] 11 months ago
This is an automated preview release. Get the latest stable release here.
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 github-actions[bot] 12 months ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] 12 months ago
This is an automated preview release. Get the latest stable release here.
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 github-actions[bot] about 1 year ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] about 1 year ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] about 1 year ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] about 1 year ago
This is an automated preview release. Get the latest stable release here.
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 github-actions[bot] over 1 year ago
This is an automated preview release. Get the latest stable release here.
Published by github-actions[bot] over 1 year ago
This is an automated preview release. Get the latest stable release here.
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)