Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- data CoRec :: (u -> *) -> [u] -> * where
- type Field = CoRec Identity
- coRec :: r ∈ rs => f r -> CoRec f rs
- coRecPrism :: (RecApplicative rs, r ∈ rs) => 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) => 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 :: (RMap rs, 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, RMap rs) => Rec Maybe rs -> Maybe (Field rs)
- lastCoRec :: FoldRec rs rs => Rec (Maybe :. f) rs -> Maybe (CoRec f rs)
- lastField :: (RMap rs, 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, RMap rs, RecApplicative rs) => 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 :: (RMap rs, RecApplicative (r ': rs)) => Cases (r ': rs) b -> Field (r ': rs) -> b
- matchField :: (RMap rs, 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, RMap rs, RMap 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`

.

CoVal :: r ∈ rs => !(f r) -> CoRec f rs | Witness that |

coRecPrism :: (RecApplicative rs, r ∈ rs) => Prism' (CoRec f rs) (f r) Source #

Produce a prism for the given alternative of a `CoRec`

.

fieldPrism :: (RecApplicative rs, r ∈ rs) => Prism' (Field rs) r Source #

Produce a prism for the given alternative of a `Field`

.

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 :: (RMap rs, 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`

f`b`

.

matchCoRec :: RecApplicative (r ': rs) => CoRec f (r ': rs) -> Cases' f (r ': rs) b -> b Source #

foldField :: (RMap rs, RecApplicative (r ': rs)) => Cases (r ': rs) b -> Field (r ': rs) -> b Source #

matchField :: (RMap rs, 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, RMap rs, RMap ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => Field rs -> Field ss Source #