purescript v0.10.1 Release Notes

Release Date: 2016-10-02 // over 7 years ago
  • ๐Ÿ’ฅ Breaking Changes

    ๐Ÿ›  The new functional dependencies feature fixes type inference in some cases involving multi-parameter type classes. However, due to a bug in the compiler, some of those expressions were previously type checking where they should not have. As a result, it is necessary to add functional dependencies to some classes in order to make previous code type-check in some cases. Known examples are:

    • MonadEff and MonadAff
    • ๐Ÿ’… MonadState, MonadReader, and the rest of the MTL-style classes in transformers

    ๐Ÿ†• New Features

    Data.Newtype Deriving

    (@garyb)

    It is now possible to derive the Newtype class for any data declaration which is a newtype, using the existing deriving instance syntax:

    newtype Test = Test String
    
    derive instance newtypeTest :: Newtype Test _
    

    Note that the second type argument should be specified as a wildcard, and will be inferred.

    โž• Added type level string functions

    (@FrigoEU)

    ๐Ÿ— The Prim module now defines the TypeString and TypeConcat type constructors, which can be used to build more descriptive error messages which can depend on types, using the Fail constraint:

    instance cannotShowFunctions
        :: Fail ("Function type " <> TypeString (a -> b) <> " cannot be shown.")
        => Show (a -> b) where
      show _ = "unreachable"
    
    infixl 6 type TypeConcat as <>
    

    --dump-corefn

    (@rightfold)

    ๐Ÿ‘ The compiler now supports the --dump-corefn option, which causes the functional core to be dumped in output/**/corefn.json. This should be useful for implementing new backends which interpret the functional core.

    ๐Ÿ†• Newtype Deriving

    (@paf31)

    It is now possible to derive type class instances for newtypes, by reusing the instance for the underlying type:

    newtype X = X String
    
    derive newtype instance showX :: Show X
    

    Note that it is possible to derive instances for multi-parameter type classes, but the newtype must only appear as the last type argument.

    ๐Ÿ‘ Allow anonymous accessor chains (_.a.b)

    (@rvion)

    Anonymous record accessor syntax has been extended to work with chains of one or more accessors:

    getBaz = _.foo.bar.baz
    

    Functional Dependencies (@paf31)

    ๐Ÿ‘ The type class solver now supports functional dependencies. A multi-parameter type class can define dependencies between its type arguments by using the -> operator:

    class Stream el s | s -> el where
      cons :: el -> (Unit -> s) -> s
      uncons :: s -> { head :: el, tail :: s }
    

    Here, the s and el type arguments are related by a single functional dependency, which ensures that there is at most one instance for any given type s. Alternatively, the type s determines the type el, i.e. there is an implicit function from types s to types el. This information can be used by the solver to infer types where it was previously not possible.

    ๐Ÿ‘€ See the following examples for more information:

    โœจ Enhancements

    • Return qualifier from explicit/hiding imports (@nwolverson)
    • ๐Ÿ‘Œ Verify entry points exist in psc-bundle (@kRITZCREEK)
    • ๐Ÿ‘Œ Improved error messages for record subsumption (@FrigoEU)

    psc-ide

    • Resolve types/kinds for operators (@kRITZCREEK)
    • Unify Completion Commands (@kRITZCREEK)
    • ๐Ÿ“œ Parse type annotations from source files (@kRITZCREEK)
    • โšก๏ธ Update pursuit JSON parsing (@nwolverson)
    • โœ‚ Remove a pursuit workaround (@kRITZCREEK)
    • โž• Add a suggestion to the UnusedDctorImport warning (@FrigoEU)
    • Return JSON errors for cycles in module dependencies (@kRITZCREEK)

    ๐Ÿ› Bug Fixes

    • ๐Ÿ›  Fix usage detection for operators (@garyb)
    • ๐Ÿ›  Fix handling of duplicate module imports in JS codegen (@garyb)
    • ๐Ÿ›  Fix a small bug in the type pretty-printer (@paf31)
    • ๐Ÿ›  Fix function application judgment (@paf31)
    • ๐Ÿ›  Fix inlining for $ and # operators (@garyb)
    • ๐Ÿ›  Fix everywhereOnTypesTopDown (@ianbollinger)
    • ๐Ÿ›  Fix unification of string literals (@paf31)

    Infrastructure

    • ๐Ÿ‘Œ Support aeson-1.0 (@phadej)
    • ๐Ÿ‘Œ Support http-client-0.5 (@phadej)
    • Safer installation from source in INSTALL.md (@hdgarrood)

    Implementation

    • ๐Ÿ›  Fix most HLint warnings (@ianbollinger)
    • ๐Ÿ›  Fixing imports (@charleso)
    • Export desugarDecl from Sugar.ObjectWildcards (@rvion)
    • โœ‚ Remove legacy ObjectGetter and update doc (@rvion)