4 ms·
that's interesting - can you expand? How do higher-kinded types address the sync/async question?
by spinningslate 5y ago
that's interesting - can you expand? How do higher-kinded types address the sync/async question?
- lmm 5y agoYou can write code that's polymorphically async or not - in its simplest form the same function returns either a value or a future/promise for that value depending on which type parameter you invoke it with. Obviously at low level there has to be two separate code paths (e.g. different system calls for a blocking vs async socket read), which you handle via typeclasses or similar, but you can write all of the composition logic (make this request, then based on the result of that make that request or...) generically in terms of an interface that both futures/promises and direct values can implement (e.g. monad).