| Copyright | (c) 2016, Peter Trško |
|---|---|
| License | BSD3 |
| Maintainer | peter.trsko@gmail.com |
| Stability | experimental |
| Portability | DataKinds, FlexibleInstances, FunctionalDependencies, MagicHash, MultiParamTypeClasses, NoImplicitPrelude, TypeFamilies, UndecidableInstances |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.OverloadedRecords
Description
Magic classes for OverloadedRecordFields.
Implementation is based on: https://github.com/adamgundry/records-prototype/blob/master/CoherentPrototype.hs by Adam Gundry under MIT License.
- module Data.OverloadedLabels
- type family FieldType l s :: *
- class HasField l s a | l s -> a where
- type family UpdateType l s a :: *
- class (HasField l s b, FieldType l s ~ b) => SetField l s b where
- setField :: Proxy# l -> s -> b -> UpdateType l s b
- data Setter s t b
- set :: Setter s t b -> s -> b -> t
Oveloaded Labels
module Data.OverloadedLabels
Overloaded Record Fields
type family FieldType l s :: * Source
When accessing field named l :: Symbol of a record s :: *, then the
type of the value in that field is .FieldType l s
Instances
| type FieldType "fieldDerivation" DeriveOverloadedRecordsParams = FieldDerivation Source |
class HasField l s a | l s -> a where Source
Definition of this class is based on: https://phabricator.haskell.org/D1687
Instances
| HasField "fieldDerivation" DeriveOverloadedRecordsParams FieldDerivation Source |
type family UpdateType l s a :: * Source
If field l :: Symbol of a record s :: * is set to new value which has
type a :: *, then the modified record will have type .UpdateType l s a
Instances
| type UpdateType "fieldDerivation" DeriveOverloadedRecordsParams FieldDerivation = DeriveOverloadedRecordsParams Source |
class (HasField l s b, FieldType l s ~ b) => SetField l s b where Source
Instances
| SetField "fieldDerivation" DeriveOverloadedRecordsParams FieldDerivation Source |
Instances
| (SetField l s b, (~) * (UpdateType l s b) t) => IsLabel l (Setter s t b) Source |