Skip to content

Instantly share code, notes, and snippets.

@staydecent
Created February 8, 2020 02:14
Show Gist options
  • Save staydecent/6667a0a13f574892567c4c0dcd95d9d9 to your computer and use it in GitHub Desktop.
Save staydecent/6667a0a13f574892567c4c0dcd95d9d9 to your computer and use it in GitHub Desktop.
const seq = (...args) => input => args.reduce((acc, el) => el(acc), input)
const cons = (a, b) => fn => fn(a, b)
const car = pair => pair((a, b) => a)
const cdr = pair => pair((a, b) => b)
const render = Comp => seq(car(Comp), cdr(Comp))
const App = cons(state => state.count, count => `Count ${count}`)
console.log(
render(App)({count: 2})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment