ten-lens-0.1.0.1: Lenses for the types in the ten package.
Safe HaskellNone
LanguageHaskell2010

Data.Ten.Lens

Description

Provides lenses and related functionality for the "ten" package.

Synopsis

Documentation

rep10 :: Representable10 f => Getting (Rep10 f a) (f (Rep10 f)) (Rep10 f a) -> Rep10 f a Source #

Turn a record field lens into a Rep10.

Since tabulate10 can give us a record of Rep10s, all we have to do to convert a lens into a Rep10 is use view to extract the desired Rep10.

field10 :: Representable10 rec => Getting (Ap10 a (Rep10 rec)) (rec (Rep10 rec)) (Ap10 a (Rep10 rec)) -> Rep10 rec a Source #

Convert a lens targeting Ap10 to a Rep10.

ixRep10 :: forall k f g (a :: k) m. (Update10 f, Functor g) => Rep10 f a -> (m a -> g (m a)) -> f m -> g (f m) #

A Lens to the field identified by a given Rep10.

    ix10 :: Update10 f => Rep10 f a -> Lens' (f m) (m a)

ap10 :: Iso (Ap10 s fs) (Ap10 t ft) (fs s) (ft t) Source #

An Iso between an Ap10 a m wrapper and its contained m a.

comp :: Iso ((m :.: n) a) ((k :.: l) b) (m (n a)) (k (l b)) Source #

An Iso between a (m :.: n) a wrapper and its contained m (n a).

_Field10 :: GEq k => k a -> Prism' (k :** m) (m a) Source #

A Prism from a ':**" to a particular field.

_Field10 k f (k := m) === (k :=) $ f m _Field10 k' f (k := m) === k := m | k' /= k _Field10 k # m === k := m

_Field10' :: forall rec a m. (GEq (Rep10 rec), Representable10 rec) => (forall n. Getting (Ap10 a n) (rec n) (Ap10 a n)) -> Prism' (Rep10 rec :** m) (m a) Source #

_Field10 taking the field lens rather than the Rep10.

(!=) :: Representable10 rec => (forall m. Getting (Ap10 a m) (rec m) (Ap10 a m)) -> f a -> Rep10 rec :** f infixr 5 Source #

Shortcut to construct a (:**) from a Getter.

Note that this assumes the fields are ultimately wrapped in Ap10. If a particular field doesn't have Ap10 (which can only arise from a manually-written Representable10 instance), just pretend it does by adding from ap10 to the lens.

(!=?) :: (Representable10 rec, Applicative f) => (forall m. Getting (Ap10 a m) (rec m) (Ap10 a m)) -> a -> Rep10 rec :** f infixr 5 Source #

Shortcut to construct a (:**) using pure for the value.

fragmented :: (Functor m, Representable10 recA, Representable10 recB, f ~ OpCostar m (Rep10 recB :** m)) => ASetter (recB f) (recA f) (f b) (f a) -> Setter (Rep10 recA :** m) (Rep10 recB :** m) a b Source #

Lifts a Setter to work underneath (:**).

This means if you know how to change the type of a whole record, you can use this to change the type of a (:**).

Example usage:

data MyRecord a m = MyRecord { _mrA :: Ap10 a m, _mrInt :: Ap10 Int m } mrA :: Lens' (MyRecord a m) (MyRecord b m) (Ap10 m a) (Ap10 m b)

example :: Rep10 (MyRecord Int) :** Identity -> Rep10 (MyRecord String) :** Identity example = fragmented (mrA.ap10) %~ show