Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data CoRec :: (u -> *) -> [u] -> * where
- type Field = CoRec Identity
- coRec :: r ∈ rs => f r -> CoRec f rs
- coRecPrism :: (RecApplicative rs, r ∈ rs) => proxy r -> Prism' (CoRec f rs) (f r)
- field :: r ∈ rs => r -> Field rs
- fieldVal :: forall s a rs proxy. (s :-> a) ∈ rs => proxy (s :-> a) -> a -> Field rs
- fieldPrism :: (RecApplicative rs, r ∈ rs) => proxy r -> Prism' (Field rs) r
- fieldValPrism :: (RecApplicative rs, (s :-> a) ∈ rs) => proxy (s :-> a) -> Prism' (Field rs) a
- foldCoVal :: (forall (r :: u). RElem r rs (RIndex r rs) => f r -> b) -> CoRec f rs -> b
- mapCoRec :: (forall x. f x -> g x) -> CoRec f rs -> CoRec g rs
- traverseCoRec :: Functor h => (forall x. f x -> h (g x)) -> CoRec f rs -> h (CoRec g rs)
- coRecToRec :: RecApplicative rs => CoRec f rs -> Rec (Maybe :. f) rs
- fieldToRec :: RecApplicative rs => Field rs -> Rec Maybe rs
- class FoldRec ss ts where
- foldRec1 :: FoldRec (r ': rs) rs => (CoRec f (r ': rs) -> CoRec f (r ': rs) -> CoRec f (r ': rs)) -> Rec f (r ': rs) -> CoRec f (r ': rs)
- firstCoRec :: FoldRec rs rs => Rec (Maybe :. f) rs -> Maybe (CoRec f rs)
- firstField :: FoldRec rs rs => Rec Maybe rs -> Maybe (Field rs)
- lastCoRec :: FoldRec rs rs => Rec (Maybe :. f) rs -> Maybe (CoRec f rs)
- lastField :: FoldRec rs rs => Rec Maybe rs -> Maybe (Field rs)
- newtype Op b a = Op {
- runOp :: a -> b
- onCoRec :: forall (cs :: [* -> Constraint]) (f :: * -> *) (rs :: [*]) (b :: *) (proxy :: [* -> Constraint] -> *). (AllHave cs rs, Functor f, RecApplicative rs) => proxy cs -> (forall (a :: *). HasInstances a cs => a -> b) -> CoRec f rs -> f b
- onField :: forall (cs :: [* -> Constraint]) (rs :: [*]) (b :: *) (proxy :: [* -> Constraint] -> *). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall (a :: *). HasInstances a cs => a -> b) -> Field rs -> b
- asA :: (r ∈ rs, RecApplicative rs) => proxy r -> Field rs -> Maybe r
- newtype Case' f b a = Case' {
- unCase' :: f a -> b
- type Cases' f rs b = Rec (Case' f b) rs
- foldCoRec :: RecApplicative (r ': rs) => Cases' f (r ': rs) b -> CoRec f (r ': rs) -> b
- matchCoRec :: RecApplicative (r ': rs) => CoRec f (r ': rs) -> Cases' f (r ': rs) b -> b
- newtype Case b a = Case {
- unCase :: a -> b
- type Cases rs b = Rec (Case b) rs
- foldField :: RecApplicative (r ': rs) => Cases (r ': rs) b -> Field (r ': rs) -> b
- matchField :: RecApplicative (r ': rs) => Field (r ': rs) -> Cases (r ': rs) b -> b
- widenCoRec :: (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => CoRec f rs -> CoRec f ss
- widenField :: (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => Field rs -> Field ss
Documentation
data CoRec :: (u -> *) -> [u] -> * where Source #
CoRef f rs
represents a single value of type f r
for some r
in rs
.
coRecPrism :: (RecApplicative rs, r ∈ rs) => proxy r -> Prism' (CoRec f rs) (f r) Source #
Produce a prism for the given alternative of a CoRec
, given a proxy to identify which r
you meant.
fieldPrism :: (RecApplicative rs, r ∈ rs) => proxy r -> Prism' (Field rs) r Source #
Produce a prism for the given alternative of a Field
, given a proxy to identify which r
you meant.
fieldValPrism :: (RecApplicative rs, (s :-> a) ∈ rs) => proxy (s :-> a) -> Prism' (Field rs) a Source #
Produce a prism for the given :->
alternative of a Field
, given a proxy to identify which s :-> a
you meant.
foldCoVal :: (forall (r :: u). RElem r rs (RIndex r rs) => f r -> b) -> CoRec f rs -> b Source #
Apply an extraction to whatever f r
is contained in the given CoRec
.
For example foldCoVal getConst :: CoRec (Const a) rs -> a
.
coRecToRec :: RecApplicative rs => CoRec f rs -> Rec (Maybe :. f) rs Source #
fieldToRec :: RecApplicative rs => Field rs -> Rec Maybe rs Source #
class FoldRec ss ts where Source #
foldRec :: (CoRec f ss -> CoRec f ss -> CoRec f ss) -> CoRec f ss -> Rec f ts -> CoRec f ss Source #
Given some combining function, an initial value, and a record, visit each field of the record using the combining function to accumulate the initial value or previous accumulation with the field of the record.
foldRec1 :: FoldRec (r ': rs) rs => (CoRec f (r ': rs) -> CoRec f (r ': rs) -> CoRec f (r ': rs)) -> Rec f (r ': rs) -> CoRec f (r ': rs) Source #
foldRec
for records with at least one field that doesn't require an initial value.
Helper newtype containing a function a -> b
but with the type parameters flipped so Op b
has a consistent codomain for a varying domain.
onCoRec :: forall (cs :: [* -> Constraint]) (f :: * -> *) (rs :: [*]) (b :: *) (proxy :: [* -> Constraint] -> *). (AllHave cs rs, Functor f, RecApplicative rs) => proxy cs -> (forall (a :: *). HasInstances a cs => a -> b) -> CoRec f rs -> f b Source #
Given a list of constraints cs
required to apply some function, apply the function to whatever value r
(not f r
) which the CoRec
contains.
onField :: forall (cs :: [* -> Constraint]) (rs :: [*]) (b :: *) (proxy :: [* -> Constraint] -> *). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall (a :: *). HasInstances a cs => a -> b) -> Field rs -> b Source #
Given a list of constraints cs
required to apply some function, apply the function to whatever value r
which the Field
contains.
type Cases' f rs b = Rec (Case' f b) rs Source #
A record of Case'
eliminators for each r
in rs
representing the pieces of a total function from
to CoRec
fb
.
matchCoRec :: RecApplicative (r ': rs) => CoRec f (r ': rs) -> Cases' f (r ': rs) b -> b Source #
matchField :: RecApplicative (r ': rs) => Field (r ': rs) -> Cases (r ': rs) b -> b Source #
widenCoRec :: (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => CoRec f rs -> CoRec f ss Source #
widenField :: (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => Field rs -> Field ss Source #