2 ms·
There are a good deal of resources explaining these concepts in non-Haskell languages. This one is quite good and in javascript: https://github.com/MostlyAdequa
by handsaway 5y ago
There are a good deal of resources explaining these concepts in non-Haskell languages. This one is quite good and in javascript: https://github.com/MostlyAdequate/mostly-adequate-guide https://github.com/MostlyAdequate/mostly-adequate-guide
As far as functors this could be rephrased more comprehensibly to those unfamiliar with Haskell as "What is a Functor, really? Functor is an interface here are some definitions:"
(typescript)
interface ArrayFunctor<A, B> {
map: (f: ((a: A) -> B), arr: Array<A>) -> Array<B>
}
interface PromiseFunctor<A, B> {
map: (f: ((a: A) -> B), arr: Promise<A>) -> Promise<B>
}
interface ObservableFunctor<A, B> {
map: (f: ((a: A) -> B), arr: Observable<A>) -> Observable<B>
}
"definitions" is plural here because typescript doesn't support higher-kinded types or else it might look like this:
interface Functor<F, A, B> {
map: (f: ((a: A) -> B), arr: F<A>) -> F<B>
}
(note, there are ways around this used in the fp-ts library, see here: https://www.matechs.com/blog/encoding-hkts-in-ts4-1 https://www.matechs.com/blog/encoding-hkts-in-ts4-1)
> I actually do understand some useful subset of what Monads are and I just don't know it
This is certainly the case if you have ever used flatMap on an array or chained Promises (or other async structures like futures in other langs).