Source: https://dondi.lmu.build/fall2004/cmsi585/type-checking.pdf