HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulevinyl-0.14.3Haskell2010

Data.Vinyl.ARec.Internal

Constant-time field accessors for extensible records. The trade-off is the usual lists vs arrays one: it is fast to add an element to the head of a list, but element access is linear time; array access time is uniform, but extending the array is more slower.

Tradeoffs:

  • No sharing of the spine (i.e. when you change elements in the front of the record the tail can't be re-used)

  • ARec requires (4 + n) words + size of the fields

  • 1 for the ARec constructor

  • 1 for the pointer to the SmallArray#

  • The SmallArray# has 2 words as header (1 for GC, 1 for number of elements)

  • 1 pointer per element to the actual data

  • Rec requires (2n) words + size of Fields

  • 1 word per (:&) constructor

  • 1 word for the pointer to the element

  • 2 types
  • 2 classes
  • 12 values
  • Packagevinyl-0.14.3
  • Exports16
  • LanguageHaskell2010
  • LicenceMIT
  • SourceInternal.hs
newtypenewtype ARec (f :: k -> Type) (ts :: [k])
#

An array-backed extensible record with constant-time field access.

Constructors

Instances9RecSubset, RecElem, Eq, Ord, Show, RecElemFCtx, …
classclass ToARec (us :: [k]) where
#
Instances2ToARec
  • ToARec '[]Defined in vinyl-0.14.3 · Data.Vinyl.ARec.Internal
  • ToARec us => ToARec (u ': us)Defined in vinyl-0.14.3 · Data.Vinyl.ARec.Internal
newtypenewtype ARecBuilder (f :: k) (us :: k1)
#

An efficient builder for ARec values

Use the pseudo-constructors arcons and arnil to construct an ARecBuilder and then turn it into an ARec with arec

Example: (requires -XOverloadedLabels and )

user :: ARec ElField '[ "name"   ::: String
                      , "age"    ::: Int
                      , "active" ::: Bool]
user = arec (  #name   =: "Peter"
            `arcons` #age    =: 4
            `arcons` #active =: True
            `arcons` arnil
            )

Constructors

valuearecConsMatchCoercion :: (forall (x :: k). Coercible (f x) (g x)) => Coercion (ARec f xs) (ARec g xs)
#

Given that forall x. Coercible (f x) (g x), produce a coercion from ARec f xs to ARec g xs. While the constraint looks a lot like Coercible f g, it is actually weaker.