Karya, built on 2022-03-21T01:30:44 (patch 89d1651424c35e564138d93424a157ff87457245)

Util.Lens

Contents

Description

Re-export a minimal version of the fclabels API.

I'd like to be able to write (a #= x) . (b #= y) without parentheses, but since (.) already binds the strongest at 9, I can't make (#=) stronger. Besides, I already want (#=) to bind loosely so I can write x#y #= 1+2. I would need a version of (.) at 0, but that's too much trouble.

Synopsis

# Documentation

type Lens a b = a :-> b Source #

Arguments

 :: (f -> a) Getter. -> ((a -> a) -> f -> f) Modifier. -> f :-> a

Create a total lens from a getter and a modifier.

We expect the following law to hold:

get l (modify l m f) == m (get l f)

(#) :: Lens a b -> Lens b c -> Lens a c infixr 9 Source #

Compose lenses.

# operators

(#$) :: Lens f a -> f -> a infixr 1 Source # Get: bval = a#b$# record

(#=) :: Lens f a -> a -> f -> f infix 1 Source #

Set: a#b #= 42 record

(%=) :: Lens f a -> (a -> a) -> f -> f infix 1 Source #

Modify: a#b %= (+1) record

(<#>) :: Functor f => Lens a b -> f a -> f b infixl 4 Source #

Use like a#b # State.get.

# data

map :: Ord k => k -> Lens (Map k a) (Maybe a) Source #

set :: Ord k => k -> Lens (Set k) Bool Source #

list :: Int -> Lens [a] (Maybe a) Source #

A negative index counts from the end of the list, and a too-high index will be ignored.