Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides syntax for labelling values with symbolic field names.
Given val :: a
, we can specify a label by using the syntax
#field := val
, which has type "field" := a
.
For instance, we can pass a record of three arguments with the syntax:
myRecord :: ( "field1" := Int, "field2" := Bool, "field3" := Float ) myRecord = ( field2 := True, #field3 := 7.7 )
This is a simple triple of labelled types, so the order matters.
However, this library provides functionality which will automatically handle re-ordering fields when needed, see Data.Generic.Labels.
Documentation
newtype (lbl :: Symbol) := (a :: Type) infix 1 Source #
pattern (:=) :: Label lbl -> a -> lbl := a infix 1 | Add a With ( #bar := Just |
Instances
GLens' (HasTotalLabelPSym lbl) (args :*: opts) all => GAdapt args opts (M1 m meta (Rec0 (lbl := all))) Source # | This instance is INCOHERENT because we assume that no type variable (say The end result is that, when we have both a built-in Haskell record field name as well as an explicit label, we prioritise the built-in record field name over the label. |
(Generic args, Generic all, optFld ~ S1 ('MetaSel ('Just lbl) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 o), GAdapt (Rep args) optFld (Rep all)) => UncheckedAdapt args (lbl := o) all Source # | |
Defined in Data.Generic.Labels uncheckedAdapt :: args -> (lbl := o) -> all Source # | |
(KnownSymbol lbl, Show a) => Show (lbl := a) Source # | |
(Generic opt, Generic all, argFld ~ S1 ('MetaSel ('Just lbl) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a), GAdapt argFld (Rep opt) (Rep all)) => UncheckedAdapt (lbl := a) opt all Source # | |
Defined in Data.Generic.Labels uncheckedAdapt :: (lbl := a) -> opt -> all Source # | |
a ~ b => UncheckedAdapt (lbl := a) opt (lbl := b) Source # | |
Defined in Data.Generic.Labels uncheckedAdapt :: (lbl := a) -> opt -> lbl := b Source # | |
(Generic all, argFld ~ S1 ('MetaSel ('Just lbl1) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a), optFld ~ S1 ('MetaSel ('Just lbl2) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 o), GAdapt argFld optFld (Rep all)) => UncheckedAdapt (lbl1 := a) (lbl2 := o) all Source # | |
Defined in Data.Generic.Labels uncheckedAdapt :: (lbl1 := a) -> (lbl2 := o) -> all Source # | |
(a ~ b, o ~ b) => UncheckedAdapt (lbl := a) (lbl := o) (lbl := b) Source # | |
Defined in Data.Generic.Labels |