8.18
top
← prev up next →

require-typed-checkπŸ”— i

syntax

( require/typed/check mrt-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 ttyped/racket
(require require-typed-check)
(require/typed/check racket/math
((sqrsquare)(-> Integer Integer )))
(require/typed racket/contract
(define (check-contractid)
(printf "~a does~a have a contract~n"
(if (has-contract? id)""" NOT")))
(check-contractsquare)
(check-contracthas-contract? ))
> (require 't)

sqr does NOT have a contract

has-contract? does have a contract

1Alternative Semantics for require/typed πŸ”— i

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.1Deep require-typed-check πŸ”— i

syntax

( require/typed/check/deepmrt-clause...)

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

1.2Shallow require-typed-check πŸ”— i

syntax

( require/typed/check/shallowmrt-clause...)

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

1.3Optional require-typed-check πŸ”— i

syntax

( require/typed/check/optionalmrt-clause...)

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

1.4Unsafe require-typed-check πŸ”— i

syntax

( unsafe-require/typed/checkmrt-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.

2Type Boundary InstrumentationπŸ”— i

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

#: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 .

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /