records-sop-0.1.0.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 r2 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

IsSubTypeOf r1 ([] (FieldLabel, Type)) Source # 

Methods

castRecord :: Record r1 -> Record [(FieldLabel, Type)]

(IsSubTypeOf r1 r2, IsElemOf s2 a2 r1) => IsSubTypeOf r1 ((:) (Symbol, Type) ((,) Symbol Type s2 a2) r2) Source # 

Methods

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

class IsElemOf s a r Source #

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

Minimal complete definition

get

Instances

IsElemOf' (SameFieldLabel s1 s2) s1 a1 s2 a2 r => IsElemOf s1 a1 ((:) (FieldLabel, Type) ((,) FieldLabel Type s2 a2) r) Source # 

Methods

get :: Record (((FieldLabel, Type) ': (FieldLabel, Type) s2 a2) r) -> a1