purescript-react-redux icon indicating copy to clipboard operation
purescript-react-redux copied to clipboard

Potentially move to another module

Open ethul opened this issue 7 years ago • 0 comments

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'

ethul avatar Sep 06 '17 21:09 ethul