generic-records-0.1.0.0: Magic record operations using generics

Copyright(C) 2016 Csongor Kiss
LicenseBSD3
MaintainerCsongor Kiss <kiss.csongor.kiss@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Records.Generic

Contents

Description

Magic record operations using Generics

These classes need not be instantiated manually, as GHC can automatically prove valid instances via Generics. Only the Generic class needs to be derived (see examples).

Synopsis

Magic getter

class Generic rec => HasField rec field a where Source #

Records that have a field with a given name

Minimal complete definition

getField

Methods

getField :: rec -> Proxy field -> a Source #

Instances

((~) (Maybe Type) (Contains field (Collect (Rep rec))) (Just Type a), Generic rec, LookupField * Symbol (Rep rec) field a) => HasField rec field a Source # 

Methods

getField :: rec -> Proxy Symbol field -> a Source #

Subtype relationship

class Subtype a b where Source #

Structural subtype relationship

Minimal complete definition

upcast

Methods

upcast :: a -> b Source #

Instances

(Convert (Rep a) (Rep b), Generic a, Generic b) => Subtype a b Source # 

Methods

upcast :: a -> b Source #