<commit_before>=head1 NAME

milldata - Mill types and values

=head1 DESCRIPTION

Mill has a dynamic type system.

=head2 Types

=head3 The Top and Bottom Types

The top type is a supertype of all types. The bottom type is a subtype of all
types. There are no types that are strict supertypes of the top type and there
are no types that are strict subtypes of the bottom type. There are no values
of the bottom type.

The bottom type is typically used as the return type for subroutines that never
return, and as the exception specification for subroutines that never throw.

The top type is C<std::always::Any> and the bottom type is
C<std::always::Bottom>.

=head3 Protocol Types

A protocol type defines a set of subroutines which can be overloaded by a
protocol implementation. A protocol implementation overloads these subroutines
for some type, making that type a subtype of the protocol type.

    protocol Monitor {
        proc start(monitor: this) ensure !stopped(monitor)
        proc stop(monitor: this) ensure stopped(monitor)
        func running(monitor: this): Boolean
    }

    struct PingMonitor {
        address: Address
        interval: Duration
    }

    implement Monitor for PingMonitor {
        proc start(monitor: PingMonitor) { ... }
        proc stop(monitor: PingMonitor) { ... }
        proc running(monitor: PingMonitor) { ... }
    }

=head3 Structure Types

A structure type defines a set of fields.

    struct User {
        id: Int
        name: String
        birthday: LocalDate
    }

A lens will be generated for each field.

=head3 Union Types

A union type represents one of many possible structures.

    union Option(T: in) {
        Some(x: T)
        None
    }

Optionally, a union type can describe fields common to all variants:

    union Token {
        common(position: Int)
        Identifier(name: String)
        StringLiteral(value: String)
        EOF
    }

The common fields will be inserted at the beginning of the field list for every
variant.

A lens will be generated for each common field. A prism will be generated for
each non-common field.

=head2 Destruction

When the reference count of a Mill value reaches zero, the C<destruct>
procedure in the C<mill> module is invoked if it is overloaded for the type of
the value. The value is passed as the argument to C<destruct>.

=cut
<commit_msg>Describe equivalence operators<commit_after>=head1 NAME

milldata - Mill types and values

=head1 DESCRIPTION

Mill has a dynamic type system.

=head2 Types

=head3 The Top and Bottom Types

The top type is a supertype of all types. The bottom type is a subtype of all
types. There are no types that are strict supertypes of the top type and there
are no types that are strict subtypes of the bottom type. There are no values
of the bottom type.

The bottom type is typically used as the return type for subroutines that never
return, and as the exception specification for subroutines that never throw.

The top type is C<std::always::Any> and the bottom type is
C<std::always::Bottom>.

=head3 Protocol Types

A protocol type defines a set of subroutines which can be overloaded by a
protocol implementation. A protocol implementation overloads these subroutines
for some type, making that type a subtype of the protocol type.

    protocol Monitor {
        proc start(monitor: this) ensure !stopped(monitor)
        proc stop(monitor: this) ensure stopped(monitor)
        func running(monitor: this): Boolean
    }

    struct PingMonitor {
        address: Address
        interval: Duration
    }

    implement Monitor for PingMonitor {
        proc start(monitor: PingMonitor) { ... }
        proc stop(monitor: PingMonitor) { ... }
        proc running(monitor: PingMonitor) { ... }
    }

=head3 Structure Types

A structure type defines a set of fields.

    struct User {
        id: Int
        name: String
        birthday: LocalDate
    }

A lens will be generated for each field.

=head3 Union Types

A union type represents one of many possible structures.

    union Option(T: in) {
        Some(x: T)
        None
    }

Optionally, a union type can describe fields common to all variants:

    union Token {
        common(position: Int)
        Identifier(name: String)
        StringLiteral(value: String)
        EOF
    }

The common fields will be inserted at the beginning of the field list for every
variant.

A lens will be generated for each common field. A prism will be generated for
each non-common field.

=head2 Destruction

When the reference count of a Mill value reaches zero, the C<destruct>
procedure in the C<mill> module is invoked if it is overloaded for the type of
the value. The value is passed as the argument to C<destruct>.

=head2 Equivalence and Ordering

The C<identity> function (not to be confused with the identity function) takes
a value and returns the identity of that value, which uniquely identifies it.
This is important for mutable vs immutable values. For example, the C<identity>
function returns the same value for C<1> and C<1>, but different ones for
C<array()> and C<array()>, because arrays are mutable.

There are various equivalence and ordering operators.

=over

=item C<is>, C<isn't>

C<a is b> is true iff C<a> and C<b> have the same identity. It is false
otherwise. C<isn't> is the opposite of C<is>.

=item C<==>, C<!=>

C<a == b> is true iff C<a> and C<b> have the type and the same structure. It is
false if they do not have the same structure. It has a precondition that the
values have the same type. This differs with C<is> for mutable values and for
types with partial equivalence. For example, C<array() isn't array() && array()
== array()>.

=item C<eq>, C<ne>

C<a eq b> is true iff C<a> and C<b> represent the same value. This is
interesting in the case of numbers, for example, C<1 isn't 1.0 && 1 eq 1.0>.

=back

=cut

{'fraction_non_alphanumeric': 0.061999659342531085, 'fraction_numerical': 0.0042582183614375746, 'mean_word_length': 3.2305475504322767, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5956161', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1580, 'n_words': 834}