8.0

2 Data Types

 (require rebellion/type) package: rebellion

A data type or simply type is a set of values together with 1) some basic operations on those values and 2) a predicate to test whether a value is within that set. There are many different kinds of data types, with different basic operations and meant for different use cases.

> (define-tuple-type point (x y))
> (point 7 42)

(point 7 42)

> (define-record-type circle (radius color))
> (circle #:radius 5 #:color 'red)

(circle #:color 'red #:radius 5)

> (define-wrapper-type inches)
> (inches 17)

(inches 17)

> (define-singleton-type undefined)
> undefined

#<undefined>

    2.1 Interfaces Common to All Types

      2.1.1 Nominal v.s. Structural Types

      2.1.2 Struct-Based Types and Struct Type Properties

      2.1.3 Type Implementations and Generativity

      2.1.4 Defining Types

      2.1.5 Compile-Time Type Information

    2.2 Tuple Types

      2.2.1 Tuple Type Information

      2.2.2 Tuple Type Descriptors

      2.2.3 Tuple Type Bindings

      2.2.4 Tuple Chaperones and Impersonators

    2.3 Record Types

      2.3.1 Record Type Information

      2.3.2 Record Type Descriptors

      2.3.3 Record Type Bindings

    2.4 Enum Types

      2.4.1 Enum Type Information

      2.4.2 Enum Type Descriptors

      2.4.3 Enum Type Bindings

    2.5 Singleton Types

      2.5.1 Singleton Type Information

      2.5.2 Singleton Type Descriptors

      2.5.3 Singleton Type Bindings

    2.6 Wrapper Types

      2.6.1 Wrapper Type Information

      2.6.2 Wrapper Type Descriptors

      2.6.3 Wrapper Type Bindings

    2.7 Object Types

      2.7.1 Object Type Information

      2.7.2 Object Type Descriptors

      2.7.3 Object Type Bindings

      2.7.4 Object Type Chaperones and Impersonators

    2.8 Struct Descriptors