What is the difference between `’a.` and `type a.` and when to use each?

Below are alternative explanations with a varying amount of detail, depending on how much of a hurry you’re in. 😉 I will use the following code (drawn from that other question) as a running example. Here, the type annotation on the definition of reduce is actually required to make it typecheck. (* The type [(‘a, … Read more

Abusing the algebra of algebraic data types – why does this work?

Disclaimer: A lot of this doesn’t really work quite right when you account for ⊥, so I’m going to blatantly disregard that for the sake of simplicity. A few initial points: Note that “union” is probably not the best term for A+B here–that’s specifically a disjoint union of the two types, because the two sides … Read more

How can I see the full expanded contract of a Typescript type?

The quick info for a type displayed with IntelliSense often leaves something to be desired; you generally get a single representation for any given type, which may turn out to be too terse or even too verbose for your purposes. There are a few suggestions to make it more flexible (e.g., microsoft/TypeScript#25784 and microsoft/TypeScript#28508) so … Read more