Open
Conversation
Closed
Owner
Author
|
Right. The obvious name for the method is |
|
maybe you want to lift the component to another type where map works from Component to Component rather than from Element to Element? a = ReactDream(props => </div>)
b = HOC(a)
b.map(hoc1).map(hoc2) |
Owner
Author
|
Right. 🤦♂️ 🤦♀️ this is Applicative, but on the identity functor implementation of |
Owner
Author
|
API plan update: import ReactDream, { ReactBox } from 'react-dream'
ReactDream.Stateless(({ title }) => <h1>{title}</h1>)
.map(element => <div>{element}</div>)
.contramap(({ language }) => ({
title: language === 'en' ? 'Hello' : 'Hola'
}))
.enhance(
withState('updateTitle', 'title', 'Hola')
)
.name('Header')
ReactDream.Stateful(class extends Component {})
.map() // not optimal!
ReactDream.Stateful(class extends Component {})
.toStateless()
.map() // optimal but verbose
const withChildren = (Parent, Up, Down) =>
ReactDream.Stateless(({ parent, up, down }) =>
<Parent.Component {...parent}>
<Up {...up} />
<Down {...down} />
</Parent.Component>
)
withChildren(
Header,
Title,
Tagline
)
.contramap()
// will build a Stateful
ReactDream(class extends Component {})
// will build a Stateless
ReactDream(props => <br />)
ReactDream(props => <hr />)
.asBox()
.map()
ReactBox(props => <hr />)
.asDream()
.map()
// Equivalences
ReactDream(x).enhance(f) == ReactDream(x).asBox().map(f).asDream()
ReactBox(x).map(f).asDream() == ReactDream(x).enhance(f)
ReactBox.of(f).ap(x) == ReactBox(x).map(f)
ReactBox.of(f).ap(ReactDream(x).asBox()) == ReactBox.of(f).apDream(ReactDream(x))Keys:
|
Owner
Author
|
I’m not sure about the names |
Owner
Author
|
Change roadmap:
|
Owner
Author
|
And for the next iteration:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.promapwas not following Profunctor laws because.mapwas acting on the component as-ifReactDreamwas the identity Functor, without any extra insights into the type. This is now fixed, but the consequence is that there are two breaking changes 💥:.mapacts on the result of running the component, so the React element it outputs..promap’s second argument acts on the element as well.Another effect of this is that there now no helper to apply regular higher-order components to the component inside the ReactDream. So we need a new one.
Since it is still an implementation of Functor, it could be called
.map2. It’s not a fantastic name, but it’s accurate. It could probably have an alias. Quick alias brainstorm:.hoc.wrap.updateQuick realization: it might be that HoCs need their own Fantasy Land type, since they do form a Category / Arrow.