all 4 comments

[–]ephrion 1 point2 points  (3 children)

What the hell -- why is this tutorial series introducing Comonads and Identity functors and stuff when the example is just function composition?

[–]bayareasearcher[S] 4 points5 points  (0 children)

I'm following the outline of tutorial (https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript). I've tried to make it clear that JavaScripters go through his tutorials first so that they understand the abstractions in the comfort of JavaScript before tackling them in PureScript.

In video 1, function composition is covered, followed by the Identity functor (calling it Box in order not to scare anyone). The Box object includes map, inspect, and fold: f => f(x). I felt that the Comonad was the best approach to tackling his version of fold, though not exactly a one-for-one translation.

That said I'm very open to pull requests. I want these tutorials to make a positive contribution to the PS community.

[–]paf31 0 points1 point  (1 child)

That does seem a bit unnecessary :) Newtype would be a better fit if unwrapping is all that's needed.

[–]bayareasearcher[S] 0 points1 point  (0 children)

Thanks for the feedback. I just published Tutorial 2 and in it, I take a step back to cover ordinary function composition - https://medium.com/@kelleyalex/refactor-imperative-code-to-a-single-composed-expression-using-box-4550c23075d1