-
Notifications
You must be signed in to change notification settings - Fork 6
Simplify #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify #10
Changes from 1 commit
9c64f18
006071b
26e8866
7dfe906
61f0e9d
6688c34
e782d05
c3062fa
32c64be
25d1e3a
a2dc225
edafd70
e7962a8
bd35267
4a49239
6482b29
588aa3f
461075d
7a802c3
2a2bb20
9c99881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module React.Redux | ||
( ReduxReactClass | ||
, ReduxReactClass' | ||
( ReactClass | ||
, ReactClass' | ||
, ReduxEffect | ||
, REDUX | ||
, Reducer | ||
|
@@ -13,10 +13,9 @@ module React.Redux | |
, Store | ||
, connect | ||
, connect_ | ||
, createProviderElement | ||
, createProviderElement_ | ||
, createElement | ||
, createElement_ | ||
, createProviderElement | ||
, createStore | ||
, createStore' | ||
, dispatch | ||
|
@@ -41,7 +40,7 @@ import React as React | |
|
||
import Unsafe.Coerce (unsafeCoerce) | ||
|
||
type ReduxReactClass' state props = ReduxReactClass state Unit props | ||
type ReactClass' state props = ReactClass state Unit props | ||
|
||
type Reducer' action state = Reducer action state state | ||
|
||
|
@@ -87,30 +86,27 @@ instance semigroupReducer :: Semigroup state' => Semigroup (Reducer action state | |
instance monoidReducer :: Monoid state' => Monoid (Reducer action state state') where | ||
mempty = Reducer (const (const (mempty))) | ||
|
||
createProviderElement :: forall action props props' state. Store action state -> ReduxReactClass state props props' -> props -> Array React.ReactElement -> React.ReactElement | ||
createProviderElement store reduxClass props children = React.createElement providerClass { store } [ createElement reduxClass props children ] | ||
|
||
createProviderElement_ :: forall action props state. Store action state -> ReduxReactClass' state props -> React.ReactElement | ||
createProviderElement_ store reduxClass = React.createElement providerClass { store } [ createElement_ reduxClass [] ] | ||
|
||
connect :: forall props props' state. Getter' (Tuple state props) props' -> React.ReactClass props' -> ReduxReactClass state props props' | ||
connect :: forall props props' state. Getter' (Tuple state props) props' -> React.ReactClass props' -> ReactClass state props props' | ||
connect slens class_ = runFn3 connectFn Tuple (view slens) class_ | ||
|
||
connect_ :: forall props state. Getter' state props -> React.ReactClass props -> ReduxReactClass' state props | ||
connect_ :: forall props state. Getter' state props -> React.ReactClass props -> ReactClass' state props | ||
connect_ slens class_ = connect slens' class_ | ||
where | ||
slens' :: Getter' (Tuple state Unit) props | ||
slens' = to (view slens <<< fst) | ||
|
||
createElement :: forall state props props'. ReduxReactClass state props props' -> props -> Array React.ReactElement -> React.ReactElement | ||
createElement :: forall state props props'. ReactClass state props props' -> props -> Array React.ReactElement -> React.ReactElement | ||
createElement reduxClass = React.createElement reactClass | ||
where | ||
reactClass :: React.ReactClass props | ||
reactClass = unsafeCoerce reduxClass | ||
|
||
createElement_ :: forall state props. ReduxReactClass' state props -> Array React.ReactElement -> React.ReactElement | ||
createElement_ :: forall state props. ReactClass' state props -> Array React.ReactElement -> React.ReactElement | ||
createElement_ reduxClass = createElement reduxClass unit | ||
|
||
createProviderElement :: forall action state. Store action state -> Array React.ReactElement -> React.ReactElement | ||
createProviderElement store = React.createElement providerClass { store } | ||
|
||
createStore :: forall eff action state. Reducer' action state -> state -> Enhancer eff action state -> Eff (ReduxEffect eff) (Store action state) | ||
createStore = runFn3 createStoreFn | ||
|
||
|
@@ -139,9 +135,9 @@ foreign import data REDUX :: Effect | |
|
||
foreign import data Store :: Type -> Type -> Type | ||
|
||
foreign import data ReduxReactClass :: Type -> Type -> Type -> Type | ||
foreign import data ReactClass :: Type -> Type -> Type -> Type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will affect error messages. PureScript doesn't show qualified type names (or maybe it's just a problem of psa?). This might lead to some confusion when reading an error message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And for this, I think you are looking at an outdated version. This has been renamed to |
||
|
||
foreign import connectFn :: forall state props props'. Fn3 (state -> props -> Tuple state props) (Tuple state props -> props') (React.ReactClass props') (ReduxReactClass state props props') | ||
foreign import connectFn :: forall state props props'. Fn3 (state -> props -> Tuple state props) (Tuple state props -> props') (React.ReactClass props') (ReactClass state props props') | ||
|
||
foreign import dispatchFn :: forall eff action props state. Fn2 (React.ReactThis props state) action (Eff (ReduxEffect eff) action) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
slens <<< _1
_1
is inData.Lens.Lens.Tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are looking at an outdated version here.
connect
does not useGetter'
in the latest version.