composite-base-0.8.1.0: Shared utilities for composite-* packages.
Safe HaskellNone
LanguageHaskell2010

Composite.Record

Synopsis

Documentation

data Rec (a :: u -> Type) (b :: [u]) where #

A record is parameterized by a universe u, an interpretation f and a list of rows rs. The labels or indices of the record are given by inhabitants of the kind u; the type of values at any label r :: u is given by its interpretation f r :: *.

Constructors

RNil :: forall u (a :: u -> Type). Rec a ('[] :: [u]) 
(:&) :: forall u (a :: u -> Type) (r :: u) (rs :: [u]). !(a r) -> !(Rec a rs) -> Rec a (r ': rs) infixr 7 

Instances

Instances details
RecSubset (Rec :: (k -> Type) -> [k] -> Type) ('[] :: [k]) (ss :: [k]) ('[] :: [Nat]) 
Instance details

Defined in Data.Vinyl.Lens

Associated Types

type RecSubsetFCtx Rec f #

Methods

rsubsetC :: forall g (f :: k0 -> Type). (Functor g, RecSubsetFCtx Rec f) => (Rec f '[] -> g (Rec f '[])) -> Rec f ss -> g (Rec f ss) #

rcastC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f ss -> Rec f '[] #

rreplaceC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f '[] -> Rec f ss -> Rec f ss #

(RElem r ss i, RSubset rs ss is) => RecSubset (Rec :: (k -> Type) -> [k] -> Type) (r ': rs :: [k]) (ss :: [k]) (i ': is) 
Instance details

Defined in Data.Vinyl.Lens

Associated Types

type RecSubsetFCtx Rec f #

Methods

rsubsetC :: forall g (f :: k0 -> Type). (Functor g, RecSubsetFCtx Rec f) => (Rec f (r ': rs) -> g (Rec f (r ': rs))) -> Rec f ss -> g (Rec f ss) #

