This file is indexed.

/usr/share/doc/racket/ts-guide/caveats.html is in racket-doc 6.7-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>8&nbsp;Caveats and Limitations</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9660;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">The Typed Racket Guide</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="quick.html" class="tocviewlink" data-pltdoc="x">Quick Start</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="beginning.html" class="tocviewlink" data-pltdoc="x">Beginning Typed Racket</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="more.html" class="tocviewlink" data-pltdoc="x">Specifying Types</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="types.html" class="tocviewlink" data-pltdoc="x">Types in Typed Racket</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="occurrence-typing.html" class="tocviewlink" data-pltdoc="x">Occurrence Typing</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="typed-untyped-interaction.html" class="tocviewlink" data-pltdoc="x">Typed-<wbr></wbr>Untyped Interaction</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="optimization.html" class="tocviewlink" data-pltdoc="x">Optimization in Typed Racket</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Caveats and Limitations</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>8&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Caveats and Limitations</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">8.1&nbsp;</td><td><a href="#%28part._.The_.Integer_type_and_integer_%29" class="tocviewlink" data-pltdoc="x">The <span class="RktSym"><span class="RktStxLink">Integer</span></span> type and <span class="RktSym"><span class="RktValLink">integer?</span></span></a></td></tr><tr><td align="right">8.2&nbsp;</td><td><a href="#%28part._.Type_inference_for_polymorphic_functions%29" class="tocviewlink" data-pltdoc="x">Type inference for polymorphic functions</a></td></tr><tr><td align="right">8.3&nbsp;</td><td><a href="#%28part._.Typed-untyped_interaction_and_contract_generation%29" class="tocviewlink" data-pltdoc="x">Typed-<wbr></wbr>untyped interaction and contract generation</a></td></tr><tr><td align="right">8.4&nbsp;</td><td><a href="#%28part._.Unsupported_features%29" class="tocviewlink" data-pltdoc="x">Unsupported features</a></td></tr><tr><td align="right">8.5&nbsp;</td><td><a href="#%28part._.Type_generalization%29" class="tocviewlink" data-pltdoc="x">Type generalization</a></td></tr><tr><td align="right">8.6&nbsp;</td><td><a href="#%28part._.Macros_and_compile-time_computation%29" class="tocviewlink" data-pltdoc="x">Macros and compile-<wbr></wbr>time computation</a></td></tr><tr><td align="right">8.7&nbsp;</td><td><a href="#%28part._.Expensive_contract_boundaries%29" class="tocviewlink" data-pltdoc="x">Expensive contract boundaries</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">8.1<tt>&nbsp;</tt></span><a href="#%28part._.The_.Integer_type_and_integer_%29" class="tocsubseclink" data-pltdoc="x">The <span class="RktSym"><span class="RktStxLink">Integer</span></span> type and <span class="RktSym"><span class="RktValLink">integer?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">8.2<tt>&nbsp;</tt></span><a href="#%28part._.Type_inference_for_polymorphic_functions%29" class="tocsubseclink" data-pltdoc="x">Type inference for polymorphic functions</a></td></tr><tr><td><span class="tocsublinknumber">8.3<tt>&nbsp;</tt></span><a href="#%28part._.Typed-untyped_interaction_and_contract_generation%29" class="tocsubseclink" data-pltdoc="x">Typed-<wbr></wbr>untyped interaction and contract generation</a></td></tr><tr><td><span class="tocsublinknumber">8.4<tt>&nbsp;</tt></span><a href="#%28part._.Unsupported_features%29" class="tocsubseclink" data-pltdoc="x">Unsupported features</a></td></tr><tr><td><span class="tocsublinknumber">8.5<tt>&nbsp;</tt></span><a href="#%28part._.Type_generalization%29" class="tocsubseclink" data-pltdoc="x">Type generalization</a></td></tr><tr><td><span class="tocsublinknumber">8.6<tt>&nbsp;</tt></span><a href="#%28part._.Macros_and_compile-time_computation%29" class="tocsubseclink" data-pltdoc="x">Macros and compile-<wbr></wbr>time computation</a></td></tr><tr><td><span class="tocsublinknumber">8.7<tt>&nbsp;</tt></span><a href="#%28part._.Expensive_contract_boundaries%29" class="tocsubseclink" data-pltdoc="x">Expensive contract boundaries</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.7</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="optimization.html" title="backward to &quot;7 Optimization in Typed Racket&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="index.html" title="up to &quot;The Typed Racket Guide&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next &rarr;</span></span>&nbsp;</div><h3 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;caveats&quot;">8<tt>&nbsp;</tt><a name="(part._caveats)"></a>Caveats and Limitations</h3><p>This section describes limitations and subtle aspects of the
type system that programmers often stumble on while porting programs
to Typed Racket.</p><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;The_Integer_type_and_integer_&quot;">8.1<tt>&nbsp;</tt><a name="(part._.The_.Integer_type_and_integer_)"></a>The <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span> type and <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span></h4><p>In Typed Racket, the <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span> type corresponds to values
that return <span class="RktVal">#t</span> for the <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-integer%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">exact-integer?</a></span> predicate,
<span style="font-weight: bold"><span style="font-style: italic">not</span></span> the <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span> predicate. In particular,
values that return <span class="RktVal">#t</span> for <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">integer?</a></span> may be
<a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=numbers.html%23%2528tech._inexact._number%2529&amp;version=6.7" class="techoutside Sq" data-pltdoc="x"><span class="techinside">inexact number</span></a>s (e.g, <span class="RktVal">1.0</span>).</p><p>When porting a program to Typed Racket, you may need to replace
uses of functions like <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._round%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">round</a></span> and <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._floor%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">floor</a></span> with
corresponding exact functions like <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fmath..rkt%2529._exact-round%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">exact-round</a></span> and
<span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528lib._racket%252Fmath..rkt%2529._exact-floor%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">exact-floor</a></span>.</p><p>In other cases, it may be necessary to use <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=Utilities.html%23%2528def._%2528%2528lib._typed-racket%252Fbase-env%252Fextra-procs..rkt%2529._assert%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">assert</a></span>ions
or <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._cast%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">cast</a></span>s.</p><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Type_inference_for_polymorphic_functions&quot;">8.2<tt>&nbsp;</tt><a name="(part._.Type_inference_for_polymorphic_functions)"></a>Type inference for polymorphic functions</h4><p>Typed Racket&rsquo;s local type inference algorithm is currently not
able to infer types for polymorphic functions that are used
on higher-order arguments that are themselves polymorphic.</p><p>For example, the following program results in a type error
that demonstrates this limitation:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">map</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="hspace">&nbsp;</span><span class="RktVal">c</span><span class="hspace">&nbsp;</span><span class="RktVal">d</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:2:0: Type Checker: Polymorphic function `map' could not</span></p></td></tr><tr><td><p><span class="RktErr">be applied to arguments:</span></p></td></tr><tr><td><p><span class="RktErr">Domains: (-&gt; a b ... b c) (Listof a) (Listof b) ... b</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(-&gt; a c) (Pairof a (Listof a))</span></p></td></tr><tr><td><p><span class="RktErr">Arguments: (All (a b) (case-&gt; (-&gt; a (Listof a) (Listof a))</span></p></td></tr><tr><td><p><span class="RktErr">(-&gt; a b (Pairof a b)))) (List 'a 'b 'c 'd) (List One</span></p></td></tr><tr><td><p><span class="RktErr">Positive-Byte Positive-Byte Positive-Byte)</span></p></td></tr><tr><td><blockquote class="SubFlow"></blockquote></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: 4</span></p></td></tr></table></blockquote><p>The issue is that the type of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">cons</a></span> is also polymorphic:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">cons</a></span></td></tr><tr><td><p><span class="RktOut">- : (All (a b) (case-&gt; (-&gt; a (Listof a) (Listof a)) (-&gt; a b (Pairof a b))))</span></p></td></tr><tr><td><p><span class="RktRes">#&lt;procedure:cons&gt;</span></p></td></tr></table></blockquote><p>To make this expression type-check, the <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._inst%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">inst</a></span> form can
be used to instantiate the polymorphic argument (e.g., <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">cons</a></span>)
at a specific type:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmap..rkt%2529._map%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">map</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._inst%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">inst</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Symbol%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Symbol</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">b</span><span class="hspace">&nbsp;</span><span class="RktVal">c</span><span class="hspace">&nbsp;</span><span class="RktVal">d</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">4</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : (Listof (Pairof Symbol Integer))</span></p></td></tr><tr><td><p><span class="RktRes">'((a . 1) (b . 2) (c . 3) (d . 4))</span></p></td></tr></table></blockquote><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Typed-untyped_interaction_and_contract_generation&quot;">8.3<tt>&nbsp;</tt><a name="(part._.Typed-untyped_interaction_and_contract_generation)"></a>Typed-untyped interaction and contract generation</h4><p>When a typed module <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">require</a></span>s bindings from an untyped
module (or vice-versa), there are some types that cannot be
converted to a corresponding contract.</p><p>This could happen because a type is not yet supported in the
contract system, because Typed Racket&rsquo;s contract generator has
not been updated, or because the contract is too difficult
to generate. In some of these cases, the limitation will be
fixed in a future release.</p><p>The following illustrates an example type that cannot be
converted to a contract:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._require%252Ftyped%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">require/typed</a></span><span class="hspace">&nbsp;</span><span class="RktSym">racket/base</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=inspectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._object-name%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">object-name</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._case-%7E3e%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">case-&gt;</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._-%7E3e%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Struct-.Type-.Property%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Struct-Type-Property</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Symbol%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Symbol</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._-%7E3e%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Regexp%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Regexp</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._.U%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">U</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.String%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">String</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Bytes%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Bytes</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktErr">eval:5:0: Type Checker: Error in macro expansion -- Type</span></p></td></tr><tr><td><p><span class="RktErr">(case-&gt; (-&gt; Struct-Type-Property Symbol) (-&gt; Regexp (U</span></p></td></tr><tr><td><p><span class="RktErr">String Bytes))) could not be converted to a contract:</span></p></td></tr><tr><td><p><span class="RktErr">function type has two cases of arity 1</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (case-&gt; (-&gt; Struct-Type-Property Symbol) (-&gt; Regexp (U</span></p></td></tr><tr><td><p><span class="RktErr">String Bytes)))</span></p></td></tr></table></blockquote><p>This function type by cases is a valid type, but a corresponding
contract is difficult to generate because the check on the result
depends on the check on the domain. In the future, this may be
supported with dependent contracts.</p><p>A more approximate type will work for this case, but with a loss
of type precision at use sites:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._require%252Ftyped%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">require/typed</a></span><span class="hspace">&nbsp;</span><span class="RktSym">racket/base</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=inspectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._object-name%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">object-name</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._-%7E3e%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._.U%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">U</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Struct-.Type-.Property%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Struct-Type-Property</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Regexp%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Regexp</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._.U%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">U</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.String%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">String</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Bytes%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Bytes</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Symbol%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=inspectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._object-name%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">object-name</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#rx"a regexp"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : (U Symbol String Bytes)</span></p></td></tr><tr><td><p><span class="RktRes">"a regexp"</span></p></td></tr></table></blockquote><p>Use of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._define-predicate%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-predicate</a></span> also involves contract generation, and
so some types cannot have predicates generated for them. The following
illustrates a type for which a predicate can&rsquo;t be generated:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._define-predicate%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-predicate</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p?</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types-extra..rkt%2529._.All%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">All</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">A</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Listof%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Listof</a></span><span class="hspace">&nbsp;</span><span class="RktSym">A</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:8:0: Type Checker: Error in macro expansion -- Type</span></p></td></tr><tr><td><p><span class="RktErr">Listof could not be converted to a predicate: cannot</span></p></td></tr><tr><td><p><span class="RktErr">generate contract for non-function polymorphic type</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (All (A) (Listof A))</span></p></td></tr></table></blockquote><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Unsupported_features&quot;">8.4<tt>&nbsp;</tt><a name="(part._.Unsupported_features)"></a>Unsupported features</h4><p>Most structure type properties do not work in Typed Racket, including
support for generic interfaces.</p><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Type_generalization&quot;">8.5<tt>&nbsp;</tt><a name="(part._.Type_generalization)"></a>Type generalization</h4><p>Not so much a caveat as a feature that may have unexpected consequences.
To make programming with invariant type constructors (such as <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Boxof%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Boxof</a></span>)
easier, Typed Racket generalizes types that are used as arguments to invariant
type constructors. For example:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktVal">0</span></td></tr><tr><td><p><span class="RktOut">- : Integer [more precisely: Zero]</span></p></td></tr><tr><td><p><span class="RktRes">0</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._define%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=boxes.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._box%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">box</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">b</span></td></tr><tr><td><p><span class="RktOut">- : (Boxof Integer)</span></p></td></tr><tr><td><p><span class="RktRes">'#&amp;0</span></p></td></tr></table></blockquote><p><span class="RktVal">0</span> has type <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Zero%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Zero</a></span>, which means that <span class="RktSym">b</span> &ldquo;should&rdquo; have
type <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Boxof%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Boxof</a></span><span class="stt"> </span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Zero%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Zero</a></span><span class="RktPn">)</span>. On the other hand, that type is not especially
useful, as it only allows <span class="RktVal">0</span> to be stored in the box. Most likely, the
intent was to have a box of a more general type (such as <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Integer%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Integer</a></span>) and
initialize it with <span class="RktVal">0</span>. Type generalization does exactly that.</p><p>In some cases, however, type generalization can lead to unexpected results:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=boxes.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._box%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">box</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._ann%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">ann</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Fixnum%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Fixnum</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : (Boxof Integer)</span></p></td></tr><tr><td><p><span class="RktRes">'#&amp;1</span></p></td></tr></table></blockquote><p>The intent of this code may be to create of box of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Fixnum%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Fixnum</a></span>, but Typed
Racket will generalize it anyway. To create a box of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Fixnum%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Fixnum</a></span>, the box
itself should have a type annotation:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._ann%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">ann</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=boxes.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._box%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">box</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Boxof%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Boxof</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Fixnum%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Fixnum</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : (Boxof Fixnum)</span></p></td></tr><tr><td><p><span class="RktRes">'#&amp;1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=special-forms.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fprims..rkt%2529._inst%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">inst</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=boxes.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._box%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">box</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=ts-reference&amp;rel=type-ref.html%23%2528form._%2528%2528lib._typed-racket%252Fbase-env%252Fbase-types..rkt%2529._.Fixnum%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">Fixnum</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : (Boxof Fixnum)</span></p></td></tr><tr><td><p><span class="RktRes">'#&amp;1</span></p></td></tr></table></blockquote><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Macros_and_compile-time_computation&quot;">8.6<tt>&nbsp;</tt><a name="(part._.Macros_and_compile-time_computation)"></a>Macros and compile-time computation</h4><p>Typed Racket will type-check all expressions at the run-time phase of
the given module and will prevent errors that would occur at run-time.
However, expressions at compile-time&#8212;<wbr></wbr>including computations that
occur inside macros&#8212;<wbr></wbr>are not checked.</p><p>Concretely, this means that expressions inside, for example, a
<span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=begin.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._begin-for-syntax%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">begin-for-syntax</a></span> block are not checked:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=begin.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._begin-for-syntax%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">begin-for-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">"foo"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">+: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: number?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: "foo"</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">argument position: 2nd</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">other arguments...:</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">1</span></p></td></tr></table></blockquote><p>Similarly, expressions inside of macros defined in Typed Racket are
not type-checked. On the other hand, the macro&rsquo;s expansion is always
type-checked:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">example-1</span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">"foo"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktRdr">#'</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&amp;version=6.7" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">example-2</span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.7" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">"foo"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">example-1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">+: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: number?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: "foo"</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">argument position: 2nd</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">other arguments...:</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">example-2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:17:0: Type Checker: type mismatch</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: Number</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: String</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (quote "foo")</span></p></td></tr></table></blockquote><p>Note that functions defined in Typed Racket that are used at
compile-time in other typed modules or untyped modules will be
type-checked and then protected with contracts as described in
<a href="typed-untyped-interaction.html" data-pltdoc="x">Typed-Untyped Interaction</a>.</p><p>Additionally, macros that are defined in Typed Racket modules cannot
be used in ordinary Racket modules because such uses can
circumvent the protections of the type system.</p><h4 x-source-module="(lib &quot;typed-racket/scribblings/ts-guide.scrbl&quot;)" x-source-pkg="typed-racket-doc" x-part-tag="&quot;Expensive_contract_boundaries&quot;">8.7<tt>&nbsp;</tt><a name="(part._.Expensive_contract_boundaries)"></a>Expensive contract boundaries</h4><p>Contract boundaries installed for typed-untyped interaction may cause
significant slowdowns. See <a href="optimization.html#%28part._contract-costs%29" data-pltdoc="x">Contract boundaries</a> for details.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="optimization.html" title="backward to &quot;7 Optimization in Typed Racket&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="index.html" title="up to &quot;The Typed Racket Guide&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<span class="nonavigation">next &rarr;</span></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>