purescript v0.9.1 Release Notes

Release Date: 2016-06-01 // about 6 years ago
  • ๐Ÿš€ PureScript 0.9.1 is a major stable release of the compiler. It removes features which were deprecated in the 0.8.x series, and contains several useful enhancements and bug fixes.

    ๐Ÿš€ This release will be accompanied by new releases of the core libraries and a compatible version of Pulp, which have been updated to work with this version.

    โšก๏ธ Due to the relatively large number of breaking changes, library authors are advised that they will probably need to update their libraries to maintain compatibility. Users may prefer to continue using version 0.8.5 until their dependencies have been updated.

    ๐Ÿ’ฅ Breaking Changes

    Name resolving


    โšก๏ธ 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

    (@garyb, @paf31)

    โš  The compiler will now generate an error for a missing Partial constraints, where it would previously have issued a warning.

    Module Restrictions

    (@garyb, @paf31)

    • 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


    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


    ๐Ÿ‘ 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.


    • ๐Ÿšš Deprecated class import/export syntax has been removed (@LiamGoodacre). Classes are now imported using the class keyword, and exported similarly:
      import Prelude (class Show, show)
    • โœ‚ Remove support for = in record binders (@paf31).

    Record binders such as

      f { x = 0 } = true

    are no longer supported. Record binders must now use : instead:

      f { x: 0 } = true
    • Prim.Object has been renamed to Prim.Record (#1768, @paf31)

    โœจ Enhancements

    Programmable Type Errors


    Constraints can now contain type-level strings which can be used as custom error messages using the Fail 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.

    Typed Hole Improvements

    (#2070, @paf31)

    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

    ๐Ÿ‘ 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 TypeWildCard warnings (@nwolverson)

    PSCi Improvements


    • ๐ŸŽ 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 Fixes

    • ๐Ÿ“œ 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)


    • โœ… 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)