Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Im pretty sure not a single dev would understand what the hell is going on, and i would have to buy quite a few beers to get that passed in a CR.

That's a questionable example imho, for few reasons.

The first is that understanding an applicative functor requires you to first understand map, apply and lift.

Starting from an applicative, in any language, including Haskell, is like starting from a monad, (as you know very well they are almost the same thing as a monad is an applicative with one more rule) and then it's quite clear why we get endless blog posts that leave you no brighter.

The second is that we're talking about TypeScript, not JavaScript.

Let's make an example.

Given a definition for map in TypeScript:

map: <A, B>(f: (a: A) => B) => ((fa: F<A>) => F<B>)

which requires a minimal typescript understanding (a function from A to B and a value of type F<A> you get F<B>) to read.

If you can read map you can read ap in TypeScript:

const ap: <A>(fa: F<A>) => <B>(fab: F<(a: A) => B>) => F<B>

It's almost the same, with one major difference: you don't have a function from a to b, but one that is lifted in a datatype F, thus F<a => b>.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: