vitrea-0.1.0.0: Profunctor optics via the profunctor representation theorem.

Copyright(c) Mario Román 2020
LicenseGPL-3
Maintainermromang08@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Optics

Description

Obtains the common optics and some new ones as particular cases of the unified definition of optic. This definition has been studied by Milewski ("Profunctor optics, the categorical view", 2016), then by Boisseau and Gibbons ("What you needa know about Yoneda", 2017), then by Riley ("Categories of optics", 2018), and in the mixed enriched case we implement by Clarke, Elkins, Gibbons, Loregian, Milewski, Pillmore and Román ("Profunctor optics, a categorical update", 2019).

Synopsis

Documentation

type Lens a s = ProfOptic Any (->) Any (->) Any (->) (,) () (,) (,) a a s s Source #

Lenses are optics for the action of the category on itself via the cartesian product.

mkLens :: (s -> a) -> (s -> a -> s) -> Lens a s Source #

type Prism a s = ProfOptic Any (->) Any (->) Any (->) Either Void Either Either a a s s Source #

Prisms are optics for the action of the category on itself via the coproduct.

mkPrism :: (s -> Either s a) -> (a -> s) -> Prism a s Source #

type AlgebraicLens m a s = Monad m => ProfOptic Any (->) Any (->) (Algebra m) (->) (,) () (,) (,) a a s s Source #

Algebraic lenses are optics for the action of the category of algebras of a monad.

mkAlgebraicLens :: forall m a s. Monad m => (s -> a) -> (m s -> a -> s) -> AlgebraicLens m a s Source #

type Kaleidoscope a s = ProfOptic Any (->) Any (->) Applicative Nat Compose Identity App App a a s s Source #

Kaleidoscopes are optics for the action by evaluation of applicative functors.

mkKaleidoscope :: (([a] -> a) -> [s] -> s) -> Kaleidoscope a s Source #

type MonadicLens m a b s t = Monad m => ProfOptic Any (->) Any (Kleisli m) Any (->) (,) () (,) (,) a b s t Source #

Monadic lenses are mixed optics for the cartesian product in the base category and in the Kleisli category.

mkMonadicLens :: forall m a b s t. Monad m => (s -> a) -> (s -> b -> m t) -> MonadicLens m a b s t Source #

type Traversal a s = ProfOptic Any (->) Any (->) Traversable Nat Compose Identity App App a a s s Source #

Traversals as optics for the action of traversable functors.

mkTraversal :: forall a b s t. (s -> [a]) -> ([a] -> s) -> Traversal a s Source #