CINXE.COM
role IO | Raku Documentation
<!DOCTYPE html> <html lang="en" class="fontawesome-i2svg-active fontawesome-i2svg-complete" style="scroll-padding-top:60px"> <head> <title>role IO | Raku Documentation</title> <meta charset="UTF-8" /> <link href="/assets/images/Camelia.ico" rel="icon" type="image/x-icon"/> <link rel="stylesheet" href="/assets/css/Website.css"/> <link rel="stylesheet" href="/assets/css/typegraph-styling.css"/> <link rel="stylesheet" href="/assets/css/typegraph-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/typegraph-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/announce-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/announce-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/all.min.css"/> <link rel="stylesheet" href="/assets/css/listf-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/listf-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/options-search-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/options-search-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/page-styling-main.css"/> <link rel="stylesheet" href="/assets/css/css/page-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/page-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/tm-styling.css"/> <link rel="stylesheet" href="/assets/css/tm-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/tm-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/rainbow-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/rainbow-light.css" title="light"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/css/autoComplete.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-light.min.css" title="light" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css" title="dark" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="/assets/scripts/all.min.js"></script><script src="/assets/scripts/filter-script.js"></script><script src="/assets/scripts/tableManager.js"></script><script src="https://cdn.jsdelivr.net/npm/fuzzysort@2.0.4/fuzzysort.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"></script><script src="/assets/scripts/filtered-toc.js"></script><script src="/assets/scripts/options-search.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/haskell.min.js"></script><script src="/assets/scripts/page-styling.js"></script><script src="/assets/scripts/announcements.js"></script><script src="/assets/scripts/rainbow.js"></script> </head> <body class="has-navbar-fixed-top"> <div id="role_IO" class="top-of-page"></div> <nav class="navbar is-fixed-top is-flex-touch" role="navigation" aria-label="main navigation"> <div class="navbar-item" style="margin-left: auto;"> <div class="left-bar-toggle" title="Toggle Table of Contents & Index"> <label class="chyronToggle left"> <input id="navbar-left-toggle" type="checkbox"> <span class="text">Contents</span> </label> </div> </div> <div class="container is-justify-content-space-around"> <div class="navbar-brand"> <div class="navbar-logo"> <a class="navbar-item" href="/"> <img src="/assets/images/camelia-recoloured.png" alt="Raku" width="52.83" height="38"> </a> <span class="navbar-logo-tm">tm</span> </div> <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navMenu"> <span aria-hidden="true"></span> <span aria-hidden="true"></span> <span aria-hidden="true"></span> </a> </div> <div id="navMenu" class="navbar-menu"> <div class="navbar-start"> <a class="navbar-item" href="/introduction" title="Getting started, Tutorials, Migration guides"> Introduction </a> <a class="navbar-item" href="/reference" title="Fundamentals, General reference"> Reference </a> <a class="navbar-item" href="/miscellaneous" title="Programs, Experimental"> Miscellaneous </a> <a class="navbar-item" href="/types" title="The core types (classes) available"> Types </a> <a class="navbar-item" href="/routines" title="Searchable table of routines"> Routines </a> <a class="navbar-item" href="https://raku.org" title="Home page for community"> Raku<sup>庐</sup> </a> <a class="navbar-item" href="https://web.libera.chat/#raku" title="IRC live chat"> Chat </a> <div class="navbar-item has-dropdown is-hoverable"> <a class="navbar-link"> More </a> <div class="navbar-dropdown is-right is-rounded"> <hr class="navbar-divider"> <a class="navbar-item js-modal-trigger" data-target="download-ebook"> Download E-Book (epub) </a> <hr class="navbar-divider"> <a class="navbar-item" href="/about"> About </a> <hr class="navbar-divider"> <a class="navbar-item has-text-red" href="https://github.com/raku/doc-website/issues"> Report an issue with this site </a> <hr class="navbar-divider"> <a class="navbar-item" href="https://github.com/raku/doc/issues"> Report an issue with the documentation content </a> <hr class="navbar-divider"> <label class="navbar-item centreToggle" title="Enable/Disable Announcements" style="--switch-width: 18"> <input id="cancelAnnouncements" type="checkbox"> <span class="text">Announcements</span> <span class="on">suppressed</span> <span class="off">allowed</span> </label> </div> </div> </div> <div class="navbar-end navbar-search-wrapper"> <div class="navbar-item"> <div class="field has-addons"> <div class="autoComplete_options"> <input class="control input" id="autoComplete" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off" placeholder="馃攳 Type f to search for ..."> </div> <div class="control" title="Search options"> <a class="button is-primary js-modal-trigger" data-target="options-search-info"> <span class="icon"> <i class="fas fa-cogs"></i> </span> </a> </div> </div> </div> </div> <div id="options-search-info" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p>The last search was: <span id="selected-candidate" class="ss-selected"></span></p> <div class="control is-grouped is-grouped-centered options-search-controls"> <label class="centreToggle" title="Include extra information (Alt-E)" style="--switch-width: 10.5"> <input id="options-search-extra" type="checkbox"> <span class="text">Extra info</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>The search response can be shortened by excluding the extra information line (Alt-E)</p> <label class="centreToggle" title="Search engine type Strict/Loose (Alt-L)" style="--switch-width: 10.5"> <input id="options-search-loose" type="checkbox"> <span class="text">Search type</span> <span class="on">loose</span> <span class="off">strict</span> </label> <p> The search engine can perform a strict search (only the characters in the search box) or a loose search (Alt-L)</p> <label class="centreToggle" title="Search in headings (Alt-H)" style="--switch-width: 10.5"> <input id="options-search-headings" type="checkbox"> <span class="text">Headings</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through headings in all web-pages (Alt-H)</p> <label class="centreToggle" title="Search indexed items (Alt-I)" style="--switch-width: 10.5"> <input id="options-search-indexed" type="checkbox"> <span class="text">Indexed</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through all indexed items (Alt-I)</p> <label class="centreToggle" title="Search composite pages (Alt-C)" style="--switch-width: 10.5"> <input id="options-search-composite" type="checkbox"> <span class="text">Composite</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search in the names of composite pages, which combine similar information from the main web pages (Alt-C)</p> <label class="centreToggle" title="Search primary sources (Alt-P)" style="--switch-width: 10.5"> <input id="options-search-primary" type="checkbox"> <span class="text">Primary</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through the names of the main web pages (Alt-P)</p> <label class="centreToggle" title="Open in new tab (Alt-Q)" style="--switch-width: 10.5"> <input id="options-search-newtab" type="checkbox"> <span class="text">New tab</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Once a search candidate has been chosen, it can be opened in a new tab or in the current tab (Alt-Q)</p> <p>If all else fails, an item is added to use the Google search engine on the whole site</p> <button class="button is-warning" id="options-search-reset-defaults">Clear options, reset to defaults</button> <p>Exit this page by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> <div id="download-ebook" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p><a href="/RakuDocumentation.epub" download>RakuDocumentation.epub</a> is a work in progress e-book. It targets the <a href="https://www.w3.org/publishing/epub3/">EPUB v3 specification</a>. It needs testing on a variety of ereaders (some of which may still implicitly expect compliance with EPUB v2). The CSS definitely needs enhancing (especially for code snippets). The Ebook opens in a Calibre reader, which is available on all operating systems.</p> <p>Suggestions are welcome and should be addressed by opening an issue on the Raku/doc-website repository</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> <div id="announcement-modal" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <div id="raku-doc-announcement"></div> <p>For more see <a href="/announcements">Announcements page</a>.</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> </nav> <div class="tile is-ancestor section"> <div class="page-edit"> <a class="button page-edit-button" href="https://github.com/Raku/doc/edit/main/doc/Type/IO.rakudoc" title="Edit this page. Commit: e9ec299ce 2024-05-18"> <span class="icon is-right"> <i class="fas fa-pen-alt is-medium"></i> </span> </a> </div> <div id="left-column" class="tile is-parent is-2 is-hidden"> <div id="left-col-inner"> <input type="checkbox" id="No-TOC" checked="checked" style="visibility: collapse;"> </input> <div class="content">No Table of Contents or Index available</div> </div> </div> <div id="main-column" class="tile is-parent" style="overflow-x: hidden;"> <div id="main-col-inner"> <section class="raku page-header"> <div class="container px-4"> <div class="raku page-title has-text-centered"> role IO </div> <div class="raku page-subtitle has-text-centered"> <p>Input/output related routines</p> </div> </div> </section> <section class="raku page-content"><div class="container px-4"><div class="columns one-col"><p>The role provides no methods, but exists so that <code>IO()</code> coercers, which coerce to <a href="/type/IO/Path"><code>IO::Path</code></a>, correctly type-check the resultant value. The role is implemented by <a href="/type/IO/Path"><code>IO::Path</code></a> and <a href="/type/IO/Special"><code>IO::Special</code></a>.</p><p>See also the related classes <a href="/type/IO/Handle"><code>IO::Handle</code></a> and <a href="/type/IO/Path"><code>IO::Path</code></a>.</p> <h1 id="typegraphrelations" class="raku-h1"><a href="#" title="go to top of document">Typegraph<a class="raku-anchor" title="direct link" href="#typegraphrelations">搂</a></a></h1> <figure class="typegraph" > <figcaption>Type relations for <code>IO</code></figcaption> <svg width="682pt" height="332pt" viewBox="0.00 0.00 682.29 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)"> <title>raku-type-graph</title> <polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-328 678.29,-328 678.29,4 -4,4"/> <!-- IO --> <g id="node1" class="node"> <title>IO</title> <g id="a_node1"><a xlink:href="/type/IO" xlink:title="IO"> <ellipse fill="none" stroke="#6666ff" cx="280.14" cy="-162" rx="27" ry="18"/> <text text-anchor="middle" x="280.14" y="-158.3" font-family="FreeSans" font-size="14.00" fill="#6666ff">IO</text> </a> </g> </g> <!-- Mu --> <g id="node2" class="node"> <title>Mu</title> <g id="a_node2"><a xlink:href="/type/Mu" xlink:title="Mu"> <ellipse fill="none" stroke="#000000" cx="290.14" cy="-306" rx="27" ry="18"/> <text text-anchor="middle" x="290.14" y="-302.3" font-family="FreeSans" font-size="14.00" fill="#000000">Mu</text> </a> </g> </g> <!-- Any --> <g id="node3" class="node"> <title>Any</title> <g id="a_node3"><a xlink:href="/type/Any" xlink:title="Any"> <ellipse fill="none" stroke="#000000" cx="290.14" cy="-234" rx="28.7" ry="18"/> <text text-anchor="middle" x="290.14" y="-230.3" font-family="FreeSans" font-size="14.00" fill="#000000">Any</text> </a> </g> </g> <!-- Any->Mu --> <g id="edge1" class="edge"> <title>Any->Mu</title> <path fill="none" stroke="#000000" d="M290.14,-252.3C290.14,-260.02 290.14,-269.29 290.14,-277.89"/> <polygon fill="#000000" stroke="#000000" points="286.64,-277.9 290.14,-287.9 293.64,-277.9 286.64,-277.9"/> </g> <!-- Cool --> <g id="node4" class="node"> <title>Cool</title> <g id="a_node4"><a xlink:href="/type/Cool" xlink:title="Cool"> <ellipse fill="none" stroke="#000000" cx="356.14" cy="-162" rx="30.59" ry="18"/> <text text-anchor="middle" x="356.14" y="-158.3" font-family="FreeSans" font-size="14.00" fill="#000000">Cool</text> </a> </g> </g> <!-- Cool->Any --> <g id="edge2" class="edge"> <title>Cool->Any</title> <path fill="none" stroke="#000000" d="M341.82,-178.19C332.91,-187.64 321.3,-199.96 311.33,-210.52"/> <polygon fill="#000000" stroke="#000000" points="308.75,-208.16 304.44,-217.84 313.84,-212.97 308.75,-208.16"/> </g> <!-- IO::Path --> <g id="node5" class="node"> <title>IO::Path</title> <g id="a_node5"><a xlink:href="/type/IO::Path" xlink:title="IO::Path"> <ellipse fill="none" stroke="#000000" cx="354.14" cy="-90" rx="46.29" ry="18"/> <text text-anchor="middle" x="354.14" y="-86.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Path</text> </a> </g> </g> <!-- IO::Path->IO --> <g id="edge9" class="edge"> <title>IO::Path->IO</title> <path fill="none" stroke="#6666ff" d="M337.35,-106.88C327.1,-116.59 313.85,-129.11 302.69,-139.67"/> <polygon fill="#6666ff" stroke="#6666ff" points="300.22,-137.19 295.36,-146.61 305.03,-142.28 300.22,-137.19"/> </g> <!-- IO::Path->Cool --> <g id="edge3" class="edge"> <title>IO::Path->Cool</title> <path fill="none" stroke="#000000" d="M354.64,-108.3C354.86,-116.02 355.12,-125.29 355.37,-133.89"/> <polygon fill="#000000" stroke="#000000" points="351.87,-134 355.65,-143.9 358.87,-133.8 351.87,-134"/> </g> <!-- IO::Special --> <g id="node6" class="node"> <title>IO::Special</title> <g id="a_node6"><a xlink:href="/type/IO::Special" xlink:title="IO::Special"> <ellipse fill="none" stroke="#000000" cx="229.14" cy="-90" rx="58.49" ry="18"/> <text text-anchor="middle" x="229.14" y="-86.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Special</text> </a> </g> </g> <!-- IO::Special->IO --> <g id="edge10" class="edge"> <title>IO::Special->IO</title> <path fill="none" stroke="#6666ff" d="M241.49,-107.95C247.81,-116.62 255.61,-127.33 262.55,-136.85"/> <polygon fill="#6666ff" stroke="#6666ff" points="259.89,-139.15 268.61,-145.17 265.55,-135.03 259.89,-139.15"/> </g> <!-- IO::Special->Any --> <g id="edge4" class="edge"> <title>IO::Special->Any</title> <path fill="none" stroke="#000000" d="M232.03,-108.16C236.39,-134.02 244.14,-180 244.14,-180 244.14,-180 257.91,-195.86 270.38,-210.23"/> <polygon fill="#000000" stroke="#000000" points="267.89,-212.7 277.08,-217.95 273.17,-208.11 267.89,-212.7"/> </g> <!-- IO::Path::Cygwin --> <g id="node7" class="node"> <title>IO::Path::Cygwin</title> <g id="a_node7"><a xlink:href="/type/IO::Path::Cygwin" xlink:title="IO::Path::Cygwin"> <ellipse fill="none" stroke="#000000" cx="85.14" cy="-18" rx="85.29" ry="18"/> <text text-anchor="middle" x="85.14" y="-14.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Path::Cygwin</text> </a> </g> </g> <!-- IO::Path::Cygwin->IO::Path --> <g id="edge5" class="edge"> <title>IO::Path::Cygwin->IO::Path</title> <path fill="none" stroke="#000000" d="M137.84,-32.24C200.34,-47.94 296.14,-72 296.14,-72 296.14,-72 301.25,-73.5 308.43,-75.6"/> <polygon fill="#000000" stroke="#000000" points="307.82,-79.07 318.4,-78.52 309.79,-72.35 307.82,-79.07"/> </g> <!-- IO::Path::Win32 --> <g id="node8" class="node"> <title>IO::Path::Win32</title> <g id="a_node8"><a xlink:href="/type/IO::Path::Win32" xlink:title="IO::Path::Win32"> <ellipse fill="none" stroke="#000000" cx="269.14" cy="-18" rx="80.69" ry="18"/> <text text-anchor="middle" x="269.14" y="-14.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Path::Win32</text> </a> </g> </g> <!-- IO::Path::Win32->IO::Path --> <g id="edge6" class="edge"> <title>IO::Path::Win32->IO::Path</title> <path fill="none" stroke="#000000" d="M289.29,-35.59C300.72,-45.01 315.18,-56.91 327.54,-67.09"/> <polygon fill="#000000" stroke="#000000" points="325.36,-69.83 335.31,-73.49 329.81,-64.43 325.36,-69.83"/> </g> <!-- IO::Path::QNX --> <g id="node9" class="node"> <title>IO::Path::QNX</title> <g id="a_node9"><a xlink:href="/type/IO::Path::QNX" xlink:title="IO::Path::QNX"> <ellipse fill="none" stroke="#000000" cx="440.14" cy="-18" rx="72.29" ry="18"/> <text text-anchor="middle" x="440.14" y="-14.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Path::QNX</text> </a> </g> </g> <!-- IO::Path::QNX->IO::Path --> <g id="edge7" class="edge"> <title>IO::Path::QNX->IO::Path</title> <path fill="none" stroke="#000000" d="M419.76,-35.59C408.19,-45.01 393.56,-56.91 381.06,-67.09"/> <polygon fill="#000000" stroke="#000000" points="378.74,-64.46 373.2,-73.49 383.16,-69.89 378.74,-64.46"/> </g> <!-- IO::Path::Unix --> <g id="node10" class="node"> <title>IO::Path::Unix</title> <g id="a_node10"><a xlink:href="/type/IO::Path::Unix" xlink:title="IO::Path::Unix"> <ellipse fill="none" stroke="#000000" cx="602.14" cy="-18" rx="72.29" ry="18"/> <text text-anchor="middle" x="602.14" y="-14.3" font-family="FreeSans" font-size="14.00" fill="#000000">IO::Path::Unix</text> </a> </g> </g> <!-- IO::Path::Unix->IO::Path --> <g id="edge8" class="edge"> <title>IO::Path::Unix->IO::Path</title> <path fill="none" stroke="#000000" d="M556.37,-31.92C511.87,-44.48 444.65,-63.45 400.09,-76.03"/> <polygon fill="#000000" stroke="#000000" points="399.06,-72.68 390.39,-78.77 400.96,-79.42 399.06,-72.68"/> </g> </g> </svg> <p class="fallback"> <a rel="alternate" href="/assets/typegraphs/IO.svg"> Expand chart above </a></p> </figure> </div></div></section> </div> </div> </div> <footer class="footer main-footer"> <div class="container px-4"> <nav class="level"> <div class="level-left"> <div class="level-item"> <a href="/about">About</a> </div> <div class="level-item"> <a id="toggle-theme">Toggle theme</a> </div> <div class="level-item" title="e9ec299ce 2024-05-18"> <a>Commit</a> </div> </div> <div class="level-right"> <div class="level-item"> <a href="/license">License</a> </div> </div> </nav> </div> </footer> </body> </html>