Update lens operators
This commit is contained in:
parent
40fd0a3a3b
commit
1e6309237b
|
@ -154,7 +154,7 @@ infix 4 <||=; infix 4 <&&=; infix 4 <<+>=
|
|||
infix 4 <<%=; infix 4 <<%@=; infix 4 <<.=; infix 4 <<?=; infix 4 <<+=; infix 4 <<*=
|
||||
infix 4 <<-=; infix 4 <</=; infix 4 <<||=; infix 4 <<&&=; infix 4 <<<+>=
|
||||
|
||||
infixr 2 <<~
|
||||
infixr 1 <<<~
|
||||
|
||||
|
||||
public export
|
||||
|
@ -403,11 +403,8 @@ public export
|
|||
|
||||
|
||||
||| Run a monadic action and set the focus of an optic in state to the result.
|
||||
||| This is different from `(<~)` in that it also passes though the output of
|
||||
||| the action.
|
||||
||| This is different from `(<~)` and `(<<~)` in that it also passes though
|
||||
||| the old value of the optic.
|
||||
public export
|
||||
(<<~) : MonadState s m => Lens s s a b -> m b -> m b
|
||||
(<<~) l x = do
|
||||
v <- x
|
||||
modify $ l @{MkIsLens Function} (const v)
|
||||
pure v
|
||||
(<<<~) : MonadState s m => Lens s s a b -> m b -> m a
|
||||
(<<<~) l m = l <<.= !m
|
||||
|
|
|
@ -157,6 +157,8 @@ infix 4 %=; infix 4 %@=; infix 4 .=; infix 4 .@=; infix 4 ?=; infix 4 <.=
|
|||
infix 4 <?=; infix 4 +=; infix 4 *=; infix 4 -=; infix 4 //=; infix 4 ||=
|
||||
infix 4 &&=; infixr 4 <+>=
|
||||
|
||||
infix 1 <~
|
||||
infixr 1 <<~
|
||||
|
||||
||| Set the focus of an optic to `Just` a value.
|
||||
public export
|
||||
|
@ -303,4 +305,11 @@ public export
|
|||
||| variable.
|
||||
public export
|
||||
(<~) : MonadState s m => Setter s s a b -> m b -> m ()
|
||||
(<~) l m = m >>= (l .=)
|
||||
(<~) l m = l .= !m
|
||||
|
||||
||| Run a monadic action and set the focus of an optic in state to the result.
|
||||
||| This is different from `(<~)` in that it also passes though the output of
|
||||
||| the action.
|
||||
public export
|
||||
(<<~) : MonadState s m => Setter s s a b -> m b -> m b
|
||||
(<<~) l m = l <.= !m
|
||||
|
|
Loading…
Reference in a new issue