Stability | provisional |
---|---|
Maintainer | Hugo Pacheco <hpacheco@nii.ac.jp> |
Safe Haskell | None |
Core language of put-based lenses.
- withMonadPut :: (Monad m, Monad n) => (forall a. Maybe s -> v -> n a -> m a) -> PutlensM n s v -> PutlensM m s v
- effectPut :: Monad m => (Maybe s -> v -> m ()) -> PutlensM m s v -> PutlensM m s v
- runMaybePut :: Monad m => PutlensMaybeM m s v -> PutlensM m s v
- runStatePut :: Monad m => (Maybe s -> v -> m st) -> PutlensStateM m st s v -> PutlensM m s v
- resetStatePut :: Monad m => (Maybe s -> v -> st -> m st') -> PutlensStateM m st' s v -> PutlensStateM m st s v
- withStatePut :: MonadState st m => (Maybe s -> v -> st -> m st) -> PutlensM m s v -> PutlensM m s v
- withStateTPut :: Monad m => (Maybe s -> v -> st -> m st) -> PutlensStateM m st s v -> PutlensStateM m st s v
- updateStatePut :: MonadState st m => (Maybe s -> s -> st -> m st) -> PutlensM m s v -> PutlensM m s v
- updateStateTPut :: Monad m => (Maybe s -> s -> st -> m st) -> PutlensStateM m st s v -> PutlensStateM m st s v
- runReaderPut :: Monad m => (Maybe s -> v -> m e) -> PutlensReaderM m e s v -> PutlensM m s v
- runReaderPutS :: Monad m => PutlensReaderM m s s v -> PutlensM m s v
- runReaderPutMbS :: Monad m => PutlensReaderM m (Maybe s) s v -> PutlensM m s v
- runReaderPutV :: Monad m => PutlensReaderM m v s v -> PutlensM m s v
- runReaderPutMbV :: Monad m => PutlensReaderM m (Maybe v) s v -> PutlensM m s v
- runReaderPutV' :: Monad m => PutlensReaderM m v s v -> PutlensM m s v
- withReaderPut :: Monad m => (Maybe s -> v -> e -> m e') -> PutlensReaderM m e' s v -> PutlensReaderM m e s v
- modifyS :: (Monad m, Eq v) => (Maybe s -> v -> m (Maybe s)) -> PutlensM m s v -> PutlensM m s v
- modifyV' :: Monad m => (Maybe s -> v -> m v) -> PutlensM m s v -> PutlensM m s v
- updateS' :: Monad m => (Maybe s -> s -> m s) -> PutlensM m s v -> PutlensM m s v
- unforkPut :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (v1, v2)
- idPut :: Monad m => PutlensM m v v
- (.<) :: Monad m => PutlensM m s u -> PutlensM m u v -> PutlensM m s v
- phiPut :: Monad m => (v -> Bool) -> PutlensM m v v
- botPut :: Monad m => PutlensM m a b
- addfstPut :: (Monad m, Eq v) => (Maybe (s1, v) -> v -> m s1) -> PutlensM m (s1, v) v
- addsndPut :: (Monad m, Eq v) => (Maybe (v, s2) -> v -> m s2) -> PutlensM m (v, s2) v
- dupPut :: (Monad m, Eq v) => PutlensM m (v, v) v
- keepfstPut :: (Monad m, Eq v) => PutlensM m (s1, v) v
- keepsndPut :: (Monad m, Eq v) => PutlensM m (v, s2) v
- keepfstOrPut :: (Monad m, Eq v) => (v -> m s1) -> PutlensM m (s1, v) v
- keepsndOrPut :: (Monad m, Eq v) => (v -> m s2) -> PutlensM m (v, s2) v
- remfstPut :: (Monad m, Eq v1) => (v -> v1) -> PutlensM m v (v1, v)
- remsndPut :: (Monad m, Eq v2) => (v -> v2) -> PutlensM m v (v, v2)
- (><<) :: (Monad m, Eq v1, Eq v2) => PutlensM m s1 v1 -> PutlensM m s2 v2 -> PutlensM m (s1, s2) (v1, v2)
- ignorePut :: (Monad m, Eq v) => v -> PutlensM m () v
- newPut :: Monad m => s -> PutlensM m s ()
- keepPut :: Monad m => PutlensM m s ()
- pntPut :: Monad m => (Maybe a -> m a) -> PutlensM m a ()
- addfstOnePut :: (Monad m, Eq v) => PutlensM m ((), v) v
- addsndOnePut :: (Monad m, Eq v) => PutlensM m (v, ()) v
- remfstOnePut :: Monad m => PutlensM m a ((), a)
- remsndOnePut :: Monad m => PutlensM m a (a, ())
- injPut :: (Monad m, Eq v) => (Maybe (Either v v) -> v -> m Bool) -> PutlensM m (Either v v) v
- injsOrPut :: (Monad m, Eq v) => (v -> m Bool) -> PutlensM m (Either v v) v
- injlsPut :: (Monad m, Eq v) => PutlensM m (Either v v) v
- injrsPut :: (Monad m, Eq v) => PutlensM m (Either v v) v
- injunionPut :: (Eq v, MonadPlus m) => PutlensM m s1 v -> PutlensM m s2 v -> PutlensM m (Either s1 s2) v
- (\/<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)
- eitherSPut :: Monad m => (s -> Bool) -> PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)
- (.\/<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)
- (\/.<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)
- (-|-<) :: Monad m => PutlensM m s1 v1 -> PutlensM m s2 v2 -> PutlensM m (Either s1 s2) (Either v1 v2)
- injlPut :: Monad m => PutlensM m (Either v v2) v
- injrPut :: Monad m => PutlensM m (Either v1 v) v
- uninjlPut :: Monad m => PutlensM m v (Either v v2)
- uninjrPut :: Monad m => PutlensM m v (Either v1 v)
- ifthenelsePut :: (Monad m, Eq v) => (Maybe s -> v -> m Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s v
- ifVthenelsePut :: (Monad m, Eq v) => (v -> Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s v
- ifSthenelsePut :: (Monad m, Eq v) => (s -> Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s v
- ifKthenelsePut :: (Monad m, Eq v) => (Maybe s -> v -> m Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s v
- unionPut :: (Eq v, MonadPlus m) => PutlensM m s v -> PutlensM m s v -> PutlensM m s v
- customPut :: (Monad m, Eq v) => (Maybe s -> v -> m s) -> (s -> v) -> PutlensM m s v
- innPut :: (Monad m, InOut a) => PutlensM m a (F a)
- outPut :: (Monad m, InOut a) => PutlensM m (F a) a
- swapPut :: Monad m => PutlensM m (b, a) (a, b)
- assoclPut :: Monad m => PutlensM m ((a, b), c) (a, (b, c))
- assocrPut :: Monad m => PutlensM m (a, (b, c)) ((a, b), c)
- coswapPut :: Monad m => PutlensM m (Either b a) (Either a b)
- coassoclPut :: Monad m => PutlensM m (Either (Either a b) c) (Either a (Either b c))
- coassocrPut :: Monad m => PutlensM m (Either a (Either b c)) (Either (Either a b) c)
- distlPut :: Monad m => PutlensM m (Either (a, c) (b, c)) (Either a b, c)
- distrPut :: Monad m => PutlensM m (Either (a, b) (a, c)) (a, Either b c)
- undistlPut :: Monad m => PutlensM m (Either a b, c) (Either (a, c) (b, c))
- undistrPut :: Monad m => PutlensM m (a, Either b c) (Either (a, b) (a, c))
- subrPut :: Monad m => PutlensM m (b, (a, c)) (a, (b, c))
- sublPut :: Monad m => PutlensM m ((a, c), b) ((a, b), c)
- cosubrPut :: Monad m => PutlensM m (Either b (Either a c)) (Either a (Either b c))
- cosublPut :: Monad m => PutlensM m (Either (Either a c) b) (Either (Either a b) c)
- distpPut :: Monad m => PutlensM m ((a, c), (b, d)) ((a, b), (c, d))
- distsPut :: Monad m => PutlensM m (Either (Either (a, c) (a, d)) (Either (b, c) (b, d))) (Either a b, Either c d)
- paramfstPut :: Monad m => (k -> PutlensM m s v) -> PutlensM m (k, s) (k, v)
- paramfstGet :: (Monad m, Eq v) => (k -> PutlensM m s v) -> PutlensM m (k, s) v
- paramsndPut :: Monad m => (k -> PutlensM m s v) -> PutlensM m (s, k) (v, k)
- paramsndGet :: (Monad m, Eq v) => (k -> PutlensM m s v) -> PutlensM m (s, k) v
Documentation
withMonadPut :: (Monad m, Monad n) => (forall a. Maybe s -> v -> n a -> m a) -> PutlensM n s v -> PutlensM m s vSource
Runs an inner monad n
inside a putlens with monad m
effectPut :: Monad m => (Maybe s -> v -> m ()) -> PutlensM m s v -> PutlensM m s vSource
Applies some monadic modification (like changing a state) to a putlens
runMaybePut :: Monad m => PutlensMaybeM m s v -> PutlensM m s vSource
Converts a putlens wiht explicitly partial put functions into a normal putlens
runStatePut :: Monad m => (Maybe s -> v -> m st) -> PutlensStateM m st s v -> PutlensM m s vSource
Initializes the monad with a new state
resetStatePut :: Monad m => (Maybe s -> v -> st -> m st') -> PutlensStateM m st' s v -> PutlensStateM m st s vSource
Ignores the current state and initializes a new state monad with a new state
withStatePut :: MonadState st m => (Maybe s -> v -> st -> m st) -> PutlensM m s v -> PutlensM m s vSource
Modifies the state before executing put
withStateTPut :: Monad m => (Maybe s -> v -> st -> m st) -> PutlensStateM m st s v -> PutlensStateM m st s vSource
updateStatePut :: MonadState st m => (Maybe s -> s -> st -> m st) -> PutlensM m s v -> PutlensM m s vSource
Modifies the state after executing put
updateStateTPut :: Monad m => (Maybe s -> s -> st -> m st) -> PutlensStateM m st s v -> PutlensStateM m st s vSource
runReaderPut :: Monad m => (Maybe s -> v -> m e) -> PutlensReaderM m e s v -> PutlensM m s vSource
runReaderPutS :: Monad m => PutlensReaderM m s s v -> PutlensM m s vSource
runReaderPutMbS :: Monad m => PutlensReaderM m (Maybe s) s v -> PutlensM m s vSource
runReaderPutV :: Monad m => PutlensReaderM m v s v -> PutlensM m s vSource
runReaderPutMbV :: Monad m => PutlensReaderM m (Maybe v) s v -> PutlensM m s vSource
runReaderPutV' :: Monad m => PutlensReaderM m v s v -> PutlensM m s vSource
withReaderPut :: Monad m => (Maybe s -> v -> e -> m e') -> PutlensReaderM m e' s v -> PutlensReaderM m e s vSource
modifyS :: (Monad m, Eq v) => (Maybe s -> v -> m (Maybe s)) -> PutlensM m s v -> PutlensM m s vSource
Modifies the original source before executing put (unsafe cast)
modifyV' :: Monad m => (Maybe s -> v -> m v) -> PutlensM m s v -> PutlensM m s vSource
Modifies the updated view before executing put (unsafe cast)
updateS' :: Monad m => (Maybe s -> s -> m s) -> PutlensM m s v -> PutlensM m s vSource
Modifies the updated source after executing put (unsafe cast)
unforkPut :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (v1, v2)Source
Unfork putlens that applies two putlenses to distinct sides of a view pair, producing the same source (unsafe) ^ Dualizes forward splitting and induces a source-passing style
(.<) :: Monad m => PutlensM m s u -> PutlensM m u v -> PutlensM m s vSource
Binary composition of putlenses
addfstPut :: (Monad m, Eq v) => (Maybe (s1, v) -> v -> m s1) -> PutlensM m (s1, v) vSource
Adds a value to the left of the view (according to a user-specified function)
addsndPut :: (Monad m, Eq v) => (Maybe (v, s2) -> v -> m s2) -> PutlensM m (v, s2) vSource
Adds a value to the right of the view (according to a user-specified function)
dupPut :: (Monad m, Eq v) => PutlensM m (v, v) vSource
Duplicates a view by enforcing the two sources to be the same
keepfstPut :: (Monad m, Eq v) => PutlensM m (s1, v) vSource
Adds a value to the left of the view (retrieving it from the original source)
keepsndPut :: (Monad m, Eq v) => PutlensM m (v, s2) vSource
Adds a value to the right of the view (retrieving it from the original source)
keepfstOrPut :: (Monad m, Eq v) => (v -> m s1) -> PutlensM m (s1, v) vSource
Adds a value to the left of the view (retrieving it from the original source or otherwise using a user-specified function)
keepsndOrPut :: (Monad m, Eq v) => (v -> m s2) -> PutlensM m (v, s2) vSource
Adds a value to the right of the view (retrieving it from the original source or otherwise using a user-specified function)
remfstPut :: (Monad m, Eq v1) => (v -> v1) -> PutlensM m v (v1, v)Source
Deletes the left value of a view pair (taking a user-specified function that instructs how it can be restored)
remsndPut :: (Monad m, Eq v2) => (v -> v2) -> PutlensM m v (v, v2)Source
Deletes the right value of a view pair (taking a user-specified function that instructs how it can be restored)
(><<) :: (Monad m, Eq v1, Eq v2) => PutlensM m s1 v1 -> PutlensM m s2 v2 -> PutlensM m (s1, s2) (v1, v2)Source
Product putlens that applies two putlenses to distinct sides of a view pair, producing a source pair
pntPut :: Monad m => (Maybe a -> m a) -> PutlensM m a ()Source
Creates a source from an empty view (according to a user-specified function)
addfstOnePut :: (Monad m, Eq v) => PutlensM m ((), v) vSource
Adds an empty view to the left of the view
addsndOnePut :: (Monad m, Eq v) => PutlensM m (v, ()) vSource
Adds an empty view to the right of the view
remfstOnePut :: Monad m => PutlensM m a ((), a)Source
Deletes an empty view to the left of the view
remsndOnePut :: Monad m => PutlensM m a (a, ())Source
Deletes an empty view to the left of the view
injPut :: (Monad m, Eq v) => (Maybe (Either v v) -> v -> m Bool) -> PutlensM m (Either v v) vSource
Injects a tag in the view (according to a user-specified predicate)
injsOrPut :: (Monad m, Eq v) => (v -> m Bool) -> PutlensM m (Either v v) vSource
Injects a tag in the view (according to the tags of the original source)
injlsPut :: (Monad m, Eq v) => PutlensM m (Either v v) vSource
Injects a tag in the view (according to the tags of the original source) with a left default for create
injrsPut :: (Monad m, Eq v) => PutlensM m (Either v v) vSource
Injects a tag in the view (according to the tags of the original source) with a right default for create
injunionPut :: (Eq v, MonadPlus m) => PutlensM m s1 v -> PutlensM m s2 v -> PutlensM m (Either s1 s2) vSource
Injects a tag in the view according to the tags of the original source or giving preference to the first lens when both are applicable.
Requires the monad to be an instance of MonadPlus
to recover from failure.
(\/<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)Source
Ignores the tags in the view
^ Fails whenever the domains of getM f
and getM g
are not disjoint
eitherSPut :: Monad m => (s -> Bool) -> PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)Source
Ignores the tags in the view (guaranteeing disjointness according to a predicate on sources)
(.\/<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)Source
Ignores the tags in the view (left-biased) ^ Guarantees disjointness by favoring the left putlens
(\/.<) :: Monad m => PutlensM m s v1 -> PutlensM m s v2 -> PutlensM m s (Either v1 v2)Source
Ignores the tags in the view (right-biased) ^ Guarantees disjointness by favoring the right putlens
(-|-<) :: Monad m => PutlensM m s1 v1 -> PutlensM m s2 v2 -> PutlensM m (Either s1 s2) (Either v1 v2)Source
Sum putlens that applies two putlenses to distinct sides of a view sum, producing a view sum
ifthenelsePut :: (Monad m, Eq v) => (Maybe s -> v -> m Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s vSource
Conditional putlens combinator
ifVthenelsePut :: (Monad m, Eq v) => (v -> Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s vSource
Conditional putlens combinator (with a predicate on views)
ifSthenelsePut :: (Monad m, Eq v) => (s -> Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s vSource
Conditional putlens combinator (with a predicate on sources)
ifKthenelsePut :: (Monad m, Eq v) => (Maybe s -> v -> m Bool) -> PutlensM m s v -> PutlensM m s v -> PutlensM m s vSource
Special if-then-else combinator for two putlenses with the same get function ^ Given the invariant |getM f = getM g|, there are no restrictions regarding branching behavior
unionPut :: (Eq v, MonadPlus m) => PutlensM m s v -> PutlensM m s v -> PutlensM m s vSource
Union of two putlenses (requires the monad to be an instance of MonadPlus
to be able to recover from failure)
customPut :: (Monad m, Eq v) => (Maybe s -> v -> m s) -> (s -> v) -> PutlensM m s vSource
Embed user-specified lenses as putlenses
innPut :: (Monad m, InOut a) => PutlensM m a (F a)Source
Putlens from a sums-of-products view to an algebraic data type source
outPut :: (Monad m, InOut a) => PutlensM m (F a) aSource
Putlens from an algebraic data type view to a sums-of-products source
assoclPut :: Monad m => PutlensM m ((a, b), c) (a, (b, c))Source
Associates a right-nested view pair to the left
assocrPut :: Monad m => PutlensM m (a, (b, c)) ((a, b), c)Source
Associates a left-nested view pair to the right
coswapPut :: Monad m => PutlensM m (Either b a) (Either a b)Source
Swaps the order of elements in a view sum
coassoclPut :: Monad m => PutlensM m (Either (Either a b) c) (Either a (Either b c))Source
Associates a right-nested view sum to the left
coassocrPut :: Monad m => PutlensM m (Either a (Either b c)) (Either (Either a b) c)Source
Associates a left-nested view sum to the left
distlPut :: Monad m => PutlensM m (Either (a, c) (b, c)) (Either a b, c)Source
Distributes a sum to the left of a view pair into a sum of pairs
distrPut :: Monad m => PutlensM m (Either (a, b) (a, c)) (a, Either b c)Source
Distributes a sum to the right of a view pair into a sum of pairs
undistlPut :: Monad m => PutlensM m (Either a b, c) (Either (a, c) (b, c))Source
Undistributes a sum of pairs view into source pair with a sum to the left
undistrPut :: Monad m => PutlensM m (a, Either b c) (Either (a, b) (a, c))Source
Undistributes a sum of pairs view into source pair with a sum to the right
subrPut :: Monad m => PutlensM m (b, (a, c)) (a, (b, c))Source
Swaps the first with the second element of a right-nested view pair
sublPut :: Monad m => PutlensM m ((a, c), b) ((a, b), c)Source
Swaps the second with the third element of a left-nested view pair
cosubrPut :: Monad m => PutlensM m (Either b (Either a c)) (Either a (Either b c))Source
Swaps the first with the second choice of a right-nested view sum
cosublPut :: Monad m => PutlensM m (Either (Either a c) b) (Either (Either a b) c)Source
Swaps the second with the third choice of a left-nested view sum
distpPut :: Monad m => PutlensM m ((a, c), (b, d)) ((a, b), (c, d))Source
Swaps the order of two nested view pairs
distsPut :: Monad m => PutlensM m (Either (Either (a, c) (a, d)) (Either (b, c) (b, d))) (Either a b, Either c d)Source
Distributes a pair of view sums into a sum of choices
paramfstPut :: Monad m => (k -> PutlensM m s v) -> PutlensM m (k, s) (k, v)Source
Lifts a parameter outside of a lens (first element as external parameter)
paramfstGet :: (Monad m, Eq v) => (k -> PutlensM m s v) -> PutlensM m (k, s) vSource
Lifts a left element of the source to an external parameter
paramsndPut :: Monad m => (k -> PutlensM m s v) -> PutlensM m (s, k) (v, k)Source
Lifts a parameter outside of a lens (second element as external parameter)