7.7

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 Record Types

    2.3 Tuple Types

      2.3.1 Tuple Type Information

      2.3.2 Tuple Type Descriptors

      2.3.3 Dynamically Implementing Tuple Types

      2.3.4 Tuple Chaperones and Impersonators

    2.4 Enum Types

    2.5 Singleton Types

    2.6 Wrapper Types

      2.6.1 Wrapper Descriptors

      2.6.2 Wrapper Type Properties

    2.7 Object Types

      2.7.1 Object Type Information

      2.7.2 Object Type Descriptors

      2.7.3 Dynamically Implementing Object Types

      2.7.4 Object Type Chaperones and Impersonators

    2.8 Struct Descriptors