require-typed-check
require/  typed/  check
1 Alternative Semantics for require/  typed
1.1 Deep require-typed-check
require/  typed/  check/  deep
1.2 Shallow require-typed-check
require/  typed/  check/  shallow
1.3 Optional require-typed-check
require/  typed/  check/  optional
1.4 Unsafe require-typed-check
unsafe-require/  typed/  check
2 Type Boundary Instrumentation
require-typed-check-logger
require-typed-check-info
8.12

require-typed-check🔗ℹ

 (require require-typed-check) package: require-typed-check

syntax

(require/typed/check m rt-clause ...)

Like require/typed, but expands to a (require (only-in m ...)) when m is a Typed Racket module.

If you cannot know ahead of time whether m is typed or untyped but want to avoid Typed-Racket-generated contracts if m happens to be typed, this macro is worth using. Otherwise, just use require or require/typed.

Known limitations:
  • All submodules of the current module are assumed untyped. The current implementation would need to compile the module’s submodules to be sure; it breaks the circular dependency by assuming the worst.

  • Any #:opaque imports are required via require/typed.

  • This form is intended for modules written in #lang typed/racket or typed/racket/base. For Shallow and Optional modules, use the other forms below.

Changed in version 0.3 of package require-typed-check: Added support for #:opaque.

Examples:
> (module t typed/racket
    (require require-typed-check)
  
    (require/typed/check racket/math
      ((sqr square) (-> Integer Integer)))
  
    (require/typed racket/contract
      (has-contract? (-> Any Boolean)))
  
    (define (check-contract id)
      (printf "~a does~a have a contract~n"
        (object-name id)
        (if (has-contract? id) "" " NOT")))
  
    (check-contract square)
    (check-contract has-contract?))
> (require 't)

sqr does NOT have a contract

has-contract? does have a contract

1 Alternative Semantics for require/typed🔗ℹ

The behavior of require/typed depends on the current Typed Racket language. Deep, Shallow, and Optional types have different behavior. To choose a behavior, use one of the following require/typed/check variants.

1.1 Deep require-typed-check🔗ℹ

syntax

(require/typed/check/deep m rt-clause ...)

Added in version 1.0 of package require-typed-check.

1.2 Shallow require-typed-check🔗ℹ

syntax

(require/typed/check/shallow m rt-clause ...)

Added in version 1.0 of package require-typed-check.

1.3 Optional require-typed-check🔗ℹ

syntax

(require/typed/check/optional m rt-clause ...)

Added in version 1.0 of package require-typed-check.

1.4 Unsafe require-typed-check🔗ℹ

syntax

(unsafe-require/typed/check m rt-clause ...)

Expands to either unsafe-require/typed or a plain require, depending on whether m is typed or untyped. Useful with #:struct imports to avoid creating new struct types.

Added in version 1.0 of package require-typed-check.

2 Type Boundary Instrumentation🔗ℹ

To disable require/typed/check, set the environment variable DISABLE_REQUIRE_TYPED_CHECK to any non-null value. This causes all require/typed/check forms to expand to require/typed forms.

Expanding a require/typed/check form logs an event to the 'require-typed-check topic at the 'info level.

A logger for require-typed-check.

Log events report the importing module and the syntax of the require/typed/check form. This data is package in an instance of a prefab struct:

struct

(struct require-typed-check-info (src sexp)
    #:prefab)
  src : string?
  sexp : any/c
Contains the source and value of a require/typed/check syntax object. The source src comes from syntax-source and the value sexp comes from syntax->datum.