Code is coloured in many different ways. Coloured code have restrictions on how it can interact with code of a different colour.
We say code is has two different colours async and synchronous.
Since async/await are promises and promises are monad, does this mean all monads colour code?
Consider the Option monad. It remains coloured while passing around Some/None values, but can also become uncoloured.
Example of Option monad in Scala,
Similarly in Haskell IO is a monad that colours a program.
Since Haskell IO is isolating the side-effects of IO from pure functions, does this mean function purity colours code?
Function purity has yet another set of colouring rules,
Notice how these are the same rules as synchronous/async function, yet it is a different colouring.
There are so many other forms of colouring,
requestAnimationFrames are coloured
type="script"are coloured. Modules import other modules declaratively, but scripts import other modules with dynamic import.
Different colourings are mostly independent which makes code very confusing very fast. If one tries to optimize for one type of colouring, often it ruins the colouring of another. Everything becomes a huge tradeoff.
Can you skillfully navigate coloured code? We’re like to hear from you, Battlefy is hiring.