In Vinyl, I can define a type alias for a record to make it easier to export to other modules:
import Data.Vinyl
name = Field :: "name" ::: String
age = Field :: "age" ::: Int
type Person = ["name" ::: String, "age" ::: Int]
Now suppose I add another field storing height.
height = Field :: "height" ::: Int
I would like to nicely construct a type alias for the record containing a Person
and height
. Naively, that might look something like this:
type MeasuredPerson = ("height" ::: Int) : Person
This syntax doesn't work, obviously! Is there a way to do this? Are there any good references that explain the type-level array syntax that seems to be in use here?
“Record” remains the standard term to describe both shellac and vinyl formats. It's fair to say that while all vinyl albums are records, not every record is a vinyl album. There are different types of vinyl records with various storage capacities and playback speeds, but they all fall under the “record”umbrella.
Shellacs or 78s, also called coarse groove gramophone discs, were the main mass produced audio format of the first half of the 20th century. The shellac discs were pressed from a wax matrix that was made during a professional recording.
Single discs are physically smaller – usually 7 inch 45 RPM releases. If you purchased the full length, 12-inch album, you have an LP. If you purchase that 7-inch single, you have an EP.
Turns out there's a very easy answer to this which I managed to miss:
Data.Vinyl.Rec
defines both cons and append for type level lists, so the following works:
type MeasuredPerson = ("height" ::: Int) ': Person
If I had two lists, I could append them as follows:
type Other = Person ++ Address
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With