| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Plutarch.DataRepr.Internal.HList
Synopsis
- data HRec as where
- newtype HRecGeneric as = HRecGeneric (HRec as)
- newtype Labeled sym a = Labeled {
- unLabeled :: a
- hrecField :: forall name c as a b s. (ElemOf name a as, Term s (PAsData b) ~ a, PFromDataable b c) => HRec as -> Term s c
- hrecField' :: forall name a as. ElemOf name a as => HRec as -> a
- type family IndexList (n :: Nat) (l :: [k]) :: k where ...
- type family IndexLabel name as where ...
- type family SingleItem (as :: [k]) :: k where ...
- type family Drop (n :: Nat) (as :: [k]) :: [k] where ...
- data Elem (a :: k) (as :: [k]) where
- class IndexLabel name as ~ a => ElemOf name a as | as name -> a where
HRec and Label types
newtype HRecGeneric as Source #
Constructors
| HRecGeneric (HRec as) |
Instances
| (IndexLabel name as ~ a, ElemOf name a as) => HasField (name :: Symbol) (HRecGeneric as) a Source # | |
Defined in Plutarch.DataRepr.Internal.HList Methods getField :: HRecGeneric as -> a Source # | |
Field indexing functions
hrecField :: forall name c as a b s. (ElemOf name a as, Term s (PAsData b) ~ a, PFromDataable b c) => HRec as -> Term s c Source #
Deprecated: please use getField from GHC.Records
Index a HRec with a field in a provided list of data fields.
Implicitly unwraps `PAsData a` to a when necessary.
>>>xs = HRec @["x", "y", "z"] (HCons 1 (HCons 2 (HCons 3 HNil)))>>>hrecField @"y" @["x", "y", "z"] xs>>>2
hrecField' :: forall name a as. ElemOf name a as => HRec as -> a Source #
Index a HList with a field in a provided list of fields.
>>>xs = HRec @["x", "y", "z"] (HCons 1 (HCons 2 (HCons 3 HNil)))>>>hrecField @"y" @["x", "y", "z"] xs>>>2
Type families
type family IndexLabel name as where ... Source #
Indexing list of labeled pairs by label
Equations
| IndexLabel name ('(name, a) ': _) = a | |
| IndexLabel name (_ ': as) = IndexLabel name as |
type family SingleItem (as :: [k]) :: k where ... Source #
Return the single item from a singleton list
Equations
| SingleItem '[a] = a |
Internal utils
data Elem (a :: k) (as :: [k]) where Source #
GADT proof-witness of HList membership, usable as an index
class IndexLabel name as ~ a => ElemOf name a as | as name -> a where Source #
Construct an Elem via Nat.
This class could instead be a more direct version of indexHList,
but perhaps the Elem encoding will be useful.
Methods
elemOf :: Elem '(name, a) as Source #
Construct the Elem corresponding to a Nat index.
Example:
>>>natElem @_ @0Here
>>>natElem @_ @3There (There (There Here))
Instances
| ElemOf name a ('(name, a) ': as) Source # | |
Defined in Plutarch.DataRepr.Internal.HList | |
| (IndexLabel name (b ': as) ~ a, ElemOf name a as) => ElemOf name a (b ': as) Source # | |
Defined in Plutarch.DataRepr.Internal.HList | |