vinyl-0.13.0: Extensible Records

Safe HaskellNone
LanguageHaskell2010

Data.Vinyl.Functor

Contents

Synopsis

Introduction

This module provides functors and functor compositions that can be used as the interpretation function for a Rec. For a more full discussion of this, scroll down to the bottom.

newtype Identity a Source #

This is identical to the Identity from Data.Functor.Identity in "base" except for its Show instance.

Constructors

Identity 

Fields

Instances
Monad Identity Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(>>=) :: Identity a -> (a -> Identity b) -> Identity b #

(>>) :: Identity a -> Identity b -> Identity b #

return :: a -> Identity a #

fail :: String -> Identity a #

Functor Identity Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a -> b) -> Identity a -> Identity b #

(<$) :: a -> Identity b -> Identity a #

Applicative Identity Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

pure :: a -> Identity a #

(<*>) :: Identity (a -> b) -> Identity a -> Identity b #

liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c #

(*>) :: Identity a -> Identity b -> Identity b #

(<*) :: Identity a -> Identity b -> Identity a #

Foldable Identity Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fold :: Monoid m => Identity m -> m #

foldMap :: Monoid m => (a -> m) -> Identity a -> m #

foldr :: (a -> b -> b) -> b -> Identity a -> b #

foldr' :: (a -> b -> b) -> b -> Identity a -> b #

foldl :: (b -> a -> b) -> b -> Identity a -> b #

foldl' :: (b -> a -> b) -> b -> Identity a -> b #

foldr1 :: (a -> a -> a) -> Identity a -> a #

foldl1 :: (a -> a -> a) -> Identity a -> a #

toList :: Identity a -> [a] #

null :: Identity a -> Bool #

length :: Identity a -> Int #

elem :: Eq a => a -> Identity a -> Bool #

maximum :: Ord a => Identity a -> a #

minimum :: Ord a => Identity a -> a #

sum :: Num a => Identity a -> a #

product :: Num a => Identity a -> a #

Traversable Identity Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) #

sequenceA :: Applicative f => Identity (f a) -> f (Identity a) #

mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) #

sequence :: Monad m => Identity (m a) -> m (Identity a) #

