I'd like to request changing the type of Middleware from:
newtype Middleware eff state action a b =
Middleware (MiddlewareAPI eff state action -> Dispatch eff action a -> Dispatch eff action b)
To something like
newtype Middleware eff state action a b =
Middleware (MiddlewareAPI eff state action -> Eff eff (Dispatch eff action a -> Dispatch eff action b))
Note the intermediate Eff. This is important for doing staged initialization of middlewares. That is, the middleware relies on having the MiddlewareAPI before it can be initialized. In JS, the effects are pervasive so this would just be implicit and expected, and is how Redux internally initializes them. Otherwise in JS, there'd be no use for currying it.
I think technically it should be something like:
newtype Middleware eff state action a b =
Middleware (MiddlewareAPI eff state action -> Eff eff (Dispatch eff action a -> Eff eff (Dispatch eff action b)))
But I haven't come across a use for the second Eff wrapping.
I like your proposal. Makes sense. If you are interested in opening up a PR for this change, it would definitely be welcome. I can also make the update if you prefer. Thanks!
I'd like to request changing the type of
Middleware
from:To something like
Note the intermediate
Eff
. This is important for doing staged initialization of middlewares. That is, the middleware relies on having theMiddlewareAPI
before it can be initialized. In JS, the effects are pervasive so this would just be implicit and expected, and is how Redux internally initializes them. Otherwise in JS, there'd be no use for currying it.I think technically it should be something like:
But I haven't come across a use for the second Eff wrapping.