3 ms·
Use ADTs, described on a high level with something like this: data Pics = PicsLoading | PicsFailed | PicsLoaded (Array Pic) Now yo
by wereHamster 9y ago
Use ADTs, described on a high level with something like this:
data Pics
= PicsLoading
| PicsFailed
| PicsLoaded (Array Pic)
Now you only need to figure out how you want to map it into assembler (eh, JavaScript). But that's largely a mechanical task. Like for example a compiler does.
Use a object with a tag field (like advocated by redux and well-supported in flow/typescript), or an array where the first element is a numeric tag and the rest payload (that's roughly the bytecode that a Haskell compiler would produce), or, god forbid, classes with instanceof checks or abstract class methods (hello Java).