vinyl v0.9.0 Release Notes
-
โก๏ธ A new
SRec
type for constant time field access for records with densely packedStorable
fields. Conversion fromRec
is accomplished withtoSRec
, whilefromSRec
takes you back toRec
. Record updates are fairly slow compared to native Haskell records and evenRec
, but reading a field is as fast as anything.๐ Concise record construction syntax from tuples. Construct a
FieldRec
withfieldRec (#x =: True, #y =: 'b')
and have the type inferred asRec ElField '[ '("x", Bool), '("y", Char) ]
. Or userecord
to build records of any functor. Thanks to @heptahedron on GitHub for prompting this feature, and @sboosali for thinking through various approaches.Optional concise record field lens syntax. This uses an orphan
IsLabel
instance for all function types, so will conflict with any other library that does the same. Thus it is entirely opt-in: to enable this syntax, you must explicitlyimport Data.Vinyl.Syntax
. This enables the use of labels as lenses. For example,myRec & #name %~ map toUpper
to applymap toUpper
to the#name
field of the record valuemyRec
. This technique is thanks to Tikhon Jelvis who shared it on the Haskell-Cafe mailing list.Field lenses can now change the type of a record. Thanks to @heptahedron on GitHub for exploring this feature. Using the above-mentioned features, one might now write something like
myRec & #name %~ length
to produce a record whose#name
field is the length of theString
#name
field of some record value,myRec
.๐ Changed the type of
=:=
again to work directly withLabel
s as this is the most convenient usage.๐ Definitions in
Data.Vinyl.Core
are now consistently in terms of type classes. This permits inlining and specialization to a user's record types. In the case where the record type is known, call sites do not change. But for functions polymorphic in the record's fields, a constraint will be required. If those constraints are a nuisance, or compile times increase beyond comfort, users should use definitions from theData.Vinyl.Recursive
that are written in a recursive style (as in previous versions of thevinyl
package), treating the record as a list of fields.โ Added
restrictCoRec
andweakenCoRec
suggested by @ElvishJerricco