vinyl
Extensible Records
| LTS Haskell 24.16: | 0.14.3 |
| Stackage Nightly 2025-10-24: | 0.14.3 |
| Latest on Hackage: | 0.14.3 |
vinyl-0.14.3@sha256:08565c5d9ed8a5ba69915bffe8960f048587478155d5915a56d2e93b8ba3466f,4267Module documentation for 0.14.3
- Data
- Data.Vinyl
Extensible records for Haskell with lenses.
Changes
0.14.3
- Compatibility with
lens-aeson> 1.2
0.14.2
- Export the
ToARecclass
0.14.1
- Compatibility with
aeson> 2.0
0.14.0
ARecefficiency improvements (@Philonous)- Make
ElFielda newtype (@Philonous)
The ElField change brings more opportunities for the optimizer, but can result in longer compile times.
0.13.3
- Fixed CHANGELOG entry for 0.13.2: it referred to version 0.14.0
- Relax bounds on
hspec
0.13.2
- Removed aput and alens from Data.Vinyl.ARec. They were used internally, but their type is unsound.
0.13.1
- GHC 9.0.1 support
0.13.0
- GHC 8.10.1 support fix. A fix for the previous attempt at 8.10 support involves a backwards incompatible change.
0.12.2
- GHC 8.10.1 support
0.12.0
- GHC 8.8.1 support. Class type signatures were changed to remove explicit kind variables. This is to simplify the use of
TypeApplicationswhich changed with GHC 8.8.1 to require explicit application to those kind variables. Leaving them out of the class definitions preserves existing usage ofTypeApplications. Thanks to Justin Le (@mstksg).
0.11.0
- Changed the
Showinstance ofCoRec - Added the
corechelper that specifically helps type inference when constructingCoRec ElFieldvalues.
0.10.0
-
Changed the types of
Data.Vinyl.CoRec.onCoRecandData.Vinyl.CoRec.onField. This was pushing through the changes to drop the use ofProxyarguments, relying instead onTypeApplications. Also addedonCoRec1andonFieldto work with functions relying on a single type class. -
Faster
asAandasA'. These implementations utilizeunsafeCoercein their implementations after we have performed a runtime check that proves (to us) that the types match up. The old implementations are still available asasASafeandasA'Safe. While both implementations can run in constant time if the compiler optimizes everything successfully, the faster variants are a bit more than 3x faster in a trivial benchmark. -
Add a
Genericinstance forRecand common functors. -
Add a variety of
ToJSONimplementations as a test case. One or all of these should probably exist as a separate package to avoidvinyldepending onaeson, but their content may be of interest.
0.9.2
- Add
runcurryXfor applying an uncurried function to aRecpassing through theXRecmachinery to strip out syntactic noise.
0.9.0
-
A new
SRectype for constant time field access for records with densely packedStorablefields. Conversion fromRecis accomplished withtoSRec, whilefromSRectakes 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
FieldRecwithfieldRec (#x =: True, #y =: 'b')and have the type inferred asRec ElField '[ '("x", Bool), '("y", Char) ]. Or userecordto 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
IsLabelinstance 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 toUpperto applymap toUpperto the#namefield 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 %~ lengthto produce a record whose#namefield is the length of theString#namefield of some record value,myRec. -
Changed the type of
=:=again to work directly withLabels as this is the most convenient usage. -
Definitions in
Data.Vinyl.Coreare 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.Recursivethat are written in a recursive style (as in previous versions of thevinylpackage), treating the record as a list of fields. -
Added
restrictCoRecandweakenCoRecsuggested by @ElvishJerricco
0.8.0
-
Overhaul of
FieldRec: records with named fields. We now take advantage of the-XOverloadedLabelsextension to support referring to record fields by names such a#myField. -
A new
ARectype for constant-time field access. You can convert a classic, HList-likeRecinto anARecwithtoARec, or back the other way withfromARec. AnARecuses anArrayto store record fields, so the usual trade-offs between lists and arrays apply: lists are cheap to construct by adding an element to the head, but slow to access; it is expensive to modify the shape of an array, but element lookup is constant-time.
Compatibility Break: The operator =: for constructing a record with a single field has changed. That operation is now known as =:=, while =: is now used to construct an ElField. It was decided that single-field record construction was not a common use-case, so the shorter name could be used for the more common operation. Apologies for making the upgrade a bit bumpy.
0.7.0
- Simplified
match - Added
Data.Vinyl.Curry
0.6.0
Added a CoRec (co-record) type constructed in the same style as the existing Rec type for records. A CoRec is an open sum type: a value of CoRec [a,b,c] is either an a, a b, or a c. In contrast a Rec [a,b,c] includes an a, a b, and, a c.
0.5.3
Added a concise Show instance for Const.
0.5.2
Ported the tutorial to haddocks (andrewthad)
0.5.1
Added utilities for working with the FieldRec type.
0.5
Vinyl 0.5 combines the generality of Vinyl 0.4 with the ease-of-use of previous versions by eschewing the defunctionalized type families and just using plain type constructors; Vinyl 0.4-style records can be recovered in most cases in a modular manner without baking it into the fabric of Vinyl itself.
Also new in 0.5 is a unified lens-based approach to subtyping, coercion and projection.
0.4
Vinyl 0.4 is a big departure from previous versions, in that it introduces a universe encoding as a means to generalize the space of keys from strings to any arbitrary space. This means that you can have closed universes for your records.
For details on how to use the new Vinyl, please see tests/Intro.lhs or view
Jon’s talk at BayHac 2014, Programming in
Vinyl.