/usr/share/doc/racket/ts-reference/Utilities.html is in racket-doc 6.1-4.
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 | <!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>5 Utilities</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,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">The Typed Racket Reference</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="type-ref.html" class="tocviewlink" data-pltdoc="x">Type Reference</a></td></tr><tr><td align="right">2 </td><td><a href="special-forms.html" class="tocviewlink" data-pltdoc="x">Special Form Reference</a></td></tr><tr><td align="right">3 </td><td><a href="Libraries_Provided_With_Typed_Racket.html" class="tocviewlink" data-pltdoc="x">Libraries Provided With Typed Racket</a></td></tr><tr><td align="right">4 </td><td><a href="Typed_Classes.html" class="tocviewlink" data-pltdoc="x">Typed Classes</a></td></tr><tr><td align="right">5 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Utilities</a></td></tr><tr><td align="right">6 </td><td><a href="Exploring_Types.html" class="tocviewlink" data-pltdoc="x">Exploring Types</a></td></tr><tr><td align="right">7 </td><td><a href="Typed_Racket_Syntax_Without_Type_Checking.html" class="tocviewlink" data-pltdoc="x">Typed Racket Syntax Without Type Checking</a></td></tr><tr><td align="right">8 </td><td><a href="Typed_Regions.html" class="tocviewlink" data-pltdoc="x">Typed Regions</a></td></tr><tr><td align="right">9 </td><td><a href="Optimization_in_Typed_Racket.html" class="tocviewlink" data-pltdoc="x">Optimization in Typed Racket</a></td></tr><tr><td align="right">10 </td><td><a href="Legacy_Forms.html" class="tocviewlink" data-pltdoc="x">Legacy Forms</a></td></tr><tr><td align="right">11 </td><td><a href="Compatibility_Languages.html" class="tocviewlink" data-pltdoc="x">Compatibility Languages</a></td></tr><tr><td align="right">12 </td><td><a href="Experimental_Features.html" class="tocviewlink" data-pltdoc="x">Experimental Features</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,"tocview_1");">►</a></td><td>5 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Utilities</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">5.1 </td><td><a href="#%28part._.Untyped_.Utilities%29" class="tocviewlink" data-pltdoc="x">Untyped Utilities</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">assert</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._with-asserts%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">with-<wbr></wbr>asserts</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._defined~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">defined?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._index~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">index?</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">typecheck-<wbr></wbr>fail</span></span></a></td></tr><tr><td><span class="tocsublinknumber">5.1<tt> </tt></span><a href="#%28part._.Untyped_.Utilities%29" class="tocsubseclink" data-pltdoc="x">Untyped Utilities</a></td></tr><tr><td><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">require/<span class="mywbr"> </span>untyped-<wbr></wbr>contract</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._define-typed%2Funtyped-identifier%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>typed/<span class="mywbr"> </span>untyped-<wbr></wbr>identifier</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._typed%2Funtyped-utils..rkt%29._syntax-local-typed-context~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">syntax-<wbr></wbr>local-<wbr></wbr>typed-<wbr></wbr>context?</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.1</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, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="Typed_Classes.html" title="backward to "4 Typed Classes"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "The Typed Racket Reference"" data-pltdoc="x">up</a> <a href="Exploring_Types.html" title="forward to "6 Exploring Types"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "typed-racket/scribblings/ts-reference.scrbl")" x-part-tag=""Utilities"">5<tt> </tt><a name="(part._.Utilities)"></a>Utilities</h3><p>Typed Racket provides some additional utility functions to facilitate typed programming.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._typed-racket/base-env/extra-procs..rkt)._assert))"></a><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValDef RktValLink" data-pltdoc="x">assert</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym">A</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29" class="RktStxLink" data-pltdoc="x">U</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktSym">A</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValDef RktValLink" data-pltdoc="x">assert</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span><span class="RktVar">p?</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym">B</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">A</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">p?</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">A</span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktSym">B</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Verifies that the argument satisfies the constraint. If no predicate
is provided, simply checks that the value is not
<span class="RktVal">#f</span>.</div></p><p>See also the <span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._cast%29%29" class="RktStxLink" data-pltdoc="x">cast</a></span> form.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="Legacy_Forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define~3a%29%29" class="RktStxLink" data-pltdoc="x">define:</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29" class="RktStxLink" data-pltdoc="x">U</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.String%29%29" class="RktStxLink" data-pltdoc="x">String</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number-%7E3estring%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">number->string</a></span><span class="hspace"> </span><span class="RktVal">7</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">x</span></td></tr><tr><td><p><span class="RktOut">- : (U False String)</span></p></td></tr><tr><td><p><span class="RktRes">"7"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValLink" data-pltdoc="x">assert</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : String</span></p></td></tr><tr><td><p><span class="RktRes">"7"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="Legacy_Forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define~3a%29%29" class="RktStxLink" data-pltdoc="x">define:</a></span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29" class="RktStxLink" data-pltdoc="x">U</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.String%29%29" class="RktStxLink" data-pltdoc="x">String</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29" class="RktStxLink" data-pltdoc="x">Symbol</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"hello"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">y</span></td></tr><tr><td><p><span class="RktOut">- : (U Symbol String)</span></p></td></tr><tr><td><p><span class="RktRes">"hello"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValLink" data-pltdoc="x">assert</a></span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : String</span></p></td></tr><tr><td><p><span class="RktRes">"hello"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValLink" data-pltdoc="x">assert</a></span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">- : Any [more precisely: Nothing]</span></p></td></tr><tr><td><p><span class="RktErr">Assertion #<procedure:boolean?> failed on "hello"</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._typed-racket/base-env/prims..rkt)._with-asserts))"></a><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._with-asserts%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">with-asserts</a></span></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">id</span><span class="hspace"> </span><span class="RktVar">maybe-pred</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVar">body</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">maybe-pred</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td></td></tr></table></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">predicate</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Guard the body with assertions. If any of the assertions fail, the
program errors. These assertions behave like <span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._assert%29%29" class="RktValLink" data-pltdoc="x">assert</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._typed-racket/base-env/extra-procs..rkt)._defined~3f))"></a><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fextra-procs..rkt%29._defined~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">defined?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">any/c</span></td></tr></table></blockquote></div><div class="SIntrapara">A predicate for determining if
<span class="RktVar">v</span> is <span style="font-style: italic">not</span> <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="nobreak"><span class="RktRes">#<undefined></span></span></a>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._typed-racket/base-env/prims..rkt)._index~3f))"></a><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28def._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._index~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">index?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">any/c</span></td></tr></table></blockquote></div><div class="SIntrapara">A predicate for the <span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Index%29%29" class="RktStxLink" data-pltdoc="x">Index</a></span>
type.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._typed-racket/base-env/prims..rkt)._typecheck-fail))"></a><span title="Provided from: typed/racket/base, typed/racket | Package: typed-racket-lib"><span class="RktSym"><a href="#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">typecheck-fail</a></span></span><span class="hspace"> </span><span class="RktVar">orig-stx</span><span class="hspace"> </span><span class="RktVar">maybe-msg</span><span class="hspace"> </span><span class="RktVar">maybe-id</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">maybe-msg</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td></td></tr></table></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">msg-string</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">maybe-id</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td></td></tr></table></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:covered-id</span><span class="hspace"> </span><span class="RktVar">id</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Explicitly produce a type error, with the source location or
<span class="RktVar">orig-stx</span>. If <span class="RktVar">msg-string</span> is present, it must be a literal string, it is used as
the error message, otherwise the error message
<span class="RktVal">"Incomplete case coverage"</span> is used.
If <span class="RktVar">id</span> is present and has
type <span class="RktSym">T</span>, then the message <span class="RktVal">"missing coverage of T"</span> is added to
the error message.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">cond*</span><span class="hspace"> </span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._syntax-case%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">syntax-case</a></span><span class="hspace"> </span><span class="RktSym">stx</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529.__%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">_</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">clause</span><span class="hspace"> </span><span class="RktMeta"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._......%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">...</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktRdr">#`</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">cond</a></span><span class="hspace"> </span><span class="RktSym">clause</span><span class="hspace"> </span><span class="RktMeta"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._......%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">...</a></span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._else%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">else</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._typecheck-fail%29%29" class="RktStxLink" data-pltdoc="x">typecheck-fail</a></span><span class="hspace"> </span><span class="RktRdr">#,</span><span class="RktSym">stx</span><span class="hspace"> </span><span class="RktVal">"incomplete coverage"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:covered-id</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</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><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="Legacy_Forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define~3a%29%29" class="RktStxLink" data-pltdoc="x">define:</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29" class="RktStxLink" data-pltdoc="x">U</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.String%29%29" class="RktStxLink" data-pltdoc="x">String</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Boolean%29%29" class="RktStxLink" data-pltdoc="x">Boolean</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">cond*</span><span class="hspace"> </span><span class="RktSym">x</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</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:10:0: Type Checker: incomplete coverage; missing</span></p></td></tr><tr><td><p><span class="RktErr">coverage of Negative-Integer</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">in: #f</span></p></td></tr></table></blockquote></td></tr></table></p><h4 x-source-module="(lib "typed-racket/scribblings/ts-reference.scrbl")" x-part-tag=""Untyped_Utilities"">5.1<tt> </tt><a name="(part._.Untyped_.Utilities)"></a><a name="(mod-path._typed/untyped-utils)"></a>Untyped Utilities</h4><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left" colspan="2"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="#%28mod-path._typed%2Funtyped-utils%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">typed/untyped-utils</span></a><span class="RktPn">)</span></td></tr><tr><td align="left"> </td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">typed-racket-more</span></span></td></tr></table></p><p>These utilities help interface typed with untyped code, particularly typed
libraries that use types that cannot be converted into contracts, or export
syntax transformers that must expand differently in typed and untyped contexts.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._typed/untyped-utils..rkt)._require/untyped-contract))"></a><span title="Provided from: typed/untyped-utils | Package: typed-racket-more"><span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">require/untyped-contract</a></span></span><span class="hspace"> </span><span class="RktVar">maybe-begin</span><span class="hspace"> </span><span class="RktVar">module</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">name</span><span class="hspace"> </span><span class="RktVar">subtype</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">maybe-begin</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td></td></tr></table></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">begin</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Use this form to import typed identifiers whose types cannot be converted into
contracts, but have <span style="font-style: italic">subtypes</span> that can be converted into contracts.</div></p><p><div class="SIntrapara">For example, suppose we define and provide the Typed Racket function
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._case-~3e%29%29" class="RktStxLink" data-pltdoc="x">case-></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Index%29%29" class="RktStxLink" data-pltdoc="x">Index</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Fixnum%29%29" class="RktStxLink" data-pltdoc="x">Fixnum</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._-%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x"><span class="nobreak">-</span></a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Trying to use <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span> within an untyped module will raise an error
because the cases cannot be distinguished by arity alone.</div></p><p><div class="SIntrapara">If the defining module for <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span> is <span class="RktVal">"my-numerics.rkt"</span>,
it can be imported and used in untyped code this way:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">"my-numerics.rkt"</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">The type <span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="RktPn">)</span> is converted into the contract used
for <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528lib._racket%252Ffunction..rkt%2529._negate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">negate</a></span>.</div></p><p><div class="SIntrapara">The <span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span> form expands into a submodule
with language <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">typed/racket/base</span></a>. Identifiers used in
<span class="RktVar">subtype</span> expressions must be either in Typed Racket’s base type
environment (e.g. <span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span> and <span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span>) or defined by an
expression in the <span class="RktVar">maybe-begin</span> form, which is spliced into the
submodule. For example, the <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?tag=%28mod-path._.%27math%2Fmatrix.%27%29&version=6.1" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">math/matrix</span></a> module imports and
reexports <span class="RktSym">matrix-expt</span>, which has a <span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._case-~3e%29%29" class="RktStxLink" data-pltdoc="x">case-></a></span> type,
for untyped use in this way:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._provide%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">provide</a></span><span class="hspace"> </span><span class="RktSym">matrix-expt</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">begin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace"> </span><span class="RktVal">"private/matrix/matrix-types.rkt"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">"private/matrix/matrix-expt.rkt"</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">matrix-expt</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">Matrix</span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Number%29%29" class="RktStxLink" data-pltdoc="x">Number</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29" class="RktStxLink" data-pltdoc="x">Integer</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">Matrix</span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Number%29%29" class="RktStxLink" data-pltdoc="x">Number</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">The <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><span class="RktVal">"private/matrix/matrix-types.rkt"</span><span class="RktPn">)</span> expression imports the
<span class="RktSym">Matrix</span> type.</div></p><p>If an identifier <span class="RktVar">name</span> is imported using <span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span>,
reexported, and imported into typed code, it has its original type, not
<span class="RktVar">subtype</span>. In other words, <span class="RktVar">subtype</span> is used only to generate
a contract for <span class="RktVar">name</span>, not to narrow its type.</p><p>Because of limitations in the macro expander, <span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span>
cannot currently be used in typed code.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._typed/untyped-utils..rkt)._define-typed/untyped-identifier))"></a><span title="Provided from: typed/untyped-utils | Package: typed-racket-more"><span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._define-typed%2Funtyped-identifier%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-typed/untyped-identifier</a></span></span><span class="hspace"> </span><span class="RktVar">name</span><span class="hspace"> </span><span class="RktVar">typed-name</span><span class="hspace"> </span><span class="RktVar">untyped-name</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Defines an identifier <span class="RktVar">name</span> that expands to <span class="RktVar">typed-name</span> in typed
contexts and to <span class="RktVar">untyped-name</span> in untyped contexts. Each subform must be
an identifier.</div></p><p><div class="SIntrapara">Suppose we define and provide a Typed Racket function with this type:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktSym">my-filter</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29" class="RktStxLink" data-pltdoc="x">All</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="hspace"> </span><span class="RktSym"><a href="special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" class="RktStxLink" data-pltdoc="x">:</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="hspace"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">This type cannot be converted into a contract because it accepts a predicate.
Worse, <span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span> does not help because
<span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29" class="RktStxLink" data-pltdoc="x">All</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="stt"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span> is not a subtype.</div></p><p><div class="SIntrapara">In this case, we might still provide <span class="RktSym">my-filter</span> to untyped code using
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._provide%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">provide</a></span><span class="hspace"> </span><span class="RktSym">my-filter</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._define-typed%2Funtyped-identifier%29%29" class="RktStxLink" data-pltdoc="x">define-typed/untyped-identifier</a></span><span class="hspace"> </span><span class="RktSym">my-filter</span></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">typed:my-filter</span></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">untyped:my-filter</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">where <span class="RktSym">typed:my-filter</span> is the original <span class="RktSym">my-filter</span>, but imported
using <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._prefix-in%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">prefix-in</a></span>, and <span class="RktSym">untyped:my-filter</span> is either a Typed Racket
implementation of it with type <span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29" class="RktStxLink" data-pltdoc="x">All</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="stt"> </span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29" class="RktStxLink" data-pltdoc="x">Any</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29" class="RktStxLink" data-pltdoc="x">Listof</a></span><span class="stt"> </span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span>
or an untyped Racket implementation.</div></p><p>Avoid this if possible. Use only in cases where a type has no subtype that can
be converted to a contract; i.e. cases in which <span class="RktSym"><a href="#%28form._%28%28lib._typed%2Funtyped-utils..rkt%29._require%2Funtyped-contract%29%29" class="RktStxLink" data-pltdoc="x">require/untyped-contract</a></span>
cannot be used.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._typed/untyped-utils..rkt)._syntax-local-typed-context~3f))"></a><span title="Provided from: typed/untyped-utils | Package: typed-racket-more"><span class="RktSym"><a href="#%28def._%28%28lib._typed%2Funtyped-utils..rkt%29._syntax-local-typed-context~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-local-typed-context?</a></span></span><span class="RktPn"></span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if called while expanding code in a typed context; otherwise
<span class="RktVal">#f</span>.</div></p><p>This is the nuclear option, provided because it is sometimes, but rarely, useful.
Avoid.</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, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="Typed_Classes.html" title="backward to "4 Typed Classes"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "The Typed Racket Reference"" data-pltdoc="x">up</a> <a href="Exploring_Types.html" title="forward to "6 Exploring Types"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|