records-sop-0.1.1.0: Record subtyping and record utilities with generics-sop
Safe HaskellNone
LanguageHaskell2010

Generics.SOP.Record.SubTyping

Synopsis

Documentation

cast :: (IsRecord a ra, IsRecord b rb, IsSubTypeOf ra rb) => a -> b Source #

Cast one record type to another if there is a subtype relationship between them. Currently, only width subtyping is considered, which means that we can forget and reorder fields.

class IsSubTypeOf (r1 :: RecordCode) (r2 :: RecordCode) Source #

Class that checks whether one record code is convertible into another.

Conversion works if the first record contains at least the labels of the second record, and if the types of the corresponding fields match exactly.

Minimal complete definition

castRecord

Instances

Instances details
IsSubTypeOf r1 ('[] :: [(FieldLabel, Type)]) Source # 
Instance details

Defined in Generics.SOP.Record.SubTyping

Methods

castRecord :: Record r1 -> Record '[]

(IsSubTypeOf r1 r2, IsElemOf s2 a2 r1) => IsSubTypeOf r1 ('(s2, a2) ': r2) Source # 
Instance details

Defined in Generics.SOP.Record.SubTyping

Methods

castRecord :: Record r1 -> Record ('(s2, a2) ': r2)

class IsElemOf (s :: Symbol) (a :: Type) (r :: RecordCode) Source #

Class that checks whether a field of a particular type is contained in a record.

Minimal complete definition

get

Instances

Instances details
IsElemOf' (SameFieldLabel s1 s2) s1 a1 s2 a2 r => IsElemOf s1 a1 ('(s2, a2) ': r) Source # 
Instance details

Defined in Generics.SOP.Record.SubTyping

Methods

get :: Record ('(s2, a2) ': r) -> a1 Source #

get :: IsElemOf s a r => Record r -> a Source #

Perform an extraction of a given field. Field name has to be passed via type application.

getField :: forall s a b ra. (IsRecord a ra, IsElemOf s b ra) => a -> b Source #

Extract a record field based on the symbolic name of a field. Requires an explicit type application for the field name.