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
andMonadAff
- ๐
MonadState
,MonadReader
, and the rest of the MTL-style classes intransformers
๐ New Features
Data.Newtype
Deriving(@garyb)
It is now possible to derive the
Newtype
class for any data declaration which is anewtype
, using the existingderiving 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 theTypeString
andTypeConcat
type constructors, which can be used to build more descriptive error messages which can depend on types, using theFail
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 inoutput/**/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
newtype
s, 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
andel
type arguments are related by a single functional dependency, which ensures that there is at most one instance for any given types
. Alternatively, the types
determines the typeel
, i.e. there is an implicit function from typess
to typesel
. 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
fromSugar.ObjectWildcards
(@rvion) - โ Remove legacy
ObjectGetter
and update doc (@rvion)