Skip to main content

Module profunctor

Module profunctor 

Source
Expand description

Implements Profunctor, Strong, and Choice traits, primarily for function types.

Structs§

Check
A simple struct for demonstrating lenses.
Forget
A Profunctor that “forgets” its second type parameter (BPhantom) and maps its first type parameter (AInput) to a fixed result type R.
Lens
A Lens is a type of Optic that focuses on a part A of a whole S, allowing both getting the part and setting it (which might change S to T and A to B).
Optic
Represents a general Optic using Profunctor encoding.

Traits§

Choice
Choice profunctors are profunctors that can operate on sum types (Result).
Profunctor
A Profunctor is a bifunctor that is contravariant in its first type parameter and covariant in its second type parameter.
Strong
Strong profunctors are profunctors that can operate on product types (tuples).

Functions§

_1
A Lens that focuses on the first element of a pair (A, C). Allows getting A and setting A to B, resulting in (B, C).
_2
A Lens that focuses on the second element of a pair (C, A). Allows getting A and setting A to B, resulting in (C, B).
_key
A Lens that focuses on the key field of a Check struct. Allows getting check.key and setting it.
lcmap
Maps the input of a Profunctor (contravariant mapping). lcmap(f, p) is equivalent to p.dimap(f, id).
lens
Constructs a Lens from a getter function and a setter function.
lens_
Internal helper to construct a Lens using the “van Laarhoven” representation. Not typically called directly by users. lens function is preferred.
rmap
Maps the output of a Profunctor (covariant mapping). rmap(f, p) is equivalent to p.dimap(id, f).
view
Extracts a value A from a structure S using a AGetter.

Type Aliases§

AGetter
An AGetter (or simply Getter) is a specialized Fold that extracts a single part A from a structure S.
Fold
A Fold is an Optic that can extract multiple pieces of data A from a structure S, and fold them using a monoid. It’s a generalization of a Getter.