r/functionalprogramming • u/ibrahimbensalah • Feb 28 '23
Question Is JSX a hidden monad bind?
Say we have this example
function Component() {
return <Layout><Page /></Layout>
}
And lets assume this is compiled to
where type of jsx is (fn, JSX.Element) => JSX.Element. For simplicity ignore that we can have multiple elements in the second argument.
jsx is not in the form of monadic bind (JSX.Element, (fn) => JSX.Element) => JSX.Element. If we ignore the laws, can we say jsx is a special case of the monadic bind function nevertheless?
15
Upvotes
View all comments
Show parent comment
4
u/EsperSpirit Feb 28 '23
If you're thinking about combining values (e. g. JSX fragments), you might want to look at Semigroup and Monoid.