vinyl-0.9.3: Extensible Records

Safe HaskellNone
LanguageHaskell2010

Data.Vinyl

Synopsis

Documentation

class RecMapMethod c (f :: u -> *) (ts :: [u]) where Source #

Apply a typeclass method to each field of a Rec.

Minimal complete definition

rmapMethod

Methods

rmapMethod :: (forall a. c (PayloadType f a) => f a -> g a) -> Rec f ts -> Rec g ts Source #

Instances
RecMapMethod c (f :: u -> *) ([] :: [u]) Source # 
Instance details

Defined in Data.Vinyl.Class.Method

Methods

rmapMethod :: (forall (a :: u0). c (PayloadType f a) => f a -> g a) -> Rec f [] -> Rec g [] Source #

(c (PayloadType f t), RecMapMethod c f ts) => RecMapMethod c (f :: a -> *) (t ': ts :: [a]) Source # 
Instance details

Defined in Data.Vinyl.Class.Method

Methods

rmapMethod :: (forall (a0 :: u). c (PayloadType f a0) => f a0 -> g a0) -> Rec f (t ': ts) -> Rec g (t ': ts) Source #

class RecPointed c (f :: u -> *) (ts :: [u]) where Source #

Generate a record from fields derived from type class instances.

Minimal complete definition

rpointMethod

Methods

rpointMethod :: (forall (a :: u). c (f a) => f a) -> Rec f ts Source #

Instances
RecPointed c (f :: u -> *) ([] :: [u]) Source # 
Instance details

Defined in Data.Vinyl.Class.Method

Methods

rpointMethod :: (forall (a :: u0). c (f a) => f a) -> Rec f [] Source #

(c (f t), RecPointed c f ts) => RecPointed c (f :: a -> *) (t ': ts :: [a]) Source # 
Instance details

Defined in Data.Vinyl.Class.Method

Methods

rpointMethod :: (forall (a0 :: u). c (f a0) => f a0) -> Rec f (t ': ts) Source #

rmapMethodF :: forall c f ts. (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. 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.

data ARec (f :: k -> *) (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 :: (k -> *) -> [k] -> *) (rs :: [k]) (ss :: [k]) is Source # 
Instance details

Defined in Data.Vinyl.ARec

Associated Types

type RecSubsetFCtx ARec f :: Constraint Source #

Methods

rsubsetC :: (Functor g, RecSubsetFCtx ARec f) => (ARec f rs -> g (ARec f rs)) -> ARec f ss -> g (ARec f ss) Source #

rcastC :: RecSubsetFCtx ARec f => ARec f ss -> ARec f rs Source #

rreplaceC :: RecSubsetFCtx ARec f => ARec f rs -> ARec f ss -> ARec f ss Source #

RecElem (ARec :: (a -> *) -> [a] -> *) (t :: a) (t' :: a) (t ': ts :: [a]) (t' ': ts :: [a]) Z Source # 
Instance details

Defined in Data.Vinyl.ARec

Associated Types

type RecElemFCtx ARec f :: Constraint Source #

Methods

rlensC :: (Functor g, RecElemFCtx ARec f) => (f t -> g (f t')) -> ARec f (t ': ts) -> g (ARec f (t' ': ts)) Source #

rgetC :: (RecElemFCtx ARec f, t ~ t') => ARec f (t ': ts) -> f t Source #

rputC :: RecElemFCtx ARec f => f t' -> ARec f (t ': ts) -> ARec f (t' ': ts) Source #

(RIndex t (s ': ts) ~ S i, NatToInt i, RecElem (ARec :: (a -> *) -> [a] -> *) t t' ts ts' i) => RecElem (ARec :: (a -> *) -> [a] -> *) (t :: a) (t' :: a) (s ': ts :: [a]) (s ': ts' :: [a]) (S i) Source # 
Instance details

Defined in Data.Vinyl.ARec

Associated Types

type RecElemFCtx ARec f :: Constraint Source #

Methods

rlensC :: (Functor g, RecElemFCtx ARec f) => (f t -> g (f t')) -> ARec f (s ': ts) -> g (ARec f (s ': ts')) Source #

rgetC :: (RecElemFCtx ARec f, t ~ t') => ARec f (s ': ts) -> f t Source #

rputC :: RecElemFCtx ARec f => f t' -> ARec f (s ': ts) -> ARec f (s ': ts') Source #

(RPureConstrained (IndexableField rs) rs, RecApplicative rs, Eq (Rec f rs)) => Eq (ARec f rs) Source # 
Instance details

Defined in Data.Vinyl.ARec

Methods

(==) :: ARec f rs -> ARec f rs -> Bool #

(/=) :: ARec f rs -> ARec f rs -> Bool #

(RPureConstrained (IndexableField rs) rs, RecApplicative rs, Ord (Rec f rs)) => Ord (ARec f rs) Source # 
Instance details

Defined in Data.Vinyl.ARec

Methods

compare :: ARec f rs -> ARec f rs -> Ordering #

(<) :: ARec f rs -> ARec f rs -> Bool #

(<=) :: ARec f rs -> ARec f rs -> Bool #

(>) :: ARec f rs -> ARec f rs -> Bool #

(>=) :: ARec f rs -> ARec f rs -> Bool #

max :: ARec f rs -> ARec f rs -> ARec f rs #

min :: ARec f rs -> ARec f rs -> ARec f rs #

(RPureConstrained (IndexableField rs) rs, RecApplicative rs, Show (Rec f rs)) => Show (ARec f rs) Source # 
Instance details

Defined in Data.Vinyl.ARec

Methods

showsPrec :: Int -> ARec f rs -> ShowS #

show :: ARec f rs -> String #

showList :: [ARec f rs] -> ShowS #

type RecSubsetFCtx (ARec :: (k -> *) -> [k] -> *) (f :: k -> *) Source # 
Instance details

Defined in Data.Vinyl.ARec

type RecSubsetFCtx (ARec :: (k -> *) -> [k] -> *) (f :: k -> *) = ()
type RecElemFCtx (ARec :: (a -> *) -> [a] -> *) (f :: a -> *) Source # 
Instance details

Defined in Data.Vinyl.ARec

type RecElemFCtx (ARec :: (a -> *) -> [a] -> *) (f :: a -> *) = ()
type RecElemFCtx (ARec :: (a -> *) -> [a] -> *) (f :: a -> *) Source # 
Instance details

Defined in Data.Vinyl.ARec

type RecElemFCtx (ARec :: (a -> *) -> [a] -> *) (f :: a -> *) = ()

toARec :: forall f ts. NatToInt (RLength ts) => Rec f ts -> ARec f ts Source #

Convert a Rec into an ARec for constant-time field access.

fromARec :: forall f ts. (RecApplicative ts, RPureConstrained (IndexableField ts) ts) => ARec f ts -> Rec f ts Source #

Convert an ARec into a Rec.

xrecX :: TupleXRec f t => ListToHKDTuple f t -> XRec f t Source #

Build an XRec from a tuple.

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.

ruple :: (IsoXRec f ts, TupleXRec f ts) => Rec f ts -> ListToHKDTuple f ts Source #

Convert a Rec to a tuple going through HKD to reduce syntactic noise. Useful for pattern matching on an entire Rec.

xrec :: (IsoXRec f t, TupleXRec f t) => ListToHKDTuple f t -> Rec f t Source #

Build a Rec from a tuple passing through XRec. This admits the most concise syntax for building a Rec. For example, xrec ("joe", 23) :: Rec Identity '[String, Int].

fieldRec :: TupleRec ElField t => t -> UncurriedRec (TupleToRecArgs ElField t) Source #

Build a FieldRec from a tuple of ElField values.

data ElField (field :: (Symbol, Type)) where 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.

Constructors

Field :: KnownSymbol s => !t -> ElField '(s, t) 
Instances
Eq t => Eq (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(==) :: ElField (s, t) -> ElField (s, t) -> Bool #

(/=) :: ElField (s, t) -> ElField (s, t) -> Bool #

(Floating t, KnownSymbol s) => Floating (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

pi :: ElField (s, t) #

exp :: ElField (s, t) -> ElField (s, t) #

log :: ElField (s, t) -> ElField (s, t) #

sqrt :: ElField (s, t) -> ElField (s, t) #

(**) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

logBase :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

sin :: ElField (s, t) -> ElField (s, t) #

cos :: ElField (s, t) -> ElField (s, t) #

tan :: ElField (s, t) -> ElField (s, t) #

asin :: ElField (s, t) -> ElField (s, t) #

acos :: ElField (s, t) -> ElField (s, t) #

atan :: ElField (s, t) -> ElField (s, t) #

sinh :: ElField (s, t) -> ElField (s, t) #

cosh :: ElField (s, t) -> ElField (s, t) #

tanh :: ElField (s, t) -> ElField (s, t) #

asinh :: ElField (s, t) -> ElField (s, t) #

acosh :: ElField (s, t) -> ElField (s, t) #

atanh :: ElField (s, t) -> ElField (s, t) #

log1p :: ElField (s, t) -> ElField (s, t) #

expm1 :: ElField (s, t) -> ElField (s, t) #

log1pexp :: ElField (s, t) -> ElField (s, t) #

log1mexp :: ElField (s, t) -> ElField (s, t) #

(Fractional t, KnownSymbol s) => Fractional (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(/) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

recip :: ElField (s, t) -> ElField (s, t) #

fromRational :: Rational -> ElField (s, t) #

(Num t, KnownSymbol s) => Num (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(+) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

(-) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

(*) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

negate :: ElField (s, t) -> ElField (s, t) #

abs :: ElField (s, t) -> ElField (s, t) #

signum :: ElField (s, t) -> ElField (s, t) #

fromInteger :: Integer -> ElField (s, t) #

Ord t => Ord (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

compare :: ElField (s, t) -> ElField (s, t) -> Ordering #

(<) :: ElField (s, t) -> ElField (s, t) -> Bool #

(<=) :: ElField (s, t) -> ElField (s, t) -> Bool #

(>) :: ElField (s, t) -> ElField (s, t) -> Bool #

(>=) :: ElField (s, t) -> ElField (s, t) -> Bool #

max :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

min :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

(Real t, KnownSymbol s) => Real (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

toRational :: ElField (s, t) -> Rational #

(RealFrac t, KnownSymbol s) => RealFrac (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

properFraction :: Integral b => ElField (s, t) -> (b, ElField (s, t)) #

truncate :: Integral b => ElField (s, t) -> b #

round :: Integral b => ElField (s, t) -> b #

ceiling :: Integral b => ElField (s, t) -> b #

floor :: Integral b => ElField (s, t) -> b #

(Show t, KnownSymbol s) => Show (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

showsPrec :: Int -> ElField (s, t) -> ShowS #

show :: ElField (s, t) -> String #

showList :: [ElField (s, t)] -> ShowS #

Semigroup t => Semigroup (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(<>) :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

sconcat :: NonEmpty (ElField (s, t)) -> ElField (s, t) #

stimes :: Integral b => b -> ElField (s, t) -> ElField (s, t) #

(KnownSymbol s, Monoid t) => Monoid (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

mempty :: ElField (s, t) #

mappend :: ElField (s, t) -> ElField (s, t) -> ElField (s, t) #

mconcat :: [ElField (s, t)] -> ElField (s, t) #

(KnownSymbol s, Storable t) => Storable (ElField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

sizeOf :: ElField (s, t) -> Int #

alignment :: ElField (s, t) -> Int #

peekElemOff :: Ptr (ElField (s, t)) -> Int -> IO (ElField (s, t)) #

pokeElemOff :: Ptr (ElField (s, t)) -> Int -> ElField (s, t) -> IO () #

peekByteOff :: Ptr b -> Int -> IO (ElField (s, t)) #

pokeByteOff :: Ptr b -> Int -> ElField (s, t) -> IO () #

peek :: Ptr (ElField (s, t)) -> IO (ElField (s, t)) #

poke :: Ptr (ElField (s, t)) -> ElField (s, t) -> IO () #

KnownSymbol s => IsoHKD ElField ((,) s a :: (Symbol, Type)) Source #

Work with values of type ElField '(s,a) as if they were of type a.

Instance details

Defined in Data.Vinyl.XRec

Associated Types

type HKD ElField (s, a) :: * Source #

Methods

unHKD :: HKD ElField (s, a) -> ElField (s, a) Source #

toHKD :: ElField (s, a) -> HKD ElField (s, a) Source #

(is ~ RImage rs ss, RecSubset (Rec :: ((Symbol, Type) -> *) -> [(Symbol, 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 (SRec2 ElField) (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) is Source # 
Instance details

Defined in Data.Vinyl.SRec

Associated Types

type RecSubsetFCtx (SRec2 ElField) f :: Constraint Source #

(i ~ RIndex t ts, FieldOffset ElField ts t, Storable (Rec ElField ts), AllConstrained (FieldOffset ElField ts) ts) => RecElem (SRec2 ElField) (t :: (Symbol, Type)) (t :: (Symbol, Type)) (ts :: [(Symbol, Type)]) (ts :: [(Symbol, Type)]) i Source #

Field accessors for SRec2 specialized to ElField as the functor.

Instance details

Defined in Data.Vinyl.SRec

Associated Types

type RecElemFCtx (SRec2 ElField) f :: Constraint Source #

Methods

rlensC :: (Functor g, RecElemFCtx (SRec2 ElField) f) => (f t -> g (f t)) -> SRec2 ElField f ts -> g (SRec2 ElField f ts) Source #

rgetC :: (RecElemFCtx (SRec2 ElField) f, t ~ t) => SRec2 ElField f ts -> f t Source #

rputC :: RecElemFCtx (SRec2 ElField) f => f t -> SRec2 ElField f ts -> SRec2 ElField f ts Source #

type HKD ElField ((,) s a :: (Symbol, Type)) Source # 
Instance details

Defined in Data.Vinyl.XRec

type HKD ElField ((,) s a :: (Symbol, Type)) = a
type RecSubsetFCtx (SRec2 ElField) (f :: (Symbol, Type) -> *) Source # 
Instance details

Defined in Data.Vinyl.SRec

type RecSubsetFCtx (SRec2 ElField) (f :: (Symbol, Type) -> *) = f ~ ElField
type RecElemFCtx (SRec2 ElField) (f :: (Symbol, Type) -> *) Source # 
Instance details

Defined in Data.Vinyl.SRec

type RecElemFCtx (SRec2 ElField) (f :: (Symbol, Type) -> *) = f ~ ElField

data SRec f ts Source #

A simpler type for SRec2 whose RecElem and RecSubset instances are specialized to the ElField functor.

Instances
(is ~ RImage rs ss, RecSubset (Rec :: ((Symbol, Type) -> *) -> [(Symbol, 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) -> *) -> [(Symbol, Type)] -> *) (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) is Source # 
Instance details

Defined in Data.Vinyl.SRec

Associated Types

type RecSubsetFCtx SRec f :: Constraint Source #

Methods

rsubsetC :: (Functor g, RecSubsetFCtx SRec f) => (SRec f rs -> g (SRec f rs)) -> SRec f ss -> g (SRec f ss) Source #

rcastC :: RecSubsetFCtx SRec f => SRec f ss -> SRec f rs Source #

rreplaceC :: RecSubsetFCtx SRec f => SRec f rs -> SRec f ss -> SRec f ss Source #

(i ~ RIndex t ts, FieldOffset ElField ts t, Storable (Rec ElField ts), AllConstrained (FieldOffset ElField ts) ts) => RecElem (SRec :: ((Symbol, *) -> *) -> [(Symbol, *)] -> *) (t :: (Symbol, *)) (t :: (Symbol, *)) (ts :: [(Symbol, *)]) (ts :: [(Symbol, *)]) i Source # 
Instance details

Defined in Data.Vinyl.SRec

Associated Types

type RecElemFCtx SRec f :: Constraint Source #

Methods

rlensC :: (Functor g, RecElemFCtx SRec f) => (f t -> g (f t)) -> SRec f ts -> g (SRec f ts) Source #

rgetC :: (RecElemFCtx SRec f, t ~ t) => SRec f ts -> f t Source #

rputC :: RecElemFCtx SRec f => f t -> SRec f ts -> SRec f ts Source #

type RecSubsetFCtx (SRec :: ((Symbol, Type) -> *) -> [(Symbol, Type)] -> *) (f :: (Symbol, Type) -> *) Source # 
Instance details

Defined in Data.Vinyl.SRec

type RecSubsetFCtx (SRec :: ((Symbol, Type) -> *) -> [(Symbol, Type)] -> *) (f :: (Symbol, Type) -> *) = f ~ ElField
type RecElemFCtx (SRec :: ((Symbol, *) -> *) -> [(Symbol, *)] -> *) (f :: (Symbol, *) -> *) Source # 
Instance details

Defined in Data.Vinyl.SRec

type RecElemFCtx (SRec :: ((Symbol, *) -> *) -> [(Symbol, *)] -> *) (f :: (Symbol, *) -> *) = f ~ ElField

toSRec :: Storable (Rec f ts) => Rec f ts -> SRec f ts Source #

Create an SRec from a Rec. This should offer very fast field access, but note that its lens API (via RecElem and RecSubset) is restricted to the ElField functor.

fromSRec :: Storable (Rec f ts) => SRec f ts -> Rec f ts Source #

Create a Rec from an SRec.

class IsoXRec f ts 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.

Minimal complete definition

fromXRec, toXRec

Methods

fromXRec :: XRec f ts -> Rec f ts Source #

toXRec :: Rec f ts -> XRec f ts Source #

Instances
IsoXRec (f :: u -> *) ([] :: [u]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

fromXRec :: XRec f [] -> Rec f [] Source #

toXRec :: Rec f [] -> XRec f [] Source #

(IsoXRec f ts, IsoHKD f t) => IsoXRec (f :: a -> *) (t ': ts :: [a]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

fromXRec :: XRec f (t ': ts) -> Rec f (t ': ts) Source #

toXRec :: Rec f (t ': ts) -> XRec f (t ': ts) Source #

class XRApply f g rs 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.

Minimal complete definition

xrapply

Methods

xrapply :: XRec (Lift (->) f g) rs -> XRec f rs -> XRec g rs Source #

Instances
XRApply (f :: u -> *) (g :: u -> *) ([] :: [u]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

xrapply :: XRec (Lift (->) f g) [] -> XRec f [] -> XRec g [] Source #

XRApply f g rs => XRApply (f :: a -> *) (g :: a -> *) (r ': rs :: [a]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

xrapply :: XRec (Lift (->) f g) (r ': rs) -> XRec f (r ': rs) -> XRec g (r ': rs) Source #

class XRMap (f :: u -> *) (g :: u -> *) (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

xrmapAux

Instances
XRMap (f :: u -> *) (g :: u -> *) ([] :: [u]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

xrmapAux :: (forall (a :: u0). XData f a -> XData g a) -> XRec f [] -> XRec g [] Source #

(XRMap f g rs, IsoHKD f r, IsoHKD g r) => XRMap (f :: a -> *) (g :: a -> *) (r ': rs :: [a]) Source # 
Instance details

Defined in Data.Vinyl.XRec

Methods

xrmapAux :: (forall (a0 :: u). XData f a0 -> XData g a0) -> XRec f (r ': rs) -> XRec g (r ': rs) Source #

type XRec f = Rec (XData f) Source #

pattern XRNil :: XRec f '[] Source #

pattern (::&) :: HKD f r -> XRec f rs -> XRec f (r ': rs) infixr 7 Source #

rmapX :: forall f g rs. (XRMap f g rs, IsoXRec f rs, IsoXRec g rs) => (forall a. HKD f a -> HKD g a) -> Rec f rs -> Rec g rs Source #

Like rmap, but the supplied function is written against the HKD-simplified types. This is xrmap sandwiched in between fromXRec and toXRec.

xrmap :: forall f g rs. XRMap f g rs => (forall a. 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.