4 ms·
I'm having trouble grokking whatever type-added syntax you're using for Javascript here. I'm guessing it's: function ap(pf) { return (pa) => pf.th
by phs2501 11y ago
I'm having trouble grokking whatever type-added syntax you're using for Javascript here. I'm guessing it's:
function ap(pf) {
return (pa) =>
pf.then((f) => pa.then((a) => Promise.resolve(f(a))))
}
Still, if I wanted to go full-hog static-typed functional I doubt I'd be using straight Javascript, I'd probably try one of the various Haskell-alike to JS converters. Promises with async/await syntax seems like the most practical of the various solutions whilst still feeling like Javascript.
(Besides, I prefer dynamic typing and I find points-free style in Haskell to be obfuscating rather than clarifying, so it seems unlikely we're going to have the same opinion of the best way to accomplish things here. :)
- tel 11y agoSorry, I'm just writing in Typescript. It's the typed Javascript flavor I'm most familiar with. But, yep, you properly erased the types. I'd love to use Haskell-to-JS but I don't think I could bet a product on it quite yet.