module Proton.Setter where

import Data.Profunctor

type Setter s t a b = (a -> b) -> (s -> t)
type Setter' s a = Setter s s a a

set :: Setter s t a b -> s -> b -> t
set :: Setter s t a b -> s -> b -> t
set l :: Setter s t a b
l s :: s
s b :: b
b = Setter s t a b
l (b -> a -> b
forall a b. a -> b -> a
const b
b) s
s

over :: Setter s t a b -> (a -> b) -> s -> t
over :: Setter s t a b -> Setter s t a b
over l :: Setter s t a b
l f :: a -> b
f s :: s
s = Setter s t a b
l a -> b
f s
s

sets :: (forall p. Profunctor p => p a b -> p s t) -> Setter s t a b
sets :: (forall (p :: * -> * -> *). Profunctor p => p a b -> p s t)
-> Setter s t a b
sets = (forall (p :: * -> * -> *). Profunctor p => p a b -> p s t)
-> Setter s t a b
forall a. a -> a
id

setter :: (s -> a) -> (b -> t) -> Setter s t a b
setter :: (s -> a) -> (b -> t) -> Setter s t a b
setter f :: s -> a
f g :: b -> t
g = (s -> a) -> (b -> t) -> Setter s t a b
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap s -> a
f b -> t
g

mapped :: Functor f => Setter (f a) (f b) a b
mapped :: Setter (f a) (f b) a b
mapped = Setter (f a) (f b) a b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

infixr 4 %~
(%~) :: Setter s t a b -> (a -> b) -> s -> t
%~ :: Setter s t a b -> Setter s t a b
(%~) = Setter s t a b -> Setter s t a b
forall s t a b. Setter s t a b -> Setter s t a b
over

infixr 4 .~
(.~) :: Setter s t a b -> b -> s -> t
.~ :: Setter s t a b -> b -> s -> t
(.~) l :: Setter s t a b
l b :: b
b s :: s
s = Setter s t a b -> s -> b -> t
forall s t a b. Setter s t a b -> s -> b -> t
set Setter s t a b
l s
s b
b