小巧而强大的静态类型语言 PureScript v0.9.1发布

jopen 8年前
   <p style="text-align: center;"><img alt="" src="https://simg.open-open.com/show/6c5da9e63102b686994315d7f4a206df.png" /></p>    <p>PureScript 是个小巧而强大的静态类型语言,可以编译成 JavaScript。purescript 主要是由 Haskell 和 PureScript 编写的。</p>    <h2>更新日志</h2>    <h3>重大改进</h3>    <h3>Name resolving</h3>    <p>(<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</p>    <p>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.</p>    <p>Some examples:</p>    <table>     <thead>      <tr>       <th>Import statement</th>       <th>Exposed members</th>      </tr>     </thead>     <tbody>      <tr>       <td><code>import X</code></td>       <td><code>A</code>, <code>f</code></td>      </tr>      <tr>       <td><code>import X as Y</code></td>       <td><code>Y.A</code> <code>Y.f</code></td>      </tr>      <tr>       <td><code>import X (A)</code></td>       <td><code>A</code></td>      </tr>      <tr>       <td><code>import X (A) as Y</code></td>       <td><code>Y.A</code></td>      </tr>      <tr>       <td><code>import X hiding (f)</code></td>       <td><code>A</code></td>      </tr>      <tr>       <td><code>import Y hiding (f) as Y</code></td>       <td><code>Y.A</code></td>      </tr>     </tbody>    </table>    <p>Qualified references like <code>Control.Monad.Eff.Console.log</code> will no longer resolve unless there is a corresponding <code>import Control.Monad.Eff.Console as Control.Monad.Eff.Console</code>. Importing a module unqualified does not allow you to reference it with qualification, so <code>import X</code> does not allow references to <code>X.A</code> unless there is also an <code>import X as X</code>.</p>    <p>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.</p>    <p>Module re-exports have also been tightened up as a result of these rules. Now if module <code>X</code> is only imported <code>as Y</code>, the re-export must list <code>module Y</code> also. If a module is imported without being re-qualified then the original name is used.</p>    <h3>Partial Constraints</h3>    <p>(<a href="/misc/goto?guid=4958879147088779009">@garyb</a>, <a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <p>The compiler will now generate an error for a missing <code>Partial</code> constraints, where it would previously have issued a warning.</p>    <h3>Module Restrictions</h3>    <p>(<a href="/misc/goto?guid=4958879147088779009">@garyb</a>, <a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <ul>     <li>Imports must now appear before other declarations in a module.</li>     <li>A source file must now contain exactly one module.</li>    </ul>    <p>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.</p>    <h3>Foreign Function Interface Changes</h3>    <p>(<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <p>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<code>.purs</code> to <code>.js</code>.</p>    <p>This change was made to be more consistent with <code>psc-ide</code>, and also to adopt a simple convention which will port well to other backends.</p>    <h3>Operator Aliases</h3>    <p>(<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</p>    <p>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. <code>let (#) x y = x y in ...</code>). This change makes it possible to generate better JavaScript code for operators, by desugaring them to the functions they alias.</p>    <h3>Other</h3>    <ul>     <li> <p>Deprecated class import/export syntax has been removed (<a href="/misc/goto?guid=4958991075782312448">@LiamGoodacre</a>). Classes are now imported using the <code>class</code> keyword, and exported similarly:</p> <pre>  import Prelude (class Show, show)</pre> </li>     <li> <p>Remove support for <code>=</code> in record binders (<a href="/misc/goto?guid=4958879147349283503">@paf31</a>).</p> <p>Record binders such as</p> <pre>  f { x = 0 } = true</pre> <p>are no longer supported. Record binders must now use <code>:</code> instead:</p> <pre>  f { x: 0 } = true</pre> </li>     <li><code>Prim.Object</code> has been renamed to <code>Prim.Record</code> (<a href="/misc/goto?guid=4958991075887502404">#1768</a>, <a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</li>    </ul>    <h2>功能增强</h2>    <h3>Programmable Type Errors</h3>    <p>(<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <p>Constraints can now contain type-level strings which can be used as custom error messages using the<code>Fail</code> constraint. For example, one can now document the fact that foreign types such as <code>JSDate</code> cannot be made instances of <code>Generic</code>:</p>    <pre>  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"</pre>    <p>Attempting to derive a <code>Generic</code> instance for a type containing <code>JSDate</code> will then result in</p>    <pre>  <code>A custom type error occurred while solving type class constraints:        JSDate is not Generic. Consider using Int with toEpochMilliseconds instead.  </code></pre>    <h3>Typed Hole Improvements</h3>    <p>(<a href="/misc/goto?guid=4958991076007967982">#2070</a>, <a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <p>Typed hole error messages now include the types of any names in scope, to assist with type-driven development:</p>    <pre>  <code>> :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>    <h3>Editor Support</h3>    <ul>     <li>The results of the last rebuild are now cached by <code>psc-ide</code>, which improves completion support for editor plugins. (<a href="/misc/goto?guid=4958991076100114071">@kRITZCREEK</a>)</li>     <li>A <code>reset</code> command was added to <code>psc-ide</code> (<a href="/misc/goto?guid=4958991076100114071">@kRITZCREEK</a>)</li>     <li>The compiler will now suggest replacements to address <code>MissingTypeDeclaration</code> and <code>TypeWildCard</code>warnings (<a href="/misc/goto?guid=4958984422936517219">@nwolverson</a>)</li>    </ul>    <h3>PSCi Improvements</h3>    <p>(<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</p>    <ul>     <li>The design of PSCi has been changed to improve performance. PSCi now precompiles all dependencies and uses the same incremental rebuilding approach as <code>psc-ide</code>. This means that the<code>:load</code> and <code>:foreign</code> commands have been removed, since dependencies are fixed and pre-compiled when PSCi loads.</li>     <li>PSCi now supports alternative base libraries such as Neon, by depending on <code>purescript-psci-support</code> for its supporting code.</li>    </ul>    <h3>Colors in Error Messages</h3>    <p>Types and values will now be highlighted in error messages, when the terminal supports it (MacOS and Linux for now) (<a href="/misc/goto?guid=4958984425136946631">@soupi</a>).</p>    <h3>Type Names</h3>    <p>Prime characters are now allowed in type names. (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</p>    <h2>Bug修复</h2>    <ul>     <li>Parser error messages inside type class and instance declarations were improved (<a href="/misc/goto?guid=4958991076289245148">#2128</a>,<a href="/misc/goto?guid=4958991076384077372">@bmjames</a>)</li>     <li>Editor suggestions for imports now use <code>(..)</code> (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>Source-spans to token end position (<a href="/misc/goto?guid=4958984422936517219">@nwolverson</a>)</li>     <li>Some pretty printing issues related to string literals in records were fixed (<a href="/misc/goto?guid=4958991075782312448">@LiamGoodacre</a>)</li>     <li>Some presentation bugs in PSCi's <code>:show import</code> were fixed (<a href="/misc/goto?guid=4958991075782312448">@LiamGoodacre</a>)</li>     <li>Parsec was updated to the latest version to fix an issue with literal parsing (<a href="/misc/goto?guid=4958991076522618293">#2115</a>, <a href="/misc/goto?guid=4958879146816584657">@hdgarrood</a>)</li>     <li>Fixed a bug related to certain typed binders which would cause the compiler to crash (<a href="/misc/goto?guid=4958991076634335121">#2055</a>,<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</li>     <li>As-patterns now bind less tightly (<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</li>     <li>More identifiers can now be parsed in FFI imports (<a href="/misc/goto?guid=4958991076751172553">@michaelficarra</a>)</li>     <li>Fixed a performance issue which manifested under certain conditions in <code>psc-ide</code> (<a href="/misc/goto?guid=4958991076835173453">#2064</a>, <a href="/misc/goto?guid=4958991076931251599">@kika</a>)</li>     <li>Fixed a test which contained an unreliable comparison (<a href="/misc/goto?guid=4958991077025495010">#2093</a>, <a href="/misc/goto?guid=4958879146690610970">@andyarvanitis</a>)</li>     <li>The precedence of type application was corrected (<a href="/misc/goto?guid=4958991077144658755">#2092</a>, <a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</li>     <li>An indentation bug in the parser was fixed (<a href="/misc/goto?guid=4958984423143257502">@DavidLindbom</a>)</li>     <li>License errors from <code>psc-publish</code> were improved (<a href="/misc/goto?guid=4958879146816584657">@hdgarrood</a>)</li>    </ul>    <h2>Other</h2>    <ul>     <li>The test suite now exercises various compiler warnings (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>The test suite performance was improved by using incremental rebuilds (<a href="/misc/goto?guid=4958879147349283503">@paf31</a>)</li>     <li>The test suite now tests that passing tests contain a <code>main</code> function (<a href="/misc/goto?guid=4958879146816584657">@hdgarrood</a>)</li>     <li>The test suite now supports tests which use multiple files (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>Portability of the core library test suite was improved (<a href="/misc/goto?guid=4958991076384077372">@bmjames</a>)</li>     <li>Performance of import elaboration was improved (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>We now use Stack for our CI builds and release builds (<a href="/misc/goto?guid=4958991077347680763">#1974</a>, <a href="/misc/goto?guid=4958879146816584657">@hdgarrood</a>)</li>     <li>We now use <code>NoImplicitPrelude</code> and enable some global extensions (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>Type-safety in the source-level AST was improved (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>Use HSpec for the compiler tests (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>     <li>New Prelude names in 0.9 (<a href="/misc/goto?guid=4958879147088779009">@garyb</a>)</li>    </ul>    <h2>下载</h2>    <ul>     <li><a href="/misc/goto?guid=4958991077489988772" rel="nofollow">64 Bytes<strong>linux64.sha</strong></a></li>     <li><a href="/misc/goto?guid=4958991077585077019" rel="nofollow">23.8 MB<strong>linux64.tar.gz</strong></a></li>     <li><a href="/misc/goto?guid=4958991077677871183" rel="nofollow">62 Bytes<strong>macos.sha</strong></a></li>     <li><a href="/misc/goto?guid=4958991077769518477" rel="nofollow">24.7 MB<strong>macos.tar.gz</strong></a></li>     <li><a href="/misc/goto?guid=4958991077859659426" rel="nofollow">68 Bytes<strong>win64.sha</strong></a></li>     <li><a href="/misc/goto?guid=4958991077954968009" rel="nofollow">22.2 MB<strong>win64.tar.gz</strong></a></li>     <li><a href="/misc/goto?guid=4958991078047602345" rel="nofollow"><strong>Source code</strong> (zip)</a></li>     <li><a href="/misc/goto?guid=4958991078126666441" rel="nofollow"><strong>Source code</strong> (tar.gz)</a></li>    </ul>