Starting in TypeScript 3.6, tsc's previously "whatever brah" mentality surrounding generators was finally replaced with accurate types. This is nice, because it gets us some extra guarantees at compile time, in particular when dealing with some asynchronous code. But the types of generators can be tricky to grok at first, and in order to understand [...]
In a couple of previous posts, I've used "nullary types", and sort of hand-waved away any explanation of what that actually means. When we're dealing with types, some are simply a set of concrete values. Consider the classical Int, Bool, or Char; you have all the information you need to use those types just based [...]
Just as we can define our own types in Sanctuary, we can also define functions and ask the typechecker to make sure our usage and implementations of those functions align with the types we specify.