Eq a => Eq (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(==) :: Identity a -> Identity a -> Bool #

(/=) :: Identity a -> Identity a -> Bool #

Ord a => Ord (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

compare :: Identity a -> Identity a -> Ordering #

(<) :: Identity a -> Identity a -> Bool #

(<=) :: Identity a -> Identity a -> Bool #

(>) :: Identity a -> Identity a -> Bool #

(>=) :: Identity a -> Identity a -> Bool #

max :: Identity a -> Identity a -> Identity a #

min :: Identity a -> Identity a -> Identity a #

Show a => Show (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

showsPrec :: Int -> Identity a -> ShowS #

show :: Identity a -> String #

showList :: [Identity a] -> ShowS #

Generic (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Associated Types

type Rep (Identity a) :: Type -> Type #

Methods

from :: Identity a -> Rep (Identity a) x #

to :: Rep (Identity a) x -> Identity a #

Storable a => Storable (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

sizeOf :: Identity a -> Int #

alignment :: Identity a -> Int #

peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a) #

pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Identity a) #

pokeByteOff :: Ptr b -> Int -> Identity a -> IO () #

peek :: Ptr (Identity a) -> IO (Identity a) #

poke :: Ptr (Identity a) -> Identity a -> IO () #

IsoHKD Identity (a :: Type) Source #

Work with values of type Identity a as if they were simple of type a.

Instance details

Defined in Data.Vinyl.XRec

Associated Types

type HKD Identity a :: Type Source #

(RecApplicative ts, RecordToList ts, RApply ts, ReifyConstraint Eq Maybe ts, RMap ts) => Eq (CoRec Identity ts) Source # 
Instance details

Defined in Data.Vinyl.CoRec

Methods

(==) :: CoRec Identity ts -> CoRec Identity ts -> Bool #

(/=) :: CoRec Identity ts -> CoRec Identity ts -> Bool #

type Rep (Identity a) Source # 
Instance details

Defined in Data.Vinyl.Functor

type Rep (Identity a) = D1 (MetaData "Identity" "Data.Vinyl.Functor" "vinyl-0.13.0-85P9x7eT4R9ILQKoq4J8ea" True) (C1 (MetaCons "Identity" PrefixI True) (S1 (MetaSel (Just "getIdentity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type HKD Identity (a :: Type) Source # 
Instance details

Defined in Data.Vinyl.XRec

type HKD Identity (a :: Type) = a

data Thunk a Source #

Used this instead of Identity to make a record lazy in its fields.

Constructors

Thunk 

Fields

Instances
Monad Thunk Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(>>=) :: Thunk a -> (a -> Thunk b) -> Thunk b #

(>>) :: Thunk a -> Thunk b -> Thunk b #

return :: a -> Thunk a #

fail :: String -> Thunk a #

Functor Thunk Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a -> b) -> Thunk a -> Thunk b #

(<$) :: a -> Thunk b -> Thunk a #

Applicative Thunk Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

pure :: a -> Thunk a #

(<*>) :: Thunk (a -> b) -> Thunk a -> Thunk b #

liftA2 :: (a -> b -> c) -> Thunk a -> Thunk b -> Thunk c #

(*>) :: Thunk a -> Thunk b -> Thunk b #

(<*) :: Thunk a -> Thunk b -> Thunk a #

Foldable Thunk Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fold :: Monoid m => Thunk m -> m #

foldMap :: Monoid m => (a -> m) -> Thunk a -> m #

foldr :: (a -> b -> b) -> b -> Thunk a -> b #

foldr' :: (a -> b -> b) -> b -> Thunk a -> b #

foldl :: (b -> a -> b) -> b -> Thunk a -> b #

foldl' :: (b -> a -> b) -> b -> Thunk a -> b #

foldr1 :: (a -> a -> a) -> Thunk a -> a #

foldl1 :: (a -> a -> a) -> Thunk a -> a #

toList :: Thunk a -> [a] #

null :: Thunk a -> Bool #

length :: Thunk a -> Int #

elem :: Eq a => a -> Thunk a -> Bool #

maximum :: Ord a => Thunk a -> a #

minimum :: Ord a => Thunk a -> a #

sum :: Num a => Thunk a -> a #

product :: Num a => Thunk a -> a #

Traversable Thunk Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

traverse :: Applicative f => (a -> f b) -> Thunk a -> f (Thunk b) #

sequenceA :: Applicative f => Thunk (f a) -> f (Thunk a) #

mapM :: Monad m => (a -> m b) -> Thunk a -> m (Thunk b) #

sequence :: Monad m => Thunk (m a) -> m (Thunk a) #

Show a => Show (Thunk a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

showsPrec :: Int -> Thunk a -> ShowS #

show :: Thunk a -> String #

showList :: [Thunk a] -> ShowS #

newtype Lift (op :: l -> l' -> *) (f :: k -> l) (g :: k -> l') (x :: k) Source #

Constructors

Lift 

Fields

Instances
(IsoHKD f a, IsoHKD g a) => IsoHKD (Lift ((->) :: Type -> Type -> Type) f g :: k -> Type) (a :: k) Source #

Work with values of type Lift (->) f g a as if they were of type f a -> g a.

Instance details

Defined in Data.Vinyl.XRec

Associated Types

type HKD (Lift (->) f g) a :: Type Source #

Methods

unHKD :: HKD (Lift (->) f g) a -> Lift (->) f g a Source #

toHKD :: Lift (->) f g a -> HKD (Lift (->) f g) a Source #

(Functor f, Functor g) => Functor (Lift Either f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a -> b) -> Lift Either f g a -> Lift Either f g b #

(<$) :: a -> Lift Either f g b -> Lift Either f g a #

(Functor f, Functor g) => Functor (Lift (,) f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a -> b) -> Lift (,) f g a -> Lift (,) f g b #

(<$) :: a -> Lift (,) f g b -> Lift (,) f g a #

(Applicative f, Applicative g) => Applicative (Lift (,) f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

pure :: a -> Lift (,) f g a #

(<*>) :: Lift (,) f g (a -> b) -> Lift (,) f g a -> Lift (,) f g b #

liftA2 :: (a -> b -> c) -> Lift (,) f g a -> Lift (,) f g b -> Lift (,) f g c #

(*>) :: Lift (,) f g a -> Lift (,) f g b -> Lift (,) f g b #

(<*) :: Lift (,) f g a -> Lift (,) f g b -> Lift (,) f g a #

type HKD (Lift ((->) :: Type -> Type -> Type) f g :: k -> Type) (a :: k) Source # 
Instance details

Defined in Data.Vinyl.XRec

type HKD (Lift ((->) :: Type -> Type -> Type) f g :: k -> Type) (a :: k) = HKD f a -> HKD g a

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 #

KnownSymbol s => Generic (ElField ((,) s a)) Source # 
Instance details

Defined in Data.Vinyl.Functor

Associated Types

type Rep (ElField (s, a)) :: Type -> Type #

Methods

from :: ElField (s, a) -> Rep (ElField (s, a)) x #

to :: Rep (ElField (s, a)) x -> ElField (s, a) #

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) :: Type Source #

Methods

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

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

(i ~ RIndex t ts, NatToInt i, 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 #

(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 (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 #

type Rep (ElField ((,) s a)) Source # 
Instance details

Defined in Data.Vinyl.Functor

type Rep (ElField ((,) s a)) = C1 (MetaCons s PrefixI False) (Rec0 a)
type HKD ElField ((,) s a :: (Symbol, Type)) Source # 
Instance details

Defined in Data.Vinyl.XRec

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

Defined in Data.Vinyl.SRec

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

Defined in Data.Vinyl.SRec

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

newtype Compose (f :: l -> *) (g :: k -> l) (x :: k) Source #

Constructors

Compose 

Fields

Instances
(IsoHKD f (HKD g a), IsoHKD g a, Functor f) => IsoHKD (Compose f g :: k -> Type) (a :: k) Source #

Work with values of type Compose f g a as if they were of type f (g a).

Instance details

Defined in Data.Vinyl.XRec

Associated Types

type HKD (Compose f g) a :: Type Source #

Methods

unHKD :: HKD (Compose f g) a -> Compose f g a Source #

toHKD :: Compose f g a -> HKD (Compose f g) a Source #

(Functor f, Functor g) => Functor (Compose f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a -> b) -> Compose f g a -> Compose f g b #

(<$) :: a -> Compose f g b -> Compose f g a #

(Applicative f, Applicative g) => Applicative (Compose f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

pure :: a -> Compose f g a #

(<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b #

liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c #

(*>) :: Compose f g a -> Compose f g b -> Compose f g b #

(<*) :: Compose f g a -> Compose f g b -> Compose f g a #

(Foldable f, Foldable g) => Foldable (Compose f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fold :: Monoid m => Compose f g m -> m #

foldMap :: Monoid m => (a -> m) -> Compose f g a -> m #

foldr :: (a -> b -> b) -> b -> Compose f g a -> b #

foldr' :: (a -> b -> b) -> b -> Compose f g a -> b #

foldl :: (b -> a -> b) -> b -> Compose f g a -> b #

foldl' :: (b -> a -> b) -> b -> Compose f g a -> b #

foldr1 :: (a -> a -> a) -> Compose f g a -> a #

foldl1 :: (a -> a -> a) -> Compose f g a -> a #

toList :: Compose f g a -> [a] #

null :: Compose f g a -> Bool #

length :: Compose f g a -> Int #

elem :: Eq a => a -> Compose f g a -> Bool #

maximum :: Ord a => Compose f g a -> a #

minimum :: Ord a => Compose f g a -> a #

sum :: Num a => Compose f g a -> a #

product :: Num a => Compose f g a -> a #

(Traversable f, Traversable g) => Traversable (Compose f g) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Compose f g a -> f0 (Compose f g b) #

sequenceA :: Applicative f0 => Compose f g (f0 a) -> f0 (Compose f g a) #

mapM :: Monad m => (a -> m b) -> Compose f g a -> m (Compose f g b) #

sequence :: Monad m => Compose f g (m a) -> m (Compose f g a) #

Show (f (g a)) => Show (Compose f g a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

showsPrec :: Int -> Compose f g a -> ShowS #

show :: Compose f g a -> String #

showList :: [Compose f g a] -> ShowS #

Generic (Compose f g x) Source # 
Instance details

Defined in Data.Vinyl.Functor

Associated Types

type Rep (Compose f g x) :: Type -> Type #

Methods

from :: Compose f g x -> Rep (Compose f g x) x0 #

to :: Rep (Compose f g x) x0 -> Compose f g x #

Semigroup (f (g a)) => Semigroup (Compose f g a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(<>) :: Compose f g a -> Compose f g a -> Compose f g a #

sconcat :: NonEmpty (Compose f g a) -> Compose f g a #

stimes :: Integral b => b -> Compose f g a -> Compose f g a #

Monoid (f (g a)) => Monoid (Compose f g a) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

mempty :: Compose f g a #

mappend :: Compose f g a -> Compose f g a -> Compose f g a #

mconcat :: [Compose f g a] -> Compose f g a #

Storable (f (g x)) => Storable (Compose f g x) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

sizeOf :: Compose f g x -> Int #

alignment :: Compose f g x -> Int #

peekElemOff :: Ptr (Compose f g x) -> Int -> IO (Compose f g x) #

pokeElemOff :: Ptr (Compose f g x) -> Int -> Compose f g x -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Compose f g x) #

pokeByteOff :: Ptr b -> Int -> Compose f g x -> IO () #

peek :: Ptr (Compose f g x) -> IO (Compose f g x) #

poke :: Ptr (Compose f g x) -> Compose f g x -> IO () #

type HKD (Compose f g :: k -> Type) (a :: k) Source # 
Instance details

Defined in Data.Vinyl.XRec

type HKD (Compose f g :: k -> Type) (a :: k) = HKD f (HKD g a)
type Rep (Compose f g x) Source # 
Instance details

Defined in Data.Vinyl.Functor

type Rep (Compose f g x) = D1 (MetaData "Compose" "Data.Vinyl.Functor" "vinyl-0.13.0-85P9x7eT4R9ILQKoq4J8ea" True) (C1 (MetaCons "Compose" PrefixI True) (S1 (MetaSel (Just "getCompose") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f (g x)))))

onCompose :: (f (g a) -> h (k a)) -> (f :. g) a -> (h :. k) a Source #

Apply a function to a value whose type is the application of the Compose type constructor. This works under the Compose newtype wrapper.

type (:.) f g = Compose f g infixr 9 Source #

newtype Const (a :: *) (b :: k) Source #

Constructors

Const 

Fields

Instances
Functor (Const a :: Type -> Type) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fmap :: (a0 -> b) -> Const a a0 -> Const a b #

(<$) :: a0 -> Const a b -> Const a a0 #

Foldable (Const a :: Type -> Type) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

fold :: Monoid m => Const a m -> m #

foldMap :: Monoid m => (a0 -> m) -> Const a a0 -> m #

foldr :: (a0 -> b -> b) -> b -> Const a a0 -> b #

foldr' :: (a0 -> b -> b) -> b -> Const a a0 -> b #

foldl :: (b -> a0 -> b) -> b -> Const a a0 -> b #

foldl' :: (b -> a0 -> b) -> b -> Const a a0 -> b #

foldr1 :: (a0 -> a0 -> a0) -> Const a a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> Const a a0 -> a0 #

toList :: Const a a0 -> [a0] #

null :: Const a a0 -> Bool #

length :: Const a a0 -> Int #

elem :: Eq a0 => a0 -> Const a a0 -> Bool #

maximum :: Ord a0 => Const a a0 -> a0 #

minimum :: Ord a0 => Const a a0 -> a0 #

sum :: Num a0 => Const a a0 -> a0 #

product :: Num a0 => Const a a0 -> a0 #

Traversable (Const a :: Type -> Type) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

traverse :: Applicative f => (a0 -> f b) -> Const a a0 -> f (Const a b) #

sequenceA :: Applicative f => Const a (f a0) -> f (Const a a0) #

mapM :: Monad m => (a0 -> m b) -> Const a a0 -> m (Const a b) #

sequence :: Monad m => Const a (m a0) -> m (Const a a0) #

Eq a => Eq (Const a b) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

(==) :: Const a b -> Const a b -> Bool #

(/=) :: Const a b -> Const a b -> Bool #

Show a => Show (Const a b) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

showsPrec :: Int -> Const a b -> ShowS #

show :: Const a b -> String #

showList :: [Const a b] -> ShowS #

Generic (Const a b) Source # 
Instance details

Defined in Data.Vinyl.Functor

Associated Types

type Rep (Const a b) :: Type -> Type #

Methods

from :: Const a b -> Rep (Const a b) x #

to :: Rep (Const a b) x -> Const a b #

Storable a => Storable (Const a b) Source # 
Instance details

Defined in Data.Vinyl.Functor

Methods

sizeOf :: Const a b -> Int #

alignment :: Const a b -> Int #

peekElemOff :: Ptr (Const a b) -> Int -> IO (Const a b) #

pokeElemOff :: Ptr (Const a b) -> Int -> Const a b -> IO () #

peekByteOff :: Ptr b0 -> Int -> IO (Const a b) #

pokeByteOff :: Ptr b0 -> Int -> Const a b -> IO () #

peek :: Ptr (Const a b) -> IO (Const a b) #

poke :: Ptr (Const a b) -> Const a b -> IO () #

type Rep (Const a b) Source # 
Instance details

Defined in Data.Vinyl.Functor

type Rep (Const a b) = D1 (MetaData "Const" "Data.Vinyl.Functor" "vinyl-0.13.0-85P9x7eT4R9ILQKoq4J8ea" True) (C1 (MetaCons "Const" PrefixI True) (S1 (MetaSel (Just "getConst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

Discussion

Example

The data types in this module are used to build interpretation fuctions for a Rec. To build a Rec that is simply a heterogeneous list, use Identity:

>>> :{
let myRec1 :: Rec Identity '[Int,Bool,Char]
    myRec1 = Identity 4 :& Identity True :& Identity 'c' :& RNil
:}

For a record in which the fields are optional, you could alternatively write:

>>> :{
let myRec2 :: Rec Maybe '[Int,Bool,Char]
    myRec2 = Just 4 :& Nothing :& Nothing :& RNil
:}

And we can gather all of the effects with rtraverse:

>>> let r2 = rtraverse (fmap Identity) myRec2
>>> :t r2
r2 :: Maybe (Rec Identity '[Int, Bool, Char])
>>> r2
Nothing

If the fields only exist once an environment is provided, you can build the record as follows:

>>> :{
let myRec3 :: Rec ((->) Int) '[Int,Bool,Char]
    myRec3 = (+5) :& (const True) :& (head . show) :& RNil
:}

And again, we can collect these effects with "rtraverse":

>>> (rtraverse (fmap Identity) myRec3) 8
{13, True, '8'}

If you want the composition of these two effects, you can use Compose:

>>> import Data.Char (chr)
>>> :{
let safeDiv a b = if b == 0 then Nothing else Just (div a b)
    safeChr i = if i >= 32 && i <= 126 then Just (chr i) else Nothing
    myRec4 :: Rec (Compose ((->) Int) Maybe) '[Int,Char]
    myRec4 = (Compose $ safeDiv 42) :& (Compose safeChr) :& RNil
:}

Ecosystem

Of the five data types provided by this modules, three can be found in others places: Identity, Compose, and Const. They are included with "vinyl" to help keep the dependency list small. The differences will be discussed here.

The Data.Functor.Identity module was originally provided by "transformers". When GHC 7.10 was released, it was moved into "base-4.8". The Identity data type provided by that module is well recognized across the haskell ecosystem and has typeclass instances for lots of common typeclasses. The significant difference between it and the copy of it provided here is that this one has a different Show instance. This is illustrated below:

>>> Identity "hello"
"hello"

But, when using Identity from "base":

>>> import qualified Data.Functor.Identity as Base
>>> Base.Identity "hello"
Identity "hello"

This Show instance makes records look nicer in GHCi. Feel free to use Data.Functor.Identity if you do not need the prettier output or if you need the many additional typeclass instances that are provided for the standard Identity.

The story with Compose and Const is much more simple. These also exist in "transformers", although Const is named Constant there. Prior to the release of "transformers-0.5", they were not polykinded, making them unusable for certain universes. However, in "transformers-0.5" and forward, they have been made polykinded. This means that they are just as usable with Rec as the vinyl equivalents but with many more typeclass instances such as Ord and Show.