| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Vinyl
Synopsis
- module Data.Vinyl.Core
- class RecMapMethod (c :: Type -> Constraint) (f :: u -> Type) (ts :: [u]) where
- rmapMethod :: (forall (a :: u). c (PayloadType f a) => f a -> g a) -> Rec f ts -> Rec g ts
- class RecPointed (c :: Type -> Constraint) (f :: u -> Type) (ts :: [u]) where
- rpointMethod :: (forall (a :: u). c (f a) => f a) -> Rec f ts
- rmapMethodF :: forall c (f :: Type -> Type) (ts :: [Type]). (Functor f, FieldPayload f ~ 'FieldId, RecMapMethod c f ts) => (forall a. c a => a -> a) -> Rec f ts -> Rec f ts
- mapFields :: forall c (ts :: [(Symbol, Type)]). RecMapMethod c ElField ts => (forall a. c a => a -> a) -> FieldRec ts -> FieldRec ts
- rtraverseInMethod :: forall {u} c (h :: Type -> Type) f g (rs :: [u]). (RMap rs, RPureConstrained c rs, RApply rs) => (forall (a :: u). c a => f a -> g (ApplyToField h a)) -> Rec f rs -> Rec g (MapTyCon h rs)
- rsequenceInFields :: forall (f :: Type -> Type) (rs :: [(Symbol, Type)]). (Functor f, AllFields rs, RMap rs) => Rec (f :. ElField) rs -> Rec ElField (MapTyCon f rs)
- data ARec (f :: k -> Type) (ts :: [k])
- toARec :: forall {k} (f :: k -> Type) (ts :: [k]). (NatToInt (RLength ts), ToARec ts) => Rec f ts -> ARec f ts
- fromARec :: forall {u} (f :: u -> Type) (ts :: [u]). (RecApplicative ts, RPureConstrained (IndexableField ts) ts) => ARec f ts -> Rec f ts
- module Data.Vinyl.Derived
- record :: TupleRec f t => t -> UncurriedRec (TupleToRecArgs f t)
- fieldRec :: TupleRec ElField t => t -> UncurriedRec (TupleToRecArgs ElField t)
- ruple :: forall {u} (f :: u -> Type) (ts :: [u]). (IsoXRec f ts, TupleXRec f ts) => Rec f ts -> ListToHKDTuple f ts
- xrec :: forall {u} (f :: u -> Type) (t :: [u]). (IsoXRec f t, TupleXRec f t) => ListToHKDTuple f t -> Rec f t
- xrecX :: TupleXRec f t => ListToHKDTuple f t -> XRec f t
- xrecTuple :: TupleXRec f t => XRec f t -> ListToHKDTuple f t
- newtype ElField (t :: (Symbol, Type)) = Field (Snd t)
- module Data.Vinyl.Lens
- data SRec (f :: k -> Type) (ts :: [k])
- toSRec :: forall {k} (f :: k -> Type) (ts :: [k]). Storable (Rec f ts) => Rec f ts -> SRec f ts
- fromSRec :: forall {u} (f :: u -> Type) (ts :: [u]). Storable (Rec f ts) => SRec f ts -> Rec f ts
- type XRec (f :: u -> Type) = Rec (XData f)
- pattern (::&) :: forall {a} (f :: a -> Type) (r :: a) rs. HKD f r -> XRec f rs -> XRec f (r ': rs)
- pattern XRNil :: forall {u} (f :: u -> Type). XRec f ('[] :: [u])
- class IsoXRec (f :: u -> Type) (ts :: [u]) where
- xrmap :: forall {u} (f :: u -> Type) (g :: u -> Type) (rs :: [u]). XRMap f g rs => (forall (a :: u). HKD f a -> HKD g a) -> XRec f rs -> XRec g rs
- class XRApply (f :: u -> Type) (g :: u -> Type) (rs :: [u]) where
- rmapX :: forall {u} (f :: u -> Type) (g :: u -> Type) (rs :: [u]). (XRMap f g rs, IsoXRec f rs, IsoXRec g rs) => (forall (a :: u). HKD f a -> HKD g a) -> Rec f rs -> Rec g rs
- class XRMap (f :: u -> Type) (g :: u -> Type) (rs :: [u])
Documentation
module Data.Vinyl.Core
class RecMapMethod (c :: Type -> Constraint) (f :: u -> Type) (ts :: [u]) where Source #
Apply a typeclass method to each field of a Rec where the class
constrains the index of the field, but not its interpretation
functor.
Methods
rmapMethod :: (forall (a :: u). c (PayloadType f a) => f a -> g a) -> Rec f ts -> Rec g ts Source #
Instances
| RecMapMethod c (f :: u -> Type) ('[] :: [u]) Source # | |
Defined in Data.Vinyl.Class.Method Methods rmapMethod :: (forall (a :: u). c (PayloadType f a) => f a -> g a) -> Rec f ('[] :: [u]) -> Rec g ('[] :: [u]) Source # | |
| (c (PayloadType f t), RecMapMethod c f ts) => RecMapMethod c (f :: a -> Type) (t ': ts :: [a]) Source # | |
Defined in Data.Vinyl.Class.Method Methods rmapMethod :: (forall (a0 :: a). c (PayloadType f a0) => f a0 -> g a0) -> Rec f (t ': ts) -> Rec g (t ': ts) Source # | |
class RecPointed (c :: Type -> Constraint) (f :: u -> Type) (ts :: [u]) where Source #
Generate a record from fields derived from type class instances.
Methods
rpointMethod :: (forall (a :: u). c (f a) => f a) -> Rec f ts Source #
Instances
| RecPointed c (f :: u -> Type) ('[] :: [u]) Source # | |
Defined in Data.Vinyl.Class.Method Methods rpointMethod :: (forall (a :: u). c (f a) => f a) -> Rec f ('[] :: [u]) Source # | |
| (c (f t), RecPointed c f ts) => RecPointed c (f :: a -> Type) (t ': ts :: [a]) Source # | |
Defined in Data.Vinyl.Class.Method Methods rpointMethod :: (forall (a0 :: a). c (f a0) => f a0) -> Rec f (t ': ts) Source # | |
rmapMethodF :: forall c (f :: Type -> Type) (ts :: [Type]). (Functor f, FieldPayload f ~ 'FieldId, RecMapMethod c f ts) => (forall a. c a => a -> a) -> Rec f ts -> Rec f ts Source #
Apply a typeclass method to each field of a Rec f ts using the
Functor instance for f to lift the function into the
functor. This is a commonly-used specialization of rmapMethod
composed with fmap.
mapFields :: forall c (ts :: [(Symbol, Type)]). RecMapMethod c ElField ts => (forall a. c a => a -> a) -> FieldRec ts -> FieldRec ts Source #
Apply a typeclass method to each field of a FieldRec. This is a
specialization of rmapMethod.
rtraverseInMethod :: forall {u} c (h :: Type -> Type) f g (rs :: [u]). (RMap rs, RPureConstrained c rs, RApply rs) => (forall (a :: u). c a => f a -> g (ApplyToField h a)) -> Rec f rs -> Rec g (MapTyCon h rs) Source #
Like rtraverseIn, but the function between functors may be
constrained.
rsequenceInFields :: forall (f :: Type -> Type) (rs :: [(Symbol, Type)]). (Functor f, AllFields rs, RMap rs) => Rec (f :. ElField) rs -> Rec ElField (MapTyCon f rs) Source #
Push an outer layer of interpretation functor into each named field.
data ARec (f :: k -> Type) (ts :: [k]) Source #
An array-backed extensible record with constant-time field access.
Instances
| (is ~ RImage rs ss, IndexWitnesses is, NatToInt (RLength rs)) => RecSubset (ARec :: (k1 -> Type) -> [k1] -> Type) (rs :: [k1]) (ss :: [k1]) is Source # | |
Defined in Data.Vinyl.ARec.Internal Methods rsubsetC :: forall g (f :: k1 -> Type). (Functor g, RecSubsetFCtx (ARec :: (k1 -> Type) -> [k1] -> Type) f) => (ARec f rs -> g (ARec f rs)) -> ARec f ss -> g (ARec f ss) Source # rcastC :: forall (f :: k1 -> Type). RecSubsetFCtx (ARec :: (k1 -> Type) -> [k1] -> Type) f => ARec f ss -> ARec f rs Source # rreplaceC :: forall (f :: k1 -> Type). RecSubsetFCtx (ARec :: (k1 -> Type) -> [k1] -> Type) f => ARec f rs -> ARec f ss -> ARec f ss Source # | |
| RecElem (ARec :: (a -> Type) -> [a] -> Type) (t :: a) (t' :: a) (t ': ts :: [a]) (t' ': ts :: [a]) 'Z Source # | |
Defined in Data.Vinyl.ARec.Internal Methods rlensC :: (Functor g, RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f) => (f t -> g (f t')) -> ARec f (t ': ts) -> g (ARec f (t' ': ts)) Source # rgetC :: (RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f, t ~ t') => ARec f (t ': ts) -> f t Source # rputC :: RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f => f t' -> ARec f (t ': ts) -> ARec f (t' ': ts) Source # | |
| (RIndex t (s ': ts) ~ 'S i, NatToInt i, RecElem (ARec :: (a -> Type) -> [a] -> Type) t t' ts ts' i) => RecElem (ARec :: (a -> Type) -> [a] -> Type) (t :: a) (t' :: a) (s ': ts :: [a]) (s ': ts' :: [a]) ('S i) Source # | |
Defined in Data.Vinyl.ARec.Internal Methods rlensC :: (Functor g, RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f) => (f t -> g (f t')) -> ARec f (s ': ts) -> g (ARec f (s ': ts')) Source # rgetC :: (RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f, t ~ t') => ARec f (s ': ts) -> f t Source # rputC :: RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) f => f t' -> ARec f (s ': ts) -> ARec f (s ': ts') Source # | |
| (RPureConstrained (IndexableField rs) rs, RecApplicative rs, Show (Rec f rs)) => Show (ARec f rs) Source # | |
| (RPureConstrained (IndexableField rs) rs, RecApplicative rs, Eq (Rec f rs)) => Eq (ARec f rs) Source # | |
| (RPureConstrained (IndexableField rs) rs, RecApplicative rs, Ord (Rec f rs)) => Ord (ARec f rs) Source # | |
| type RecSubsetFCtx (ARec :: (k1 -> Type) -> [k1] -> Type) (f :: k1 -> Type) Source # | |
Defined in Data.Vinyl.ARec.Internal | |
| type RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) Source # | |
Defined in Data.Vinyl.ARec.Internal | |
| type RecElemFCtx (ARec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) Source # | |
Defined in Data.Vinyl.ARec.Internal | |
toARec :: forall {k} (f :: k -> Type) (ts :: [k]). (NatToInt (RLength ts), ToARec ts) => Rec f ts -> ARec f ts Source #
fromARec :: forall {u} (f :: u -> Type) (ts :: [u]). (RecApplicative ts, RPureConstrained (IndexableField ts) ts) => ARec f ts -> Rec f ts Source #
module Data.Vinyl.Derived
record :: TupleRec f t => t -> UncurriedRec (TupleToRecArgs f t) Source #
fieldRec :: TupleRec ElField t => t -> UncurriedRec (TupleToRecArgs ElField t) Source #
Build a FieldRec from a tuple of ElField values.
ruple :: forall {u} (f :: u -> Type) (ts :: [u]). (IsoXRec f ts, TupleXRec f ts) => Rec f ts -> ListToHKDTuple f ts Source #
xrec :: forall {u} (f :: u -> Type) (t :: [u]). (IsoXRec f t, TupleXRec f t) => ListToHKDTuple f t -> Rec f t Source #
xrecTuple :: TupleXRec f t => XRec f t -> ListToHKDTuple f t Source #
Convert an XRec to a tuple. Useful for pattern matching on an
entire record.
newtype ElField (t :: (Symbol, Type)) Source #
A value with a phantom Symbol label. It is not a
Haskell Functor, but it is used in many of the same places a
Functor is used in vinyl.
Morally: newtype ElField (s, t) = Field t But GHC doesn't allow that
Instances
module Data.Vinyl.Lens
data SRec (f :: k -> Type) (ts :: [k]) Source #
A simpler type for SRec2 whose RecElem and RecSubset
instances are specialized to the ElField functor.
Instances
| (i ~ RIndex t ts, NatToInt i, FieldOffset ElField ts t, Storable (Rec ElField ts), AllConstrained (FieldOffset ElField ts) ts) => RecElem (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) (t :: (Symbol, Type)) (t :: (Symbol, Type)) (ts :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) i Source # | |||||
Defined in Data.Vinyl.SRec Associated Types
Methods rlensC :: (Functor g, RecElemFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f) => (f t -> g (f t)) -> SRec f ts -> g (SRec f ts) Source # rgetC :: (RecElemFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f, t ~ t) => SRec f ts -> f t Source # rputC :: RecElemFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f => f t -> SRec f ts -> SRec f ts Source # | |||||
| (is ~ RImage rs ss, RecSubset (Rec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) rs ss is, Storable (Rec ElField rs), Storable (Rec ElField ss), RPureConstrained (FieldOffset ElField ss) rs, RPureConstrained (FieldOffset ElField rs) rs, RFoldMap rs, RMap rs, RApply rs) => RecSubset (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) is Source # | |||||
Defined in Data.Vinyl.SRec Associated Types
Methods rsubsetC :: forall g (f :: (Symbol, Type) -> Type). (Functor g, RecSubsetFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f) => (SRec f rs -> g (SRec f rs)) -> SRec f ss -> g (SRec f ss) Source # rcastC :: forall (f :: (Symbol, Type) -> Type). RecSubsetFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f => SRec f ss -> SRec f rs Source # rreplaceC :: forall (f :: (Symbol, Type) -> Type). RecSubsetFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f => SRec f rs -> SRec f ss -> SRec f ss Source # | |||||
| type RecElemFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) (f :: (Symbol, Type) -> Type) Source # | |||||
| type RecSubsetFCtx (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) (f :: (Symbol, Type) -> Type) Source # | |||||
toSRec :: forall {k} (f :: k -> Type) (ts :: [k]). Storable (Rec f ts) => Rec f ts -> SRec f ts Source #
fromSRec :: forall {u} (f :: u -> Type) (ts :: [u]). Storable (Rec f ts) => SRec f ts -> Rec f ts Source #
pattern (::&) :: forall {a} (f :: a -> Type) (r :: a) rs. HKD f r -> XRec f rs -> XRec f (r ': rs) infixr 7 Source #
class IsoXRec (f :: u -> Type) (ts :: [u]) where Source #
Conversion between XRec and Rec. It is convenient to build
and consume XRec values to reduce syntactic noise, but Rec has
a richer API that is difficult to build around the HKD type
family.
xrmap :: forall {u} (f :: u -> Type) (g :: u -> Type) (rs :: [u]). XRMap f g rs => (forall (a :: u). HKD f a -> HKD g a) -> XRec f rs -> XRec g rs Source #
This is rmap for XRec. We apply a natural transformation
between interpretation functors to transport a record value between
interpretations.
class XRApply (f :: u -> Type) (g :: u -> Type) (rs :: [u]) where Source #
Like rapply: record of components f r -> g r may be applied
to a record of f to get a record of g.
rmapX :: forall {u} (f :: u -> Type) (g :: u -> Type) (rs :: [u]). (XRMap f g rs, IsoXRec f rs, IsoXRec g rs) => (forall (a :: u). HKD f a -> HKD g a) -> Rec f rs -> Rec g rs Source #
class XRMap (f :: u -> Type) (g :: u -> Type) (rs :: [u]) Source #
The implementation of xrmap is broken into a type class to
permit unrolling of the recursion across a record. The function
mapped across the vector hides the HKD type family under a newtype
constructor to help the type checker.
Minimal complete definition