小巧而強大的靜態類型語言 PureScript v0.9.1發布

PureScript 是個小巧而強大的靜態類型語言,可以編譯成 JavaScript。purescript 主要是由 Haskell 和 PureScript 編寫的。
更新日志
重大改進
Name resolving
(@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.
Partial Constraints
The compiler will now generate an error for a missing Partial constraints, where it would previously have issued a warning.
Module Restrictions
- Imports must now appear before other declarations in a module.
- A source file must now contain exactly one module.
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.
Foreign Function Interface Changes
(@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.
Operator Aliases
(@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.
Other
-
Deprecated class import/export syntax has been removed (@LiamGoodacre). Classes are now imported using the
classkeyword, and exported similarly:import Prelude (class Show, show)
-
Remove support for
=in record binders (@paf31).Record binders such as
f { x = 0 } = trueare no longer supported. Record binders must now use
:instead:f { x: 0 } = true Prim.Objecthas been renamed toPrim.Record(#1768, @paf31)
功能增強
Programmable Type Errors
(@paf31)
Constraints can now contain type-level strings which can be used as custom error messages using theFail 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.
</code></pre>
Typed Hole Improvements
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
</code></pre>
Editor Support
- The results of the last rebuild are now cached by
psc-ide, which improves completion support for editor plugins. (@kRITZCREEK)
- A
reset command was added to psc-ide (@kRITZCREEK)
- The compiler will now suggest replacements to address
MissingTypeDeclaration and TypeWildCardwarnings (@nwolverson)
PSCi Improvements
(@paf31)
- The design of PSCi has been changed to improve performance. PSCi now precompiles all dependencies and uses the same incremental rebuilding approach as
psc-ide. This means that the:load and :foreign commands have been removed, since dependencies are fixed and pre-compiled when PSCi loads.
- PSCi now supports alternative base libraries such as Neon, by depending on
purescript-psci-support for its supporting code.
Colors in Error Messages
Types and values will now be highlighted in error messages, when the terminal supports it (MacOS and Linux for now) (@soupi).
Type Names
Prime characters are now allowed in type names. (@garyb)
Bug修復
- Parser error messages inside type class and instance declarations were improved (#2128,@bmjames)
- Editor suggestions for imports now use
(..) (@garyb)
- Source-spans to token end position (@nwolverson)
- Some pretty printing issues related to string literals in records were fixed (@LiamGoodacre)
- Some presentation bugs in PSCi's
:show import were fixed (@LiamGoodacre)
- Parsec was updated to the latest version to fix an issue with literal parsing (#2115, @hdgarrood)
- Fixed a bug related to certain typed binders which would cause the compiler to crash (#2055,@paf31)
- As-patterns now bind less tightly (@paf31)
- More identifiers can now be parsed in FFI imports (@michaelficarra)
- Fixed a performance issue which manifested under certain conditions in
psc-ide (#2064, @kika)
- Fixed a test which contained an unreliable comparison (#2093, @andyarvanitis)
- The precedence of type application was corrected (#2092, @paf31)
- An indentation bug in the parser was fixed (@DavidLindbom)
- License errors from
psc-publish were improved (@hdgarrood)
Other
- The test suite now exercises various compiler warnings (@garyb)
- The test suite performance was improved by using incremental rebuilds (@paf31)
- The test suite now tests that passing tests contain a
main function (@hdgarrood)
- The test suite now supports tests which use multiple files (@garyb)
- Portability of the core library test suite was improved (@bmjames)
- Performance of import elaboration was improved (@garyb)
- We now use Stack for our CI builds and release builds (#1974, @hdgarrood)
- We now use
NoImplicitPrelude and enable some global extensions (@garyb)
- Type-safety in the source-level AST was improved (@garyb)
- Use HSpec for the compiler tests (@garyb)
- New Prelude names in 0.9 (@garyb)
下載
- 64 Byteslinux64.sha
- 23.8 MBlinux64.tar.gz
- 62 Bytesmacos.sha
- 24.7 MBmacos.tar.gz
- 68 Byteswin64.sha
- 22.2 MBwin64.tar.gz
- Source code (zip)
- Source code (tar.gz)
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!