pointless-lenses-0.0.7: Pointless Lenses library





Pointless Lenses: bidirectional lenses with point-free programming

This module provides examples, examples and more examples.


Lenses over trees

preOrd_lns :: Lens (Tree a) [a]Source

Flatten a tree into a list.

postOrd_lns :: Lens (Tree a) [a]Source

Flatten a tree into a list.

Lenses over lists and natural numbers

length_lns :: a -> Lens [a] NatSource

List length lens.

zipWith_lns :: Lens (a, b) c -> Lens ([a], [b]) [c]Source

zip_lns :: Lens ([a], [b]) [(a, b)]Source

List zipping lens.

take_lns :: Lens (Nat, [a]) [a]Source

Take the first n elements from a list

filter_left_lns :: Lens [Either a b] [a]Source

List filtering lens. The argument passed to snd_lns can be undefined because it will never be used

cat_lns :: Lens ([a], [a]) [a]Source

Binary list concatenation. Lens hylomorphisms can be defined as the composition of a catamorphism after an anamorphism.

transpose_lns :: Lens ([a], [a]) [a]Source

Binary list transposition. Binary version of transpose.

plus_lns :: Lens (Nat, Nat) NatSource

Addition of two natural numbers.

concatMap_lns :: Lens a [b] -> Lens [a] [b]Source

concat_lns :: Lens [[a]] [a]Source

List concatenation.

partition_lns :: Lens [Either a b] ([a], [b])Source

Partitions a list of options into two lists. Note that this imposes some redefinement of the traditional definition in order to fit our framework.

map_lns :: Lens c a -> Lens [c] [a]Source

List mapping lens.

head_lns :: [a] -> Lens [a] (Either One a)Source

tail_lns :: a -> Lens [a] (Either One [a])Source


snoc_lns :: Lens (a, [a]) (Some a)Source

Inserts an element at the end of a list, thus making it non-empty.

toSome_lns :: Lens [a] (Either One (Some a))Source

Isomorphism between a list and an optional non-empty list.

some_lns :: Eq a => a -> Lens [a] (Some a)Source

Converts a list into a non-empty list.

fromSome_lns :: Lens (Either One (Some a)) [a]Source

Isomorphism between a list and an optional non-empty list.

reverse_lns :: Lens [a] [a]Source

The list reversal lens is an isomorphism.

Non-natural lenses

len_lns :: Lens ([a], Int) IntSource

List length using an accumulation (after simplification into an hylomorphism). Uses Int instead of Nat because succ on Nat is not a valid lens.

sumInt_lns :: Lens [Int] IntSource

Sum of a list of integers.

isum_lns :: Lens [Int] [Int]Source

Incremental summation of a list. Since general splitting is not a lens, we need to provide user-defined put and create functions that serve our purpose and construct a valid lens.