7.4

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.4 Singleton Types

    2.5 Wrapper Types

      2.5.1 Wrapper Descriptors

      2.5.2 Wrapper Type Properties

    2.6 Reference Types

      2.6.1 Reference Type Descriptors

      2.6.2 Reference Type Properties

    2.7 Struct Descriptors