1. A method of type-checking a code segment written in a programming language comprising: translating the code segment from the programming language to one or more representations of an intermediate language; and type-checking the one or more representations based on a rule set, wherein the rule set comprises rules for type-checking a type that indicates an element of the representation can be one of a plurality of types.