On this page:
declare-refinement
Refinement
define-typed-struct/  exec
define-new-subtype
6.8

14 Experimental Features

These features are currently experimental and subject to change.

syntax

(declare-refinement id)

Declares id to be usable in refinement types.

syntax

(Refinement id)

Includes values that have been tested with the predicate id, which must have been specified with declare-refinement.

syntax

(define-typed-struct/exec forms ...)

Defines an executable structure.

syntax

(define-new-subtype name (constructor t))

Defines a new type name that is a subtype of t. The constructor is defined as a function that takes a value of type t and produces a value of the new type name. A define-new-subtype definition is only allowed at the top level of a file or module.

This is purely a type-level distinction, with no way to distinguish the new type from the base type at runtime. Predicates made by make-predicate won’t be able distinguish them properly, so they will return true for all values that the base type’s predicate would return true for. This is usually not what you want, so you shouldn’t use make-predicate with these types.

Examples:
> (module m typed/racket
    (provide Radians radians f)
    (define-new-subtype Radians (radians Real))
    (: f : [Radians -> Real])
    (define (f a)
      (sin a)))
> (require 'm)
> (radians 0)

- : Real [more precisely: Radians]

0

> (f (radians 0))

- : Real

0