1. A method for defining declarative code according to a declarative programming model comprising a type system supporting type refinement and type membership, including: receiving a specification of at least one programming construct of a declarative programming language including receiving a specification of a type refinement construct that defines at least one type by specifying values for which a Boolean expression is true, and receiving, within the type refinement construct, a specification of a type membership test construct that determines whether one or more resulting values of evaluating an expression is a member of an indicated type; and generating a machine readable representation of code based on the specification of the at least one programming construct.