rcastC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f ss -> Rec f (r ': rs) #

rreplaceC :: forall (f :: k0 -> Type). RecSubsetFCtx Rec f => Rec f (r ': rs) -> Rec f ss -> Rec f ss #

RecElem (Rec :: (a -> Type) -> [a] -> Type) (r :: a) (r' :: a) (r ': rs :: [a]) (r' ': rs :: [a]) 'Z 
Instance details

Defined in Data.Vinyl.Lens

Associated Types

type RecElemFCtx Rec f #

Methods

rlensC :: (Functor g, RecElemFCtx Rec f) => (f r -> g (f r')) -> Rec f (r ': rs) -> g (Rec f (r' ': rs)) #

rgetC :: (RecElemFCtx Rec f, r ~ r') => Rec f (r ': rs) -> f r #

rputC :: RecElemFCtx Rec f => f r' -> Rec f (r ': rs) -> Rec f (r' ': rs) #

(RIndex r (s ': rs) ~ 'S i, RecElem (Rec :: (a -> Type) -> [a] -> Type) r r' rs rs' i) => RecElem (Rec :: (a -> Type) -> [a] -> Type) (r :: a) (r' :: a) (s ': rs :: [a]) (s ': rs' :: [a]) ('S i) 
Instance details

Defined in Data.Vinyl.Lens

Associated Types

type RecElemFCtx Rec f #

Methods

rlensC :: (Functor g, RecElemFCtx Rec f) => (f r -> g (f r')) -> Rec f (s ': rs) -> g (Rec f (s ': rs')) #

rgetC :: (RecElemFCtx Rec f, r ~ r') => Rec f (s ': rs) -> f r #

rputC :: RecElemFCtx Rec f => f r' -> Rec f (s ': rs) -> Rec f (s ': rs') #

MonadContext c ((->) (Record c) :: Type -> Type) Source # 
Instance details

Defined in Control.Monad.Composite.Context

Methods

askContext :: Record c -> Record c Source #

localContext :: (Record c -> Record c) -> (Record c -> a) -> Record c -> a Source #

(NFData x, NFData (Record xs)) => NFData (Record (x ': xs)) Source # 
Instance details

Defined in Composite.Record

Methods

rnf :: Record (x ': xs) -> () #

NFData (Record ('[] :: [Type])) Source # 
Instance details

Defined in Composite.Record

Methods

rnf :: Record '[] -> () #

TestCoercion f => TestCoercion (Rec f :: [u] -> Type) 
Instance details

Defined in Data.Vinyl.Core

Methods

testCoercion :: forall (a :: k) (b :: k). Rec f a -> Rec f b -> Maybe (Coercion a b) #

TestEquality f => TestEquality (Rec f :: [u] -> Type) 
Instance details

Defined in Data.Vinyl.Core

Methods

testEquality :: forall (a :: k) (b :: k). Rec f a -> Rec f b -> Maybe (a :~: b) #

Eq (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Methods

(==) :: Rec f '[] -> Rec f '[] -> Bool #

(/=) :: Rec f '[] -> Rec f '[] -> Bool #

(Eq (f r), Eq (Rec f rs)) => Eq (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Methods

(==) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

(/=) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

Ord (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Methods

compare :: Rec f '[] -> Rec f '[] -> Ordering #

(<) :: Rec f '[] -> Rec f '[] -> Bool #

(<=) :: Rec f '[] -> Rec f '[] -> Bool #

(>) :: Rec f '[] -> Rec f '[] -> Bool #

(>=) :: Rec f '[] -> Rec f '[] -> Bool #

max :: Rec f '[] -> Rec f '[] -> Rec f '[] #

min :: Rec f '[] -> Rec f '[] -> Rec f '[] #

(Ord (f r), Ord (Rec f rs)) => Ord (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Methods

compare :: Rec f (r ': rs) -> Rec f (r ': rs) -> Ordering #

(<) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

(<=) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

(>) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

(>=) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Bool #

max :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) #

min :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) #

(RMap rs, ReifyConstraint Show f rs, RecordToList rs) => Show (Rec f rs)

Records may be shown insofar as their points may be shown. reifyConstraint is used to great effect here.

Instance details

Defined in Data.Vinyl.Core

Methods

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

show :: Rec f rs -> String #

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

Generic (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Associated Types

type Rep (Rec f '[]) :: Type -> Type #

Methods

from :: Rec f '[] -> Rep (Rec f '[]) x #

to :: Rep (Rec f '[]) x -> Rec f '[] #

Generic (Rec f rs) => Generic (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Associated Types

type Rep (Rec f (r ': rs)) :: Type -> Type #

Methods

from :: Rec f (r ': rs) -> Rep (Rec f (r ': rs)) x #

to :: Rep (Rec f (r ': rs)) x -> Rec f (r ': rs) #

Semigroup (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Methods

(<>) :: Rec f '[] -> Rec f '[] -> Rec f '[] #

sconcat :: NonEmpty (Rec f '[]) -> Rec f '[] #

stimes :: Integral b => b -> Rec f '[] -> Rec f '[] #

(Semigroup (f r), Semigroup (Rec f rs)) => Semigroup (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Methods

(<>) :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) #

sconcat :: NonEmpty (Rec f (r ': rs)) -> Rec f (r ': rs) #

stimes :: Integral b => b -> Rec f (r ': rs) -> Rec f (r ': rs) #

Monoid (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Methods

mempty :: Rec f '[] #

mappend :: Rec f '[] -> Rec f '[] -> Rec f '[] #

mconcat :: [Rec f '[]] -> Rec f '[] #

(Monoid (f r), Monoid (Rec f rs)) => Monoid (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Methods

mempty :: Rec f (r ': rs) #

mappend :: Rec f (r ': rs) -> Rec f (r ': rs) -> Rec f (r ': rs) #

mconcat :: [Rec f (r ': rs)] -> Rec f (r ': rs) #

Storable (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

Methods

sizeOf :: Rec f '[] -> Int #

alignment :: Rec f '[] -> Int #

peekElemOff :: Ptr (Rec f '[]) -> Int -> IO (Rec f '[]) #

pokeElemOff :: Ptr (Rec f '[]) -> Int -> Rec f '[] -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Rec f '[]) #

pokeByteOff :: Ptr b -> Int -> Rec f '[] -> IO () #

peek :: Ptr (Rec f '[]) -> IO (Rec f '[]) #

poke :: Ptr (Rec f '[]) -> Rec f '[] -> IO () #

(Storable (f r), Storable (Rec f rs)) => Storable (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

Methods

sizeOf :: Rec f (r ': rs) -> Int #

alignment :: Rec f (r ': rs) -> Int #

peekElemOff :: Ptr (Rec f (r ': rs)) -> Int -> IO (Rec f (r ': rs)) #

pokeElemOff :: Ptr (Rec f (r ': rs)) -> Int -> Rec f (r ': rs) -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Rec f (r ': rs)) #

pokeByteOff :: Ptr b -> Int -> Rec f (r ': rs) -> IO () #

peek :: Ptr (Rec f (r ': rs)) -> IO (Rec f (r ': rs)) #

poke :: Ptr (Rec f (r ': rs)) -> Rec f (r ': rs) -> IO () #

ReifyConstraint NFData f xs => NFData (Rec f xs) 
Instance details

Defined in Data.Vinyl.Core

Methods

rnf :: Rec f xs -> () #

type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) 
Instance details

Defined in Data.Vinyl.Lens

type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) = ()
type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) 
Instance details

Defined in Data.Vinyl.Lens

type RecSubsetFCtx (Rec :: (k -> Type) -> [k] -> Type) (f :: k -> Type) = ()
type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) 
Instance details

Defined in Data.Vinyl.Lens

type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) = ()
type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) 
Instance details

Defined in Data.Vinyl.Lens

type RecElemFCtx (Rec :: (a -> Type) -> [a] -> Type) (f :: a -> Type) = ()
type Rep (Rec f (r ': rs)) 
Instance details

Defined in Data.Vinyl.Core

type Rep (Rec f ('[] :: [u])) 
Instance details

Defined in Data.Vinyl.Core

type Record = Rec Identity Source #

The type of regular plain records where each field has a value, equal to Rec Identity.

pattern (:*:) :: a -> Rec Identity rs -> Rec Identity ((s :-> a) ': rs) infixr 5 Source #

Bidirectional pattern matching the first field of a record using :-> values and the Identity functor.

This pattern is bidirectional meaning you can use it either as a pattern or a constructor, e.g.

  let rec = 123 :*: Just "foo" :*: RNil
      foo :*: bar :*: RNil = rec

Mnemonic: * for products.

pattern (:^:) :: Functor f => f a -> Rec f rs -> Rec f ((s :-> a) ': rs) infixr 5 Source #

Bidirectional pattern matching the first field of a record using :-> values and any functor.

This pattern is bidirectional meaning you can use it either as a pattern or a constructor, e.g.

  let rec = Just 123 :^: Just "foo" :^: RNil
      Just foo :^: Just bar :^: RNil = rec

Mnemonic: ^ for products (record) of products (functor).

pattern (:!:) :: Contravariant f => f a -> Rec f rs -> Rec f ((s :-> a) ': rs) infixr 5 Source #

newtype (s :: Symbol) :-> a Source #

Some value of type a tagged with a symbol indicating its field name or label. Used as the usual type of elements in a Rec or Record.

Recommended pronunciation: record val.

Constructors

Val 

Fields

Instances

Instances details
Monad ((:->) s) Source # 
Instance details

Defined in Composite.Record

Methods

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

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

return :: a -> s :-> a #

Functor ((:->) s) Source # 
Instance details

Defined in Composite.Record

Methods

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

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

Applicative ((:->) s) Source # 
Instance details

Defined in Composite.Record

Methods

pure :: a -> s :-> a #

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

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

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

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

Foldable ((:->) s) Source # 
Instance details

Defined in Composite.Record

Methods

fold :: Monoid m => (s :-> m) -> m #

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

foldMap' :: Monoid m => (a -> m) -> (s :-> a) -> m #

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

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

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

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

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

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

toList :: (s :-> a) -> [a] #

null :: (s :-> a) -> Bool #

length :: (s :-> a) -> Int #

elem :: Eq a => a -> (s :-> a) -> Bool #

maximum :: Ord a => (s :-> a) -> a #

minimum :: Ord a => (s :-> a) -> a #

sum :: Num a => (s :-> a) -> a #

product :: Num a => (s :-> a) -> a #

Traversable ((:->) s) Source # 
Instance details

Defined in Composite.Record

Methods

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

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

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

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

KnownSymbol s => IsoHKD Identity (s :-> a :: Type) Source # 
Instance details

Defined in Composite.Record

Associated Types

type HKD Identity (s :-> a) #

Methods

unHKD :: HKD Identity (s :-> a) -> Identity (s :-> a) #

toHKD :: Identity (s :-> a) -> HKD Identity (s :-> a) #

Bounded a => Bounded (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

minBound :: s :-> a #

maxBound :: s :-> a #

Enum a => Enum (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

succ :: (s :-> a) -> s :-> a #

pred :: (s :-> a) -> s :-> a #

toEnum :: Int -> s :-> a #

fromEnum :: (s :-> a) -> Int #

enumFrom :: (s :-> a) -> [s :-> a] #

enumFromThen :: (s :-> a) -> (s :-> a) -> [s :-> a] #

enumFromTo :: (s :-> a) -> (s :-> a) -> [s :-> a] #

enumFromThenTo :: (s :-> a) -> (s :-> a) -> (s :-> a) -> [s :-> a] #

Eq a => Eq (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

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

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

Floating a => Floating (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

pi :: s :-> a #

exp :: (s :-> a) -> s :-> a #

log :: (s :-> a) -> s :-> a #

sqrt :: (s :-> a) -> s :-> a #

(**) :: (s :-> a) -> (s :-> a) -> s :-> a #

logBase :: (s :-> a) -> (s :-> a) -> s :-> a #

sin :: (s :-> a) -> s :-> a #

cos :: (s :-> a) -> s :-> a #

tan :: (s :-> a) -> s :-> a #

asin :: (s :-> a) -> s :-> a #

acos :: (s :-> a) -> s :-> a #

atan :: (s :-> a) -> s :-> a #

sinh :: (s :-> a) -> s :-> a #

cosh :: (s :-> a) -> s :-> a #

tanh :: (s :-> a) -> s :-> a #

asinh :: (s :-> a) -> s :-> a #

acosh :: (s :-> a) -> s :-> a #

atanh :: (s :-> a) -> s :-> a #

log1p :: (s :-> a) -> s :-> a #

expm1 :: (s :-> a) -> s :-> a #

log1pexp :: (s :-> a) -> s :-> a #

log1mexp :: (s :-> a) -> s :-> a #

Fractional a => Fractional (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

(/) :: (s :-> a) -> (s :-> a) -> s :-> a #

recip :: (s :-> a) -> s :-> a #

fromRational :: Rational -> s :-> a #

Integral a => Integral (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

quot :: (s :-> a) -> (s :-> a) -> s :-> a #

rem :: (s :-> a) -> (s :-> a) -> s :-> a #

div :: (s :-> a) -> (s :-> a) -> s :-> a #

mod :: (s :-> a) -> (s :-> a) -> s :-> a #

quotRem :: (s :-> a) -> (s :-> a) -> (s :-> a, s :-> a) #

divMod :: (s :-> a) -> (s :-> a) -> (s :-> a, s :-> a) #

toInteger :: (s :-> a) -> Integer #

Num a => Num (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

(+) :: (s :-> a) -> (s :-> a) -> s :-> a #

(-) :: (s :-> a) -> (s :-> a) -> s :-> a #

(*) :: (s :-> a) -> (s :-> a) -> s :-> a #

negate :: (s :-> a) -> s :-> a #

abs :: (s :-> a) -> s :-> a #

signum :: (s :-> a) -> s :-> a #

fromInteger :: Integer -> s :-> a #

Ord a => Ord (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

compare :: (s :-> a) -> (s :-> a) -> Ordering #

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

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

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

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

max :: (s :-> a) -> (s :-> a) -> s :-> a #

min :: (s :-> a) -> (s :-> a) -> s :-> a #

Real a => Real (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

toRational :: (s :-> a) -> Rational #

RealFloat a => RealFloat (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

floatRadix :: (s :-> a) -> Integer #

floatDigits :: (s :-> a) -> Int #

floatRange :: (s :-> a) -> (Int, Int) #

decodeFloat :: (s :-> a) -> (Integer, Int) #

encodeFloat :: Integer -> Int -> s :-> a #

exponent :: (s :-> a) -> Int #

significand :: (s :-> a) -> s :-> a #

scaleFloat :: Int -> (s :-> a) -> s :-> a #

isNaN :: (s :-> a) -> Bool #

isInfinite :: (s :-> a) -> Bool #

isDenormalized :: (s :-> a) -> Bool #

isNegativeZero :: (s :-> a) -> Bool #

isIEEE :: (s :-> a) -> Bool #

atan2 :: (s :-> a) -> (s :-> a) -> s :-> a #

RealFrac a => RealFrac (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

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

truncate :: Integral b => (s :-> a) -> b #

round :: Integral b => (s :-> a) -> b #

ceiling :: Integral b => (s :-> a) -> b #

floor :: Integral b => (s :-> a) -> b #

(KnownSymbol s, Show a) => Show (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

showsPrec :: Int -> (s :-> a) -> ShowS #

show :: (s :-> a) -> String #

showList :: [s :-> a] -> ShowS #

IsString a => IsString (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

fromString :: String -> s :-> a #

Semigroup a => Semigroup (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

(<>) :: (s :-> a) -> (s :-> a) -> s :-> a #

sconcat :: NonEmpty (s :-> a) -> s :-> a #

stimes :: Integral b => b -> (s :-> a) -> s :-> a #

Monoid a => Monoid (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

mempty :: s :-> a #

mappend :: (s :-> a) -> (s :-> a) -> s :-> a #

mconcat :: [s :-> a] -> s :-> a #

Storable a => Storable (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

sizeOf :: (s :-> a) -> Int #

alignment :: (s :-> a) -> Int #

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

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

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

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

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

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

NFData a => NFData (s :-> a) Source # 
Instance details

Defined in Composite.Record

Methods

rnf :: (s :-> a) -> () #

Wrapped (s :-> a) Source # 
Instance details

Defined in Composite.Record

Associated Types

type Unwrapped (s :-> a) #

Methods

_Wrapped' :: Iso' (s :-> a) (Unwrapped (s :-> a)) #

(s1 :-> a1) ~ t => Rewrapped (s2 :-> a2) t Source # 
Instance details

Defined in Composite.Record

(KnownSymbol s, ReifyNames rs) => ReifyNames ((s :-> a) ': rs) Source # 
Instance details

Defined in Composite.Record

Methods

reifyNames :: forall (f :: Type -> Type). Rec f ((s :-> a) ': rs) -> Rec ((,) Text :. f) ((s :-> a) ': rs) Source #

type HKD Identity (s :-> a :: Type) Source # 
Instance details

Defined in Composite.Record

type HKD Identity (s :-> a :: Type) = a
type Unwrapped (s :-> a) Source # 
Instance details

Defined in Composite.Record

type Unwrapped (s :-> a) = a

_Val :: Iso (s :-> a) (s :-> b) a b Source #

val :: forall (s :: Symbol) a. a -> Identity (s :-> a) Source #

Convenience function to make an Identity (s :-> a) with a particular symbol, used for named field construction.

For example:

  type FFoo = "foo" :-> Int
  type FBar = "bar" :-> String
  type FBaz = "baz" :-> Double
  type MyRecord = [FFoo, FBar, FBaz]

  myRecord1 :: Record MyRecord
  myRecord1
    =  val @"foo" 123
    :& val @"bar" "foobar"
    :& val @"baz" 3.21
    :& RNil

  myRecord2 :: Record MyRecord
  myRecord2 = rcast
    $  val @"baz" 3.21
    :& val @"foo" 123
    :& val @"bar" "foobar"
    :& RNil

In this example, both myRecord1 and myRecord2 have the same value, since rcast can reorder records.

valName :: forall s a. KnownSymbol s => (s :-> a) -> Text Source #

Reflect the type level name of a named value s :-> a to a Text. For example, given "foo" :-> Int, yields "foo" :: Text

valWithName :: forall s a. KnownSymbol s => (s :-> a) -> (Text, a) Source #

Extract the value and reflect the name of a named value.

type RElem r rs = RElem r rs (RIndex r rs) Source #

Constraint expressing that r is in rs and providing the index of r in rs. Equal to RElem rs (RIndex r rs).

rlens :: (Functor g, RElem (s :-> a) rs, Functor g) => proxy (s :-> a) -> (a -> g a) -> Rec Identity rs -> g (Rec Identity rs) Source #

Lens to a particular field of a record using the Identity functor.

For example, given:

  type FFoo = "foo" :-> Int
  type FBar = "bar" :-> String
  fBar_ :: Proxy FBar
  fBar_ = Proxy

  rec :: Rec Identity '[FFoo, FBar]
  rec = 123 :*: "hello!" :*: Nil

Then:

  view (rlens fBar_)               rec == "hello!"
  set  (rlens fBar_) "goodbye!"    rec == 123 :*: "goodbye!" :*: Nil
  over (rlens fBar_) (map toUpper) rec == 123 :*: "HELLO!"   :*: Nil

rlens' :: (Functor f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) Source #

Synonym for rlensCo

rlensCo :: (Functor f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) Source #

Lens to a particular field of a record using any functor.

For example, given:

  type FFoo = "foo" :-> Int
  type FBar = "bar" :-> String
  fBar_ :: Proxy FBar
  fBar_ = Proxy

  rec :: Rec Maybe '[FFoo, FBar]
  rec = Just 123 :^: Just "hello!" :^: Nil

Then:

  view (rlensCo fBar_)                      rec == Just "hello!"
  set  (rlensCo fBar_) Nothing              rec == Just 123 :^: Nothing       :^: Nil
  over (rlensCo fBar_) (fmap (map toUpper)) rec == Just 123 :^: Just "HELLO!" :^: Nil

rlensContra :: (Contravariant f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) Source #

Lens to a particular field of a record using a contravariant functor.

For example, given:

  type FFoo = "foo" :-> Int
  type FBar = "bar" :-> String
  fBar_ :: Proxy FBar
  fBar_ = Proxy

  rec :: Rec Predicate '[FFoo, FBar]
  rec = Predicate even :!: Predicate (even . length) :!: Nil

Then:

  view (rlensContra fBar_)                           rec == Predicate even
  set  (rlensContra fBar_) Predicate (odd . length)  rec == Predicate even :!: Predicate (odd . length) :!: Nil
  over (rlensContra fBar_) (contramap show)          rec == Predicate even :!: Predicate (odd . length . show) :!: Nil

type family AllHave (cs :: [u -> Constraint]) (as :: [u]) :: Constraint where ... Source #

Type function which produces the cross product of constraints cs and types as.

For example, AllHave '[Eq, Ord] '[Int, Text] is equivalent to (Eq Int, Ord Int, Eq Text, Ord Text)

Equations

AllHave cs '[] = () 
AllHave cs (a ': as) = (HasInstances a cs, AllHave cs as) 

type family HasInstances (a :: u) (cs :: [u -> Constraint]) :: Constraint where ... Source #

Type function which produces a constraint on a for each constraint in cs.

For example, HasInstances Int '[Eq, Ord] is equivalent to (Eq Int, Ord Int).

Equations

HasInstances a '[] = () 
HasInstances a (c ': cs) = (c a, HasInstances a cs) 

type family ValuesAllHave (cs :: [u -> Constraint]) (as :: [u]) :: Constraint where ... Source #

Type function which produces the cross product of constraints cs and the values carried in a record rs.

For example, ValuesAllHave '[Eq, Ord] '["foo" :-> Int, "bar" :-> Text] is equivalent to (Eq Int, Ord Int, Eq Text, Ord Text)

Equations

ValuesAllHave cs '[] = () 
ValuesAllHave cs ((s :-> a) ': as) = (HasInstances a cs, ValuesAllHave cs as) 

zipRecsWith :: (forall a. f a -> g a -> h a) -> Rec f as -> Rec g as -> Rec h as Source #

zipWith for Rec's.

reifyDicts :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> Type) (rs :: [u]) (proxy :: [u -> Constraint] -> Type). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a) -> Rec f rs Source #

Given a list of constraints cs, apply some function for each r in the target record type rs with proof that those constraints hold for r, generating a record with the result of each application.

reifyVal :: proxy (s :-> a) -> (s :-> a) -> s :-> a Source #

Reify the type of a val.

recordToNonEmpty :: RecordToList rs => Rec (Const a) (r ': rs) -> NonEmpty a Source #

Convert a provably nonempty Rec (Const a) rs to a NonEmpty a.

class ReifyNames (rs :: [Type]) where Source #

Class which reifies the symbols of a record composed of :-> fields as Text.

Methods

reifyNames :: Rec f rs -> Rec ((,) Text :. f) rs Source #

Given a Rec f rs where each r in rs is of the form s :-> a, make a record which adds the Text for each s.

Instances

Instances details
ReifyNames ('[] :: [Type]) Source # 
Instance details

Defined in Composite.Record

Methods

reifyNames :: forall (f :: Type -> Type). Rec f '[] -> Rec ((,) Text :. f) '[] Source #

(KnownSymbol s, ReifyNames rs) => ReifyNames ((s :-> a) ': rs) Source # 
Instance details

Defined in Composite.Record

Methods

reifyNames :: forall (f :: Type -> Type). Rec f ((s :-> a) ': rs) -> Rec ((,) Text :. f) ((s :-> a) ': rs) Source #

class RecWithContext (ss :: [Type]) (ts :: [Type]) where Source #

Class with rmap but which gives the natural transformation evidence that the value its working over is contained within the overall record ss.

Methods

rmapWithContext :: proxy ss -> (forall r. r ss => f r -> g r) -> Rec f ts -> Rec g ts Source #

Apply a natural transformation from f to g to each field of the given record, except that the natural transformation can be mildly unnatural by having evidence that r is in ss.

Instances

Instances details
RecWithContext ss ('[] :: [Type]) Source # 
Instance details

Defined in Composite.Record

Methods

rmapWithContext :: proxy ss -> (forall r. r ss => f r -> g r) -> Rec f '[] -> Rec g '[] Source #

(r ss, RecWithContext ss ts) => RecWithContext ss (r ': ts) Source # 
Instance details

Defined in Composite.Record

Methods

rmapWithContext :: proxy ss -> (forall r0. r0 ss => f r0 -> g r0) -> Rec f (r ': ts) -> Rec g (r ': ts) Source #

type family RDelete (r :: u) (rs :: [u]) where ... Source #

Type function which removes the first element r from a list rs, and doesn't expand if r is not present in rs.

Equations

RDelete r (r ': rs) = rs 
RDelete r (s ': rs) = s ': RDelete r rs 

type RDeletable r rs = (r rs, RDelete r rs rs) Source #

Constraint which reflects that an element r can be removed from rs using rdelete.

rdelete :: RDeletable r rs => proxy r -> Rec f rs -> Rec f (RDelete r rs) Source #

Remove an element r from a Rec f rs. Note this is just a type constrained rcast.

Orphan instances

(NFData x, NFData (Record xs)) => NFData (Record (x ': xs)) Source # 
Instance details

Methods

rnf :: Record (x ': xs) -> () #

NFData (Record ('[] :: [Type])) Source # 
Instance details

Methods

rnf :: Record '[] -> () #