purescript-react-redux
purescript-react-redux copied to clipboard
Potentially move to another module
reducerOptic :: forall state state' action action'. Lens' state state' -> Prism' action action' -> Reducer' action' state' -> Reducer' action state
reducerOptic lens prism k =
wrap $ \action state ->
let
state' :: state'
state' = view lens state
action' :: Either action action'
action' = matching prism action
in either (const state) (\a -> set lens (unwrap k a state') state) action'