<html><head><metahttp-equiv="content-type"content="text/html; charset=utf-8"/><title>2 Coercion</title><linkrel="stylesheet"type="text/css"href="scribble.css"title="default"/><linkrel="stylesheet"type="text/css"href="racket.css"title="default"/><linkrel="stylesheet"type="text/css"href="manual-style.css"title="default"/><linkrel="stylesheet"type="text/css"href="manual-racket.css"title="default"/><scripttype="text/javascript"src="scribble-common.js"></script><scripttype="text/javascript"src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><bodyid="scribble-racket-lang-org"><divclass="tocset"><divclass="tocview"><divclass="tocviewlist tocviewlisttopspace"><divclass="tocviewtitle"><tablecellspacing="0"cellpadding="0"><tr><tdstyle="width: 1em;"><ahref="javascript:void(0);"title="Expand/Collapse"class="tocviewtoggle"onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><ahref="index.html"class="tocviewlink"data-pltdoc="x">Sugar:<spanclass="mywbr"> </span> readability & convenience library</a></td></tr></table></div><divclass="tocviewsublisttop"style="display: block;"id="tocview_0"><tablecellspacing="0"cellpadding="0"><tr><tdalign="right">1 </td><td><ahref="Installation___updates.html"class="tocviewlink"data-pltdoc="x">Installation & updates</a></td></tr><tr><tdalign="right">2 </td><td><ahref="Coercion.html"class="tocviewselflink"data-pltdoc="x">Coercion</a></td></tr><tr><tdalign="right">3 </td><td><ahref="Container.html"class="tocviewlink"data-pltdoc="x">Container</a></td></tr><tr><tdalign="right">4 </td><td><ahref="Len.html"class="tocviewlink"data-pltdoc="x">Len</a></td></tr><tr><tdalign="right">5 </td><td><ahref="License___source_code.html"class="tocviewlink"data-pltdoc="x">License & source code</a></td></tr><tr><tdalign="right"></td><td><ahref="doc-index.html"class="tocviewlink"data-pltdoc="x">Index</a></td></tr></table></div></div><divclass="tocviewlist"><tablecellspacing="0"cellpadding="0"><tr><tdstyle="width: 1em;"><ahref="javascript:void(0);"title="Expand/Collapse"class="tocviewtoggle"onclick="TocviewToggle(this,"tocview_1");">►</a></td><td>2 </td><td><ahref="Coercion.html"class="tocviewselflink"data-pltdoc="x">Coercion</a></td></tr></table><divclass="tocviewsublistbottom"style="display: none;"id="tocview_1"><tablecellspacing="0"cellpadding="0"><tr><tdalign="right">2.1 </td><td><ahref="Coercion.html#%28part._.Values%29"class="tocviewlink"data-pltdoc="x">Values</a></td></tr><tr><tdalign="right">2.2 </td><td><ahref="Coercion.html#%28part._.Coercion_contracts%29"class="tocviewlink"data-pltdoc="x">Coercion contracts</a></td></tr></table></div></div></div><divclass="tocsub"><divclass="tocsubtitle">On this page:</div><tableclass="tocsublist"cellspacing="0"><tr><td><spanclass="tocsublinknumber">2.1<tt> </tt></span><ahref="#%28part._.Values%29"class="tocsubseclink"data-pltdoc="x">Values</a></td></tr><tr><td><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="tocsubnonseclink"data-pltdoc="x"><spanclass="RktSym"><spanclass="RktValLink"><spanclass="nobreak">-<wbr></wbr>></span>int</span></span></a></td></tr><tr><td><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="tocsubnonseclink"data-pltdoc="x"><spanclass="RktSym"><spanclass="RktValLink"><spanclass="nobreak">-<wbr></wbr>></span>string</span></span></a></td></tr><tr><td><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29"class="tocsubnonseclink"data-pltdoc="x"><spanclass="RktSym"><spanclass="RktValLink"><spanclass="nobreak">-<wbr></wbr>></span>symbol</span></span></a></td></tr><tr><td><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3epath%29%29"class="tocsubnonseclink"data-pltdoc="x"><spanclass="RktSym"><spanclass="RktValLink"><spanclass="nobreak">-<wbr></wbr>></span>path</span></span></a></td>
</div><divclass="SIntrapara"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>int</a></span><spanclass="hspace"> </span><spanclass="RktVal">#t</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktErr">Can’t convert #t to integer</span></p></td></tr></table></blockquote></td></tr></table></div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"cellpadding="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._sugar/coerce..rkt)._-~3estring))"></a><spantitle="Provided from: sugar/coerce | Package: sugar"><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValDef RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span></span><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29"class="RktValLink"data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29"class="RktValLink"data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><divclass="SIntrapara">Return the most natural string representation of <spanclass="RktVar">v</span>, or raise an error if none exists.</div></p><p><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">"string"</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"string"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">symbol</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"symbol"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">98.6</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"98.6"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><a