"M" Types Overview ("M" Reference)

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

Within the Microsoft code name “M” modeling language, a type is a specification for a set of values. “M” is a structurally-typed language rather than a nominally-typed language, which means that two types are the same if the same collection of values conforms to both types regardless of the name of the types. For example, if you define two types, SomeNumber and AnyNumber, and both of those types are defined as "any integer", then those types are considered the same type by the “M” compiler, even though they have different names. This also means that a collection of the integers that is comprised of one through ten is simultaneously a collection of SomeNumber types as well as a collection of AnyNumber types.

It is not required that a type be named to be used. A type expression is allowed wherever a type reference is required. Types in “M” are expressions that return collections.

The types of the “M” language are divided into two main categories: intrinsic types and derived types. An intrinsic type is a type that is already defined in the “M” language and understood by the “M” compiler. A derived type is a type that you define within “M” code and can consist of a collection of intrinsic and other derived types.

All types except for the Any type (which is defined as "all possible values") are defined as a subset of possible values of another type. If every value that conforms to type A also conforms to type B, then A is a subtype of B (and B is a super-type of A). Subtyping is transitive, that is, if A is a subtype of B and B is a subtype of C, then A is a subtype of C (and C is a super-type of A).

Intrinsic Types

The “M” modeling language contains the intrinsic types shown in the following table.

Type Description

Any Type ("M" Reference)

All possible values.

General Type ("M" Reference)

All possible values except the Entity and Collection types.

Number Type ("M" Reference)

Any numeric value.

Decimal Type ("M" Reference)

A fixed point or exact number.

Decimal9 Type ("M" Reference)

A fixed point or exact number.

Decimal19 Type ("M" Reference)

A fixed point or exact number.

Decimal28 Type ("M" Reference)

A fixed point or exact number.

Decimal38 Type ("M" Reference)

A fixed point or exact number.

Integer Type ("M" Reference)

A signed integer.

Integer8 Type ("M" Reference)

A signed integer with fewer than 9 digits of precision.

Integer16 Type ("M" Reference)

A signed integer with fewer than 17 digits of precision.

Integer32 Type ("M" Reference)

A signed integer with fewer than 33 digits of precision.

Integer64 Type ("M" Reference)

A signed integer with fewer than 65 digits of precision.

Scientific Type ("M" Reference)

A floating-point or exact number.

Single Type ("M" Reference)

A 32-bit floating-point or exact number.

Double Type ("M" Reference)

A 64-bit floating-point or exact number.

Unsigned Type ("M" Reference)

An unsigned integer.

Unsigned8 Type ("M" Reference)

An unsigned integer with fewer than 9 digits of precision.

Unsigned16 Type ("M" Reference)

An unsigned integer with fewer than 17 digits of precision.

Unsigned32 Type ("M" Reference)

An unsigned integer with fewer than 33 digits of precision.

Unsigned64 Type ("M" Reference)

An unsigned integer with fewer than 65 digits of precision.

Date Type ("M" Reference)

A calendar date.

DateTime Type ("M" Reference)

A calendar date and time of day independent of time zone.

DateTimeOffset Type ("M" Reference)

A calendar date and time of day within a specific time zone.

Time Type ("M" Reference)

A time of day and time zone.

Text Type ("M" Reference)

A sequence of Characters.

Logical Type ("M" Reference)

A logical flag.

Binary Type ("M" Reference)

A sequence of binary octets.

Byte Type (“M” Reference)

A single binary octet.

Collection Type ("M" Reference)

An unordered group of potentially duplicate values.

Entity Types

A collection of labeled values.

Derived Types

Derived types are created by adding constraints to another type. Constraints limit the number of possible values that are contained within a type definition. The most common way of creating a new type is to add required fields that a type must contain. Consider the Address type shown in the following code example.

    type Address 
{
        Street: Text;
        City : Text;
        Region : Text;
        PostalCode : Text;
        Country : Text;
    };

You can create your own derived type which includes the fields of the parent type as well as any additional fields specified. The following code is an example.

    type WorkAddress : Address
    {
        OrgName : Text;
    }