CINXE.COM
Intersection type - Wikipedia
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Intersection type - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-sticky-header-enabled vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"e2af89b9-07ad-4e8a-b954-3f97f5f3d3b9","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Intersection_type","wgTitle":"Intersection type","wgCurRevisionId":1259099901,"wgRevisionId":1259099901,"wgArticleId":24140211,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description matches Wikidata","Type theory","Type systems","Data types","Composite data types","Polymorphism (computer science)","TypeScript"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Intersection_type","wgRelevantArticleId":24140211,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":30000,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q85769734","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false}; RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.math.styles":"ready","ext.cite.styles":"ready","ext.pygments":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.tablesorter.styles":"ready","jquery.makeCollapsible.styles":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","ext.pygments.view","site","mediawiki.page.ready","jquery.tablesorter","jquery.makeCollapsible","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.math.styles%7Cext.pygments%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.19"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Intersection type - Wikipedia"> <meta property="og:type" content="website"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Intersection_type"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Intersection_type&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Intersection_type"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Intersection_type rootpage-Intersection_type skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" title="Main menu" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li><li id="n-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages"><span>Special pages</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=Intersection+type" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=Intersection+type" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Intersection+type" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Intersection+type" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-TypeScript_example" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#TypeScript_example"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>TypeScript example</span> </div> </a> <button aria-controls="toc-TypeScript_example-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle TypeScript example subsection</span> </button> <ul id="toc-TypeScript_example-sublist" class="vector-toc-list"> <li id="toc-Comparison_to_inheritance" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Comparison_to_inheritance"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1</span> <span>Comparison to inheritance</span> </div> </a> <ul id="toc-Comparison_to_inheritance-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comparison_to_duck_typing" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Comparison_to_duck_typing"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2</span> <span>Comparison to duck typing</span> </div> </a> <ul id="toc-Comparison_to_duck_typing-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comparison_to_function_overloading" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Comparison_to_function_overloading"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3</span> <span>Comparison to function overloading</span> </div> </a> <ul id="toc-Comparison_to_function_overloading-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comparison_to_the_visitor_pattern" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Comparison_to_the_visitor_pattern"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.4</span> <span>Comparison to the visitor pattern</span> </div> </a> <ul id="toc-Comparison_to_the_visitor_pattern-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Limitations" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Limitations"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.5</span> <span>Limitations</span> </div> </a> <ul id="toc-Limitations-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Dependent_intersection_type" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Dependent_intersection_type"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Dependent intersection type</span> </div> </a> <button aria-controls="toc-Dependent_intersection_type-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Dependent intersection type subsection</span> </button> <ul id="toc-Dependent_intersection_type-sublist" class="vector-toc-list"> <li id="toc-Scala_example" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Scala_example"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Scala example</span> </div> </a> <ul id="toc-Scala_example-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Intersection_of_a_type_family" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Intersection_of_a_type_family"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Intersection of a type family</span> </div> </a> <ul id="toc-Intersection_of_a_type_family-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Comparison_of_languages_with_intersection_types" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Comparison_of_languages_with_intersection_types"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Comparison of languages with intersection types</span> </div> </a> <ul id="toc-Comparison_of_languages_with_intersection_types-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" title="Table of Contents" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Intersection type</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="This article exist only in this language. Add the article for other languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-0" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">Add languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> <div class="after-portlet after-portlet-lang"><span class="uls-after-portlet-link"></span><span class="wb-langlinks-add wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q85769734#sitelinks-wikipedia" title="Add interlanguage links" class="wbc-editpage">Add links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Intersection_type" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Intersection_type" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Intersection_type"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Intersection_type&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Intersection_type&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Intersection_type"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Intersection_type&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Intersection_type&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Intersection_type" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Intersection_type" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Intersection_type&oldid=1259099901" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Intersection_type&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=Intersection_type&id=1259099901&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FIntersection_type"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FIntersection_type"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=Intersection_type&action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Intersection_type&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q85769734" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Concept in type theory</div> <style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1246091330">.mw-parser-output .sidebar{width:22em;float:right;clear:right;margin:0.5em 0 1em 1em;background:var(--background-color-neutral-subtle,#f8f9fa);border:1px solid var(--border-color-base,#a2a9b1);padding:0.2em;text-align:center;line-height:1.4em;font-size:88%;border-collapse:collapse;display:table}body.skin-minerva .mw-parser-output .sidebar{display:table!important;float:right!important;margin:0.5em 0 1em 1em!important}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding:0 0.4em 0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding:0.2em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding:0.4em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.8em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding:0.1em 0.4em}.mw-parser-output .sidebar-image{padding:0.2em 0.4em 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em 0.4em}.mw-parser-output .sidebar-content{padding:0 0.5em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0.4em 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.8em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:115%;padding:0 0.4em 0.4em}.mw-parser-output .sidebar-list-title{padding:0 0.4em;text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}.mw-parser-output .sidebar-list-title-c{padding:0 0.4em;text-align:center;margin:0 3.3em}@media(max-width:640px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none!important;margin-left:0!important;margin-right:0!important}}body.skin--responsive .mw-parser-output .sidebar a>img{max-width:none!important}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media print{body.ns-0 .mw-parser-output .sidebar{display:none!important}}</style><table class="sidebar nomobile nowraplinks" style="margin-top: 0.5em;"><tbody><tr><th class="sidebar-title"><a href="/wiki/Type_system" title="Type system">Type systems</a></th></tr><tr><th class="sidebar-heading"> General concepts</th></tr><tr><td class="sidebar-content" style="text-align: left;"> <ul><li><a href="/wiki/Type_safety" title="Type safety">Type safety</a></li> <li><a href="/wiki/Strong_and_weak_typing" title="Strong and weak typing">Strong vs. weak typing</a></li></ul></td> </tr><tr><th class="sidebar-heading"> Major categories</th></tr><tr><td class="sidebar-content" style="text-align: left;"> <ul><li><a href="/wiki/Type_system#Static_type_checking" title="Type system">Static</a> vs. <a href="/wiki/Type_system#Dynamic_type_checking_and_runtime_type_information" title="Type system">dynamic</a></li> <li><a href="/wiki/Manifest_typing" title="Manifest typing">Manifest</a> vs. <a href="/wiki/Type_inference" title="Type inference">inferred</a></li> <li><a href="/wiki/Nominal_type_system" title="Nominal type system">Nominal</a> vs. <a href="/wiki/Structural_type_system" title="Structural type system">structural</a></li> <li><a href="/wiki/Duck_typing" title="Duck typing">Duck typing</a></li></ul></td> </tr><tr><th class="sidebar-heading"> Minor categories</th></tr><tr><td class="sidebar-content" style="text-align: left;"> <ul><li><a href="/wiki/Abstract_type" title="Abstract type">Abstract</a></li> <li><a href="/wiki/Dependent_type" title="Dependent type">Dependent</a></li> <li><a href="/wiki/Flow-sensitive_typing" title="Flow-sensitive typing">Flow-sensitive</a></li> <li><a href="/wiki/Gradual_typing" title="Gradual typing">Gradual</a></li> <li><a class="mw-selflink selflink">Intersection</a></li> <li><a href="/wiki/Latent_typing" title="Latent typing">Latent</a></li> <li><a href="/wiki/Refinement_type" title="Refinement type">Refinement</a></li> <li><a href="/wiki/Substructural_type_system" title="Substructural type system">Substructural</a></li> <li><a href="/wiki/Uniqueness_type" title="Uniqueness type">Unique</a></li> <li><a href="/wiki/Session_type" title="Session type">Session</a></li></ul></td> </tr><tr><td class="sidebar-navbar"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Type_systems" title="Template:Type systems"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Type_systems" title="Template talk:Type systems"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Type_systems" title="Special:EditPage/Template:Type systems"><abbr title="Edit this template">e</abbr></a></li></ul></div></td></tr></tbody></table> <p>In <a href="/wiki/Type_theory" title="Type theory">type theory</a>, an <b>intersection type</b> can be allocated to values that can be assigned both the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle \sigma }" /></span> and the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/38a7dcde9730ef0853809fefc18d88771f95206c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.202ex; height:1.676ex;" alt="{\displaystyle \tau }" /></span>. This value can be given the intersection type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma \cap \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> <mo>∩<!-- ∩ --></mo> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma \cap \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f1b5fbc85a391ea8ded8940802c28265a131830b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.114ex; height:2.009ex;" alt="{\displaystyle \sigma \cap \tau }" /></span> in an <a href="/wiki/Intersection_type_system" class="mw-redirect" title="Intersection type system">intersection type system</a>.<sup id="cite_ref-BCD83_1-0" class="reference"><a href="#cite_note-BCD83-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> Generally, if the ranges of values of two types overlap, then a value belonging to the <i>intersection</i> of the two ranges can be assigned the <i>intersection type</i> of these two types. Such a value can be safely passed as argument to functions expecting <i>either</i> of the two types. For example, in <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> the class <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Boolean</code> implements both the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Serializable</code> and the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Comparable</code> interfaces. Therefore, an object of type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Boolean</code> can be safely passed to functions expecting an argument of type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Serializable</code> and to functions expecting an argument of type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Comparable</code>. </p><p>Intersection types are <a href="/wiki/Composite_data_type" title="Composite data type">composite data types</a>. Similar to <a href="/wiki/Product_type" title="Product type">product types</a>, they are used to assign several types to an object. However, product types are assigned to <a href="/wiki/Tuple" title="Tuple">tuples</a>, so that each tuple element is assigned a particular product type component. In comparison, underlying objects of intersection types are not necessarily composite. A restricted form of intersection types are <a href="/wiki/Refinement_type" title="Refinement type">refinement types</a>. </p><p>Intersection types are useful for describing <a href="/wiki/Function_overloading" title="Function overloading">overloaded functions</a>.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> For example, if <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="kt">number</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="kt">number</span></code> is the type of function taking a number as an argument and returning a number, and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="kt">string</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="kt">string</span></code> is the type of function taking a string as an argument and returning a string, then the intersection of these two types can be used to describe (overloaded) functions that do one or the other, based on what type of input they are given. </p><p>Contemporary programming languages, including <a href="/wiki/Ceylon_(programming_language)" title="Ceylon (programming language)">Ceylon</a>, Flow, <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, <a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a>, <a href="/wiki/Microsoft_TypeScript" class="mw-redirect" title="Microsoft TypeScript">TypeScript</a>, and <a href="/wiki/Whiley_(programming_language)" title="Whiley (programming language)">Whiley</a> (see <a href="#Comparison_of_languages_with_intersection_types">comparison of languages with intersection types</a>), use intersection types to combine interface specifications and to express <a href="/wiki/Ad_hoc_polymorphism" title="Ad hoc polymorphism">ad hoc polymorphism</a>. Complementing <a href="/wiki/Parametric_polymorphism" title="Parametric polymorphism">parametric polymorphism</a>, intersection types may be used to avoid class hierarchy pollution from <a href="/wiki/Cross-cutting_concern" title="Cross-cutting concern">cross-cutting concerns</a> and reduce <a href="/wiki/Boilerplate_code" title="Boilerplate code">boilerplate code</a>, as shown in the <a href="#TypeScript_example">TypeScript example</a> below. </p><p>The <a href="/wiki/Type_theory" title="Type theory">type theoretic</a> study of intersection types is referred to as the <a href="/wiki/Intersection_type_discipline" title="Intersection type discipline">intersection type discipline</a>.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> Remarkably, program termination can be precisely characterized using intersection types.<sup id="cite_ref-G96_4-0" class="reference"><a href="#cite_note-G96-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="TypeScript_example">TypeScript example</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=1" title="Edit section: TypeScript example"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/TypeScript" title="TypeScript">TypeScript</a> supports intersection types,<sup id="cite_ref-TS_5-0" class="reference"><a href="#cite_note-TS-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> improving expressiveness of the type system and reducing potential class hierarchy size, demonstrated as follows. </p><p>The following program code defines the classes <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Chicken</span></code>, <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Cow</span></code>, and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">RandomNumberGenerator</span></code> that each have a method <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> returning an object of either type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code>, <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>, or <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="kt">number</span></code>. Additionally, the functions <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">eatEgg</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">drinkMilk</span></code> require arguments of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>, respectively. </p> <div class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">class</span><span class="w"> </span><span class="nx">Egg</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="nx">kind</span><span class="o">:</span><span class="w"> </span><span class="s2">"Egg"</span><span class="w"> </span><span class="p">}</span> <span class="kd">class</span><span class="w"> </span><span class="nx">Milk</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="nx">kind</span><span class="o">:</span><span class="w"> </span><span class="s2">"Milk"</span><span class="w"> </span><span class="p">}</span> <span class="c1">// produces eggs</span> <span class="kd">class</span><span class="w"> </span><span class="nx">Chicken</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">produce</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">Egg</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span> <span class="c1">// produces milk</span> <span class="kd">class</span><span class="w"> </span><span class="nx">Cow</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">produce</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">Milk</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span> <span class="c1">// produces a random number</span> <span class="kd">class</span><span class="w"> </span><span class="nx">RandomNumberGenerator</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">produce</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span> <span class="c1">// requires an egg</span> <span class="kd">function</span><span class="w"> </span><span class="nx">eatEgg</span><span class="p">(</span><span class="nx">egg</span><span class="o">:</span><span class="w"> </span><span class="kt">Egg</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="s2">"I ate an egg."</span><span class="p">;</span> <span class="p">}</span> <span class="c1">// requires milk</span> <span class="kd">function</span><span class="w"> </span><span class="nx">drinkMilk</span><span class="p">(</span><span class="nx">milk</span><span class="o">:</span><span class="w"> </span><span class="kt">Milk</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="s2">"I drank some milk."</span><span class="p">;</span> <span class="p">}</span> </pre></div> <p>The following program code defines the <a href="/wiki/Ad_hoc_polymorphism" title="Ad hoc polymorphism">ad hoc polymorphic</a> function <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> that invokes the member function <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> of the given object <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animal</span></code>. The function <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> has <i>two</i> type annotations, namely <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="p">((</span><span class="nx">_</span><span class="o">:</span><span class="w"> </span><span class="kt">Chicken</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Egg</span><span class="p">)</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="p">((</span><span class="nx">_</span><span class="o">:</span><span class="w"> </span><span class="kt">Cow</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Milk</span><span class="p">)</span></code>, connected via the intersection type constructor <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="o">&</span></code>. Specifically, <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> when applied to an argument of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Chicken</span></code> returns an object of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code>, and when applied to an argument of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Cow</span></code> returns an object of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>. Ideally, <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> should not be applicable to any object having (possibly by chance) a <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method. </p> <div class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><pre><span></span><span class="c1">// given a chicken, produces an egg; given a cow, produces milk</span> <span class="kd">let</span><span class="w"> </span><span class="nx">animalToFood</span><span class="o">:</span><span class="w"> </span><span class="p">((</span><span class="nx">_</span><span class="o">:</span><span class="w"> </span><span class="kt">Chicken</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Egg</span><span class="p">)</span><span class="w"> </span><span class="o">&</span><span class="w"> </span><span class="p">((</span><span class="nx">_</span><span class="o">:</span><span class="w"> </span><span class="kt">Cow</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">Milk</span><span class="p">)</span><span class="w"> </span><span class="o">=</span> <span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">(</span><span class="nx">animal</span><span class="o">:</span><span class="w"> </span><span class="kt">any</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nx">animal</span><span class="p">.</span><span class="nx">produce</span><span class="p">();</span> <span class="w"> </span><span class="p">};</span> </pre></div> <p>Finally, the following program code demonstrates <a href="/wiki/Type_safety" title="Type safety">type safe</a> use of the above definitions. </p> <div class="mw-highlight mw-highlight-lang-typescript mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span></span><span class="linenos" data-line="1"></span><span class="kd">var</span><span class="w"> </span><span class="nx">chicken</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">Chicken</span><span class="p">();</span> <span class="linenos" data-line="2"></span><span class="kd">var</span><span class="w"> </span><span class="nx">cow</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">Cow</span><span class="p">();</span> <span class="linenos" data-line="3"></span><span class="kd">var</span><span class="w"> </span><span class="nx">randomNumberGenerator</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">RandomNumberGenerator</span><span class="p">();</span> <span class="linenos" data-line="4"></span> <span class="linenos" data-line="5"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">chicken</span><span class="p">.</span><span class="nx">produce</span><span class="p">());</span><span class="w"> </span><span class="c1">// Egg { }</span> <span class="linenos" data-line="6"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">cow</span><span class="p">.</span><span class="nx">produce</span><span class="p">());</span><span class="w"> </span><span class="c1">// Milk { }</span> <span class="linenos" data-line="7"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">randomNumberGenerator</span><span class="p">.</span><span class="nx">produce</span><span class="p">());</span><span class="w"> </span><span class="c1">//0.2626353555444987</span> <span class="linenos" data-line="8"></span> <span class="linenos" data-line="9"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">chicken</span><span class="p">));</span><span class="w"> </span><span class="c1">// Egg { }</span> <span class="linenos" data-line="10"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">cow</span><span class="p">));</span><span class="w"> </span><span class="c1">// Milk { }</span> <span class="linenos" data-line="11"></span><span class="c1">//console.log(animalToFood(randomNumberGenerator)); // ERROR: Argument of type 'RandomNumberGenerator' is not assignable to parameter of type 'Cow'</span> <span class="linenos" data-line="12"></span> <span class="linenos" data-line="13"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">eatEgg</span><span class="p">(</span><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">chicken</span><span class="p">)));</span><span class="w"> </span><span class="c1">// I ate an egg.</span> <span class="linenos" data-line="14"></span><span class="c1">//console.log(eatEgg(animalToFood(cow))); // ERROR: Argument of type 'Milk' is not assignable to parameter of type 'Egg'</span> <span class="linenos" data-line="15"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">drinkMilk</span><span class="p">(</span><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">cow</span><span class="p">)));</span><span class="w"> </span><span class="c1">// I drank some milk.</span> <span class="linenos" data-line="16"></span><span class="c1">//console.log(drinkMilk(animalToFood(chicken))); // ERROR: Argument of type 'Egg' is not assignable to parameter of type 'Milk'</span> </pre></div> <p>The above program code has the following properties: </p> <ul><li>Lines 1–3 create objects <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">chicken</span></code>, <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">cow</span></code>, and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">randomNumberGenerator</span></code> of their respective type.</li> <li>Lines 5–7 print for the previously created objects the respective results (provided as comments) when invoking <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code>.</li> <li>Line 9 (resp. 10) demonstrates type safe use of the method <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> applied to <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">chicken</span></code> (resp. <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">cow</span></code>).</li> <li>Line 11, if uncommented, would result in a type error at compile time. Although the <i>implementation</i> of <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> could invoke the <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method of <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">randomNumberGenerator</span></code>, the <i>type annotation</i> of <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> disallows it. This is in accordance with the intended meaning of <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code>.</li> <li>Line 13 (resp. 15) demonstrates that applying <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> to <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">chicken</span></code> (resp. <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">cow</span></code>) results in an object of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code> (resp. <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>).</li> <li>Line 14 (resp. 16) demonstrates that applying <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> to <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">cow</span></code> (resp. <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">chicken</span></code>) does not result in an object of type <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code> (resp. <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>). Therefore, if uncommented, line 14 (resp. 16) would result in a type error at compile time.</li></ul> <div class="mw-heading mw-heading3"><h3 id="Comparison_to_inheritance">Comparison to inheritance</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=2" title="Edit section: Comparison to inheritance"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The above minimalist example can be realized using <a href="/wiki/Inheritance_(object-oriented_programming)" title="Inheritance (object-oriented programming)">inheritance</a>, for instance by deriving the classes <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Chicken</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Cow</span></code> from a base class <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Animal</span></code>. However, in a larger setting, this could be disadvantageous. Introducing new classes into a class hierarchy is not necessarily justified for <a href="/wiki/Cross-cutting_concern" title="Cross-cutting concern">cross-cutting concerns</a>, or maybe outright impossible, for example when using an external library. Imaginably, the above example could be extended with the following classes: </p> <ul><li>a class <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Horse</span></code> that does not have a <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method;</li> <li>a class <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Sheep</span></code> that has a <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method returning <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Wool</span></code>;</li> <li>a class <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Pig</span></code> that has a <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method, which can be used only once, returning <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Meat</span></code>.</li></ul> <p>This may require additional classes (or interfaces) specifying whether a produce method is available, whether the produce method returns food, and whether the produce method can be used repeatedly. Overall, this may pollute the class hierarchy. </p> <div class="mw-heading mw-heading3"><h3 id="Comparison_to_duck_typing">Comparison to duck typing</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=3" title="Edit section: Comparison to duck typing"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The above minimalist example already shows that <a href="/wiki/Duck_typing" title="Duck typing">duck typing</a> is less suited to realize the given scenario. While the class <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">RandomNumberGenerator</span></code> contains a <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">produce</span></code> method, the object <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">randomNumberGenerator</span></code> should not be a valid argument for <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code>. The above example can be realized using duck typing, for instance by introducing a new field <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">argumentForAnimalToFood</span></code> to the classes <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Chicken</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Cow</span></code> signifying that objects of corresponding type are valid arguments for <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code>. However, this would not only increase the size of the respective classes (especially with the introduction of more methods similar to <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code>), but is also a non-local approach with respect to <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code>. </p> <div class="mw-heading mw-heading3"><h3 id="Comparison_to_function_overloading">Comparison to function overloading</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=4" title="Edit section: Comparison to function overloading"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The above example can be realized using <a href="/wiki/Function_overloading" title="Function overloading">function overloading</a>, for instance by implementing two methods <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">animal</span><span class="o">:</span><span class="w"> </span><span class="kt">Chicken</span><span class="p">)</span><span class="o">:</span><span class="w"> </span><span class="nx">Egg</span></code> and <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span><span class="p">(</span><span class="nx">animal</span><span class="o">:</span><span class="w"> </span><span class="kt">Cow</span><span class="p">)</span><span class="o">:</span><span class="w"> </span><span class="nx">Milk</span></code>. In TypeScript, such a solution is almost identical to the provided example. Other programming languages, such as <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, require distinct implementations of the overloaded method. This may lead to either <a href="/wiki/Code_duplication" class="mw-redirect" title="Code duplication">code duplication</a> or <a href="/wiki/Boilerplate_code" title="Boilerplate code">boilerplate code</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Comparison_to_the_visitor_pattern">Comparison to the visitor pattern</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=5" title="Edit section: Comparison to the visitor pattern"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The above example can be realized using the <a href="/wiki/Visitor_pattern" title="Visitor pattern">visitor pattern</a>. It would require each animal class to implement an <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">accept</span></code> method accepting an object implementing the interface <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">AnimalVisitor</span></code> (adding non-local <a href="/wiki/Boilerplate_code" title="Boilerplate code">boilerplate code</a>). The function <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">animalToFood</span></code> would be realized as the <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">visit</span></code> method of an implementation of <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">AnimalVisitor</span></code>. Unfortunately, the connection between the input type (<code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Chicken</span></code> or <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Cow</span></code>) and the result type (<code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Egg</span></code> or <code class="mw-highlight mw-highlight-lang-typescript mw-content-ltr" dir="ltr"><span class="nx">Milk</span></code>) would be difficult to represent. </p> <div class="mw-heading mw-heading3"><h3 id="Limitations">Limitations</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=6" title="Edit section: Limitations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>On the one hand, intersection types <i>can</i> be used to locally annotate different types to a function without introducing new classes (or interfaces) to the class hierarchy. On the other hand, this approach <i>requires</i> all possible argument types and result types to be specified explicitly. If the behavior of a function can be specified precisely by either a unified interface, <a href="/wiki/Parametric_polymorphism" title="Parametric polymorphism">parametric polymorphism</a>, or <a href="/wiki/Duck_typing" title="Duck typing">duck typing</a>, then the verbose nature of intersection types is unfavorable. Therefore, intersection types should be considered complementary to existing specification methods. </p> <div class="mw-heading mw-heading2"><h2 id="Dependent_intersection_type">Dependent intersection type</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=7" title="Edit section: Dependent intersection type"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A <b>dependent intersection type</b>, denoted <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x:\sigma )\cap \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>x</mi> <mo>:</mo> <mi>σ<!-- σ --></mi> <mo stretchy="false">)</mo> <mo>∩<!-- ∩ --></mo> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (x:\sigma )\cap \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1d1582886a9278c7fc635dac09779d9546f7a372" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.19ex; height:2.843ex;" alt="{\displaystyle (x:\sigma )\cap \tau }" /></span>, is a <a href="/wiki/Dependent_type" title="Dependent type">dependent type</a> in which the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/38a7dcde9730ef0853809fefc18d88771f95206c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.202ex; height:1.676ex;" alt="{\displaystyle \tau }" /></span> may depend on the term variable <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>x</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle x}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" /></span>.<sup id="cite_ref-K03_6-0" class="reference"><a href="#cite_note-K03-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> In particular, if a term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>M</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f82cade9898ced02fdd08712e5f0c0151758a0dd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.442ex; height:2.176ex;" alt="{\displaystyle M}" /></span> has the dependent intersection type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x:\sigma )\cap \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>x</mi> <mo>:</mo> <mi>σ<!-- σ --></mi> <mo stretchy="false">)</mo> <mo>∩<!-- ∩ --></mo> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (x:\sigma )\cap \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1d1582886a9278c7fc635dac09779d9546f7a372" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.19ex; height:2.843ex;" alt="{\displaystyle (x:\sigma )\cap \tau }" /></span>, then the term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>M</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f82cade9898ced02fdd08712e5f0c0151758a0dd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.442ex; height:2.176ex;" alt="{\displaystyle M}" /></span> has <i>both</i> the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle \sigma }" /></span> and the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau [x:=M]}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> <mo stretchy="false">[</mo> <mi>x</mi> <mo>:=</mo> <mi>M</mi> <mo stretchy="false">]</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau [x:=M]}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fd0c8300581da4d7f300aa14361be64c101020cb" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.013ex; height:2.843ex;" alt="{\displaystyle \tau [x:=M]}" /></span>, where <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau [x:=M]}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> <mo stretchy="false">[</mo> <mi>x</mi> <mo>:=</mo> <mi>M</mi> <mo stretchy="false">]</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau [x:=M]}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fd0c8300581da4d7f300aa14361be64c101020cb" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.013ex; height:2.843ex;" alt="{\displaystyle \tau [x:=M]}" /></span> is the type which results from replacing all occurrences of the term variable <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>x</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle x}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" /></span> in <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/38a7dcde9730ef0853809fefc18d88771f95206c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.202ex; height:1.676ex;" alt="{\displaystyle \tau }" /></span> by the term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>M</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f82cade9898ced02fdd08712e5f0c0151758a0dd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.442ex; height:2.176ex;" alt="{\displaystyle M}" /></span>. </p> <div class="mw-heading mw-heading3"><h3 id="Scala_example">Scala example</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=8" title="Edit section: Scala example"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a> supports type declarations <sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> as object members. This allows a type of an object member to depend on the value of another member, which is called a <i>path-dependent type</i>.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> For example, the following program text defines a Scala trait <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Witness</span></code>, which can be used to implement the <a href="/wiki/Singleton_pattern" title="Singleton pattern">singleton pattern</a>.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="nc">Witness</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="nc">T</span> <span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="n">value</span><span class="p">:</span><span class="w"> </span><span class="nc">T</span><span class="w"> </span><span class="p">{}</span> <span class="p">}</span> </pre></div> <p>The above trait <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Witness</span></code> declares the member <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">T</span></code>, which can be assigned a <i>type</i> as its value, and the member <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">value</span></code>, which can be assigned a value of type <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">T</span></code>. The following program text defines an object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> as instance of the above trait <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Witness</span></code>. The object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> defines the type <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">T</span></code> as <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Boolean</span></code> and the value <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">value</span></code> as <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="kc">true</span></code>. For example, executing <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">System</span><span class="p">.</span><span class="n">out</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">booleanWitness</span><span class="p">.</span><span class="n">value</span><span class="p">)</span></code> prints <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="kc">true</span></code> on the console. </p> <div class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><pre><span></span><span class="k">object</span><span class="w"> </span><span class="nc">booleanWitness</span><span class="w"> </span><span class="k">extends</span><span class="w"> </span><span class="nc">Witness</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">type</span><span class="w"> </span><span class="nc">T</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Boolean</span> <span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span> <span class="p">}</span> </pre></div> <p>Let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \langle {\textsf {x}}:\sigma \rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">x</mtext> </mrow> </mrow> <mo>:</mo> <mi>σ<!-- σ --></mi> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \langle {\textsf {x}}:\sigma \rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d2b03d3c8d2be2e064edb383d050bc5aebda4368" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:6.148ex; height:2.843ex;" alt="{\displaystyle \langle {\textsf {x}}:\sigma \rangle }" /></span> be the type (specifically, a <a href="/wiki/Record_(computer_science)" title="Record (computer science)">record type</a>) of objects having the member <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\textsf {x}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">x</mtext> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\textsf {x}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0350688214b6c2cbd3a985ce656f08ad9660372b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.072ex; height:1.676ex;" alt="{\displaystyle {\textsf {x}}}" /></span> of type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle \sigma }" /></span>. In the above example, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> can be assigned the dependent intersection type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>x</mi> <mo>:</mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mtext>Type</mtext> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> <mo stretchy="false">)</mo> <mo>∩<!-- ∩ --></mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">value</mtext> </mrow> </mrow> <mo>:</mo> <mi>x</mi> <mo>.</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/35db40712cb5b22bdc1973875c2163541d7dcaea" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.892ex; height:2.843ex;" alt="{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }" /></span>. The reasoning is as follows. The object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the member <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">T</span></code> that is assigned the type <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Boolean</span></code> as its value. Since <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Boolean</span></code> is a type, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mtext>Type</mtext> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/09a4e39ede9bdbd8aa3b62a9fb8eae947f680b68" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.56ex; height:2.843ex;" alt="{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle }" /></span>. Additionally, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the member <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">value</span></code> that is assigned the value <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="kc">true</span></code> of type <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Boolean</span></code>. Since the value of <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span><span class="p">.</span><span class="nc">T</span></code> is <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="nc">Boolean</span></code>, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">value</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">booleanWitness.T</mtext> </mrow> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/30afb173f0c6589ca655fdfe34fda78c887a220e" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:25.998ex; height:2.843ex;" alt="{\displaystyle \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }" /></span>. Overall, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the intersection type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle \cap \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mtext>Type</mtext> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> <mo>∩<!-- ∩ --></mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">value</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">booleanWitness.T</mtext> </mrow> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle \cap \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1b01633bcb1c5f27b635e7dbf922c9b0fdc89f95" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:39.14ex; height:2.843ex;" alt="{\displaystyle \langle {\textsf {T}}:{\text{Type}}\rangle \cap \langle {\textsf {value}}:{\textsf {booleanWitness.T}}\rangle }" /></span>. Therefore, presenting self-reference as dependency, the object <code class="mw-highlight mw-highlight-lang-scala mw-content-ltr" dir="ltr"><span class="n">booleanWitness</span></code> has the dependent intersection type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>x</mi> <mo>:</mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo>:</mo> <mrow class="MJX-TeXAtom-ORD"> <mtext>Type</mtext> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> <mo stretchy="false">)</mo> <mo>∩<!-- ∩ --></mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">value</mtext> </mrow> </mrow> <mo>:</mo> <mi>x</mi> <mo>.</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mtext mathvariant="sans-serif">T</mtext> </mrow> </mrow> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/35db40712cb5b22bdc1973875c2163541d7dcaea" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.892ex; height:2.843ex;" alt="{\displaystyle (x:\langle {\textsf {T}}:{\text{Type}}\rangle )\cap \langle {\textsf {value}}:x.{\textsf {T}}\rangle }" /></span>. </p><p>Alternatively, the above minimalistic example can be described using <i>dependent record types</i>.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> In comparison to dependent intersection types, dependent record types constitute a strictly more specialized type theoretic concept.<sup id="cite_ref-K03_6-1" class="reference"><a href="#cite_note-K03-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Intersection_of_a_type_family">Intersection of a type family</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=9" title="Edit section: Intersection of a type family"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An <b>intersection of a type family</b>, denoted <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\textstyle \bigcap _{x:\sigma }\tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="false" scriptlevel="0"> <munder> <mo>⋂<!-- ⋂ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mi>x</mi> <mo>:</mo> <mi>σ<!-- σ --></mi> </mrow> </munder> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\textstyle \bigcap _{x:\sigma }\tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/44efcaf5df3a92bb171a16211e44f33e85cc94ab" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:6.095ex; height:3.009ex;" alt="{\textstyle \bigcap _{x:\sigma }\tau }" /></span>, is a <a href="/wiki/Dependent_type" title="Dependent type">dependent type</a> in which the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/38a7dcde9730ef0853809fefc18d88771f95206c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.202ex; height:1.676ex;" alt="{\displaystyle \tau }" /></span> may depend on the term variable <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>x</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle x}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" /></span>. In particular, if a term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>M</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f82cade9898ced02fdd08712e5f0c0151758a0dd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.442ex; height:2.176ex;" alt="{\displaystyle M}" /></span> has the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\textstyle \bigcap _{x:\sigma }\tau }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="false" scriptlevel="0"> <munder> <mo>⋂<!-- ⋂ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mi>x</mi> <mo>:</mo> <mi>σ<!-- σ --></mi> </mrow> </munder> <mi>τ<!-- τ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\textstyle \bigcap _{x:\sigma }\tau }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/44efcaf5df3a92bb171a16211e44f33e85cc94ab" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:6.095ex; height:3.009ex;" alt="{\textstyle \bigcap _{x:\sigma }\tau }" /></span>, then for <i>each</i> term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle N}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>N</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle N}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f5e3890c981ae85503089652feb48b191b57aae3" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.064ex; height:2.176ex;" alt="{\displaystyle N}" /></span> of type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle \sigma }" /></span>, the term <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>M</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f82cade9898ced02fdd08712e5f0c0151758a0dd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.442ex; height:2.176ex;" alt="{\displaystyle M}" /></span> has the type <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau [x:=N]}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>τ<!-- τ --></mi> <mo stretchy="false">[</mo> <mi>x</mi> <mo>:=</mo> <mi>N</mi> <mo stretchy="false">]</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \tau [x:=N]}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/c002d47c768eee1680120285b350790d373dbf23" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.634ex; height:2.843ex;" alt="{\displaystyle \tau [x:=N]}" /></span>. This notion is also called <i>implicit <a href="/wiki/Dependent_type#Pi_type" title="Dependent type">Pi type</a></i>,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> observing that the argument <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle N}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>N</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle N}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f5e3890c981ae85503089652feb48b191b57aae3" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.064ex; height:2.176ex;" alt="{\displaystyle N}" /></span> is not kept at term level. </p> <div class="mw-heading mw-heading2"><h2 id="Comparison_of_languages_with_intersection_types">Comparison of languages with intersection types</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=10" title="Edit section: Comparison of languages with intersection types"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <table class="wikitable sortable"> <tbody><tr> <th>Language</th> <th>Actively developed</th> <th>Paradigm(s)</th> <th>Status</th> <th>Features </th></tr> <tr> <td><a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li></ul> </td> <td style="background: #FF8; color:black; vertical-align: middle; text-align: center;" class="table-maybe">Under discussion<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></td> <td>Additionally, generic type parameters can have constraints that require their (monomorphized) type-arguments to implement multiple interfaces, whereupon the runtime type represented by the generic type parameter becomes an intersection-type of all listed interfaces. </td></tr> <tr> <td><a href="/wiki/Ceylon_(programming_language)" title="Ceylon (programming language)">Ceylon</a></td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-Cey_15-0" class="reference"><a href="#cite_note-Cey-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li>Type refinement</li> <li>Interface composition</li> <li>Subtyping in width</li></ul> </td></tr> <tr> <td><a href="/wiki/F_Sharp_(programming_language)" title="F Sharp (programming language)">F#</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li></ul> </td> <td style="background: #FF8; color:black; vertical-align: middle; text-align: center;" class="table-maybe">Under discussion<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup></td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Unknown">? </td></tr> <tr> <td>Flow</td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li> <li><a href="/wiki/Scripting_language" title="Scripting language">Scripting</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li>Type refinement</li> <li>Interface composition</li></ul> </td></tr> <tr> <td><a href="/wiki/Forsythe_(programming_language)" class="mw-redirect" title="Forsythe (programming language)">Forsythe</a></td> <td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td> <td> <ul><li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li>Function type intersection</li> <li>Distributive, co- and contravariant function type subtyping</li></ul> </td></tr> <tr> <td><a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li>Type refinement</li> <li>Interface composition</li> <li>Subtyping in width</li></ul> </td></tr> <tr> <td><a href="/wiki/PHP" title="PHP">PHP</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li> <li><a href="/wiki/Scripting_language" title="Scripting language">Scripting</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li>Type refinement</li> <li>Interface composition</li></ul> </td></tr> <tr> <td><a href="/wiki/Scala_(programming_language)" title="Scala (programming language)">Scala</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup> </td> <td> <ul><li>Type refinement</li> <li>Trait composition</li> <li>Subtyping in width</li></ul> </td></tr> <tr> <td><a href="/wiki/Microsoft_TypeScript" class="mw-redirect" title="Microsoft TypeScript">TypeScript</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li> <li><a href="/wiki/Object-oriented_programming" title="Object-oriented programming">Object-oriented</a></li> <li><a href="/wiki/Scripting_language" title="Scripting language">Scripting</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-TS_5-1" class="reference"><a href="#cite_note-TS-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li>Arbitrary type intersection</li> <li>Interface composition</li> <li>Subtyping in width and depth</li></ul> </td></tr> <tr> <td><a href="/wiki/Whiley_(programming_language)" title="Whiley (programming language)">Whiley</a></td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup></td> <td> <ul><li><a href="/wiki/Functional_programming" title="Functional programming">Functional</a></li> <li><a href="/wiki/Imperative_programming" title="Imperative programming">Imperative</a></li></ul> </td> <td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Supported<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup></td> <td style="background: var(--background-color-interactive, #EEE); color: var(--color-base, black); vertical-align: middle; white-space: nowrap; text-align: center;" class="table-Unknown">? </td></tr></tbody></table> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Intersection_type&action=edit&section=11" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist"> <div class="mw-references-wrap mw-references-columns"><ol class="references"> <li id="cite_note-BCD83-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-BCD83_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFBarendregtCoppoDezani-Ciancaglini1983" class="citation journal cs1">Barendregt, Henk; Coppo, Mario; <a href="/wiki/Mariangiola_Dezani-Ciancaglini" title="Mariangiola Dezani-Ciancaglini">Dezani-Ciancaglini, Mariangiola</a> (1983). "A filter lambda model and the completeness of type assignment". <i>Journal of Symbolic Logic</i>. <b>48</b> (4): <span class="nowrap">931–</span>940. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2273659">10.2307/2273659</a>. <a href="/wiki/JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a> <a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2273659">2273659</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:45660117">45660117</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Journal+of+Symbolic+Logic&rft.atitle=A+filter+lambda+model+and+the+completeness+of+type+assignment&rft.volume=48&rft.issue=4&rft.pages=%3Cspan+class%3D%22nowrap%22%3E931-%3C%2Fspan%3E940&rft.date=1983&rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A45660117%23id-name%3DS2CID&rft_id=https%3A%2F%2Fwww.jstor.org%2Fstable%2F2273659%23id-name%3DJSTOR&rft_id=info%3Adoi%2F10.2307%2F2273659&rft.aulast=Barendregt&rft.aufirst=Henk&rft.au=Coppo%2C+Mario&rft.au=Dezani-Ciancaglini%2C+Mariangiola&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFPalsberg2012" class="citation book cs1">Palsberg, Jens (2012). "Overloading is NP-Complete". <i>Logic and Program Semantics</i>. Lecture Notes in Computer Science. Vol. 7230. pp. <span class="nowrap">204–</span>218. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-642-29485-3_13">10.1007/978-3-642-29485-3_13</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-3-642-29484-6" title="Special:BookSources/978-3-642-29484-6"><bdi>978-3-642-29484-6</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=Overloading+is+NP-Complete&rft.btitle=Logic+and+Program+Semantics&rft.series=Lecture+Notes+in+Computer+Science&rft.pages=%3Cspan+class%3D%22nowrap%22%3E204-%3C%2Fspan%3E218&rft.date=2012&rft_id=info%3Adoi%2F10.1007%2F978-3-642-29485-3_13&rft.isbn=978-3-642-29484-6&rft.aulast=Palsberg&rft.aufirst=Jens&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFHenk_BarendregtWil_DekkersRichard_Statman2013" class="citation book cs1">Henk Barendregt; Wil Dekkers; Richard Statman (20 June 2013). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=2UVasvrhXl8C&pg=PR1"><i>Lambda Calculus with Types</i></a>. Cambridge University Press. pp. 1–. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-0-521-76614-2" title="Special:BookSources/978-0-521-76614-2"><bdi>978-0-521-76614-2</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Lambda+Calculus+with+Types&rft.pages=1-&rft.pub=Cambridge+University+Press&rft.date=2013-06-20&rft.isbn=978-0-521-76614-2&rft.au=Henk+Barendregt&rft.au=Wil+Dekkers&rft.au=Richard+Statman&rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3D2UVasvrhXl8C%26pg%3DPR1&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-G96-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-G96_4-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFGhilezan1996" class="citation journal cs1">Ghilezan, Silvia (1996). <a rel="nofollow" class="external text" href="https://doi.org/10.1305%2Fndjfl%2F1040067315">"Strong normalization and typability with intersection types"</a>. <i>Notre Dame Journal of Formal Logic</i>. <b>37</b> (1): <span class="nowrap">44–</span>52. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1305%2Fndjfl%2F1040067315">10.1305/ndjfl/1040067315</a></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Notre+Dame+Journal+of+Formal+Logic&rft.atitle=Strong+normalization+and+typability+with+intersection+types&rft.volume=37&rft.issue=1&rft.pages=%3Cspan+class%3D%22nowrap%22%3E44-%3C%2Fspan%3E52&rft.date=1996&rft_id=info%3Adoi%2F10.1305%2Fndjfl%2F1040067315&rft.aulast=Ghilezan&rft.aufirst=Silvia&rft_id=https%3A%2F%2Fdoi.org%2F10.1305%252Fndjfl%252F1040067315&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-TS-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-TS_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-TS_5-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.typescriptlang.org/docs/handbook/advanced-types.html#intersection-types">"Intersection Types in TypeScript"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Intersection+Types+in+TypeScript&rft_id=https%3A%2F%2Fwww.typescriptlang.org%2Fdocs%2Fhandbook%2Fadvanced-types.html%23intersection-types&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-K03-6"><span class="mw-cite-backlink">^ <a href="#cite_ref-K03_6-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-K03_6-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFKopylov2003" class="citation conference cs1">Kopylov, Alexei (2003). "Dependent intersection: A new way of defining records in type theory". <i>18th IEEE Symposium on Logic in Computer Science</i>. LICS 2003. IEEE Computer Society. pp. <span class="nowrap">86–</span>95. <a href="/wiki/CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.89.4223">10.1.1.89.4223</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FLICS.2003.1210048">10.1109/LICS.2003.1210048</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=conference&rft.atitle=Dependent+intersection%3A+A+new+way+of+defining+records+in+type+theory&rft.btitle=18th+IEEE+Symposium+on+Logic+in+Computer+Science&rft.pages=%3Cspan+class%3D%22nowrap%22%3E86-%3C%2Fspan%3E95&rft.pub=IEEE+Computer+Society&rft.date=2003&rft_id=https%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fsummary%3Fdoi%3D10.1.1.89.4223%23id-name%3DCiteSeerX&rft_id=info%3Adoi%2F10.1109%2FLICS.2003.1210048&rft.aulast=Kopylov&rft.aufirst=Alexei&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.scala-lang.org/files/archive/spec/2.12/04-basic-declarations-and-definitions.html#type-declarations-and-type-aliases">"Type declarations in Scala"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-15</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Type+declarations+in+Scala&rft_id=https%3A%2F%2Fwww.scala-lang.org%2Ffiles%2Farchive%2Fspec%2F2.12%2F04-basic-declarations-and-definitions.html%23type-declarations-and-type-aliases&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFAminGrütterOderskyRompf2016" class="citation book cs1">Amin, Nada; Grütter, Samuel; Odersky, Martin; Rompf, Tiark; Stucki, Sandro (2016). "The Essence of Dependent Object Types". <a rel="nofollow" class="external text" href="https://infoscience.epfl.ch/record/215280/files/paper_1.pdf"><i>A List of Successes That Can Change the World</i></a> <span class="cs1-format">(PDF)</span>. Lecture Notes in Computer Science. Vol. 9600. Springer. pp. <span class="nowrap">249–</span>272. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-319-30936-1_14">10.1007/978-3-319-30936-1_14</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/978-3-319-30935-4" title="Special:BookSources/978-3-319-30935-4"><bdi>978-3-319-30935-4</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=The+Essence+of+Dependent+Object+Types&rft.btitle=A+List+of+Successes+That+Can+Change+the+World&rft.series=Lecture+Notes+in+Computer+Science&rft.pages=%3Cspan+class%3D%22nowrap%22%3E249-%3C%2Fspan%3E272&rft.pub=Springer&rft.date=2016&rft_id=info%3Adoi%2F10.1007%2F978-3-319-30936-1_14&rft.isbn=978-3-319-30935-4&rft.aulast=Amin&rft.aufirst=Nada&rft.au=Gr%C3%BCtter%2C+Samuel&rft.au=Odersky%2C+Martin&rft.au=Rompf%2C+Tiark&rft.au=Stucki%2C+Sandro&rft_id=https%3A%2F%2Finfoscience.epfl.ch%2Frecord%2F215280%2Ffiles%2Fpaper_1.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/singletons.scala">"Singletons in the Scala shapeless library"</a>. <i><a href="/wiki/GitHub" title="GitHub">GitHub</a></i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-15</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=GitHub&rft.atitle=Singletons+in+the+Scala+shapeless+library&rft_id=https%3A%2F%2Fgithub.com%2Fmilessabin%2Fshapeless%2Fblob%2Fmaster%2Fcore%2Fsrc%2Fmain%2Fscala%2Fshapeless%2Fsingletons.scala&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFPollack2000" class="citation conference cs1">Pollack, Robert (2000). "Dependently typed records for representing mathematical structure". <i>Theorem Proving in Higher Order Logics, 13th International Conference</i>. TPHOLs 2000. Springer. pp. <span class="nowrap">462–</span>479. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F3-540-44659-1_29">10.1007/3-540-44659-1_29</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=conference&rft.atitle=Dependently+typed+records+for+representing+mathematical+structure&rft.btitle=Theorem+Proving+in+Higher+Order+Logics%2C+13th+International+Conference&rft.pages=%3Cspan+class%3D%22nowrap%22%3E462-%3C%2Fspan%3E479&rft.pub=Springer&rft.date=2000&rft_id=info%3Adoi%2F10.1007%2F3-540-44659-1_29&rft.aulast=Pollack&rft.aufirst=Robert&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite id="CITEREFStump2018" class="citation journal cs1">Stump, Aaron (2018). <a rel="nofollow" class="external text" href="https://doi.org/10.1016%2Fj.apal.2018.03.002">"From realizability to induction via dependent intersection"</a>. <i>Annals of Pure and Applied Logic</i>. <b>169</b> (7): <span class="nowrap">637–</span>655. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1016%2Fj.apal.2018.03.002">10.1016/j.apal.2018.03.002</a></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Annals+of+Pure+and+Applied+Logic&rft.atitle=From+realizability+to+induction+via+dependent+intersection&rft.volume=169&rft.issue=7&rft.pages=%3Cspan+class%3D%22nowrap%22%3E637-%3C%2Fspan%3E655&rft.date=2018&rft_id=info%3Adoi%2F10.1016%2Fj.apal.2018.03.002&rft.aulast=Stump&rft.aufirst=Aaron&rft_id=https%3A%2F%2Fdoi.org%2F10.1016%252Fj.apal.2018.03.002&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://csharp.net/">"C# Guide"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=C%23+Guide&rft_id=http%3A%2F%2Fcsharp.net%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/dotnet/csharplang/issues/399">"Discussion: Union and Intersection types in C Sharp"</a>. <i><a href="/wiki/GitHub" title="GitHub">GitHub</a></i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=GitHub&rft.atitle=Discussion%3A+Union+and+Intersection+types+in+C+Sharp&rft_id=https%3A%2F%2Fgithub.com%2Fdotnet%2Fcsharplang%2Fissues%2F399&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://projects.eclipse.org/projects/technology.ceylon/">"Eclipse Ceylon™"</a>. 19 July 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">2023-08-16</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Eclipse+Ceylon%E2%84%A2&rft.date=2017-07-19&rft_id=https%3A%2F%2Fprojects.eclipse.org%2Fprojects%2Ftechnology.ceylon%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-Cey-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-Cey_15-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://ceylon-lang.org/documentation/tour/types/#intersection_types">"Intersection Types in Ceylon"</a>. 19 July 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Intersection+Types+in+Ceylon&rft.date=2017-07-19&rft_id=https%3A%2F%2Fceylon-lang.org%2Fdocumentation%2Ftour%2Ftypes%2F%23intersection_types&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://fsharp.org/">"F# Software Foundation"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=F%23+Software+Foundation&rft_id=http%3A%2F%2Ffsharp.org%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/fsharp/fslang-suggestions/issues/600">"Add Intersection Types to F Sharp"</a>. <i><a href="/wiki/GitHub" title="GitHub">GitHub</a></i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=GitHub&rft.atitle=Add+Intersection+Types+to+F+Sharp&rft_id=https%3A%2F%2Fgithub.com%2Ffsharp%2Ffslang-suggestions%2Fissues%2F600&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20220408204727/https://flow.org/en/">"Flow: A Static Type Checker for JavaScript"</a>. Archived from <a rel="nofollow" class="external text" href="https://flow.org/en/">the original</a> on 2022-04-08<span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Flow%3A+A+Static+Type+Checker+for+JavaScript&rft_id=https%3A%2F%2Fflow.org%2Fen%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://flow.org/en/docs/types/intersections/#intersection-type-syntax">"Intersection Type Syntax in Flow"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Intersection+Type+Syntax+in+Flow&rft_id=https%3A%2F%2Fflow.org%2Fen%2Fdocs%2Ftypes%2Fintersections%2F%23intersection-type-syntax&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text">Reynolds, J. C. (1988). Preliminary design of the programming language Forsythe.</span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.oracle.com/java/">"Java Software"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Java+Software&rft_id=https%3A%2F%2Fwww.oracle.com%2Fjava%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/12/docs/api/java.compiler/javax/lang/model/type/IntersectionType.html">"IntersectionType (Java SE 12 & JDK 12)"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=IntersectionType+%28Java+SE+12+%26+JDK+12%29&rft_id=https%3A%2F%2Fdocs.oracle.com%2Fen%2Fjava%2Fjavase%2F12%2Fdocs%2Fapi%2Fjava.compiler%2Fjavax%2Flang%2Fmodel%2Ftype%2FIntersectionType.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://php.net">"php.net"</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=php.net&rft_id=https%3A%2F%2Fphp.net&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://php.watch/versions/8.1/intersection-types">"PHP.Watch - PHP 8.1: Intersection Types"</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=PHP.Watch+-+PHP+8.1%3A+Intersection+Types&rft_id=https%3A%2F%2Fphp.watch%2Fversions%2F8.1%2Fintersection-types&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://scala-lang.org/">"The Scala Programming Language"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-08</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=The+Scala+Programming+Language&rft_id=https%3A%2F%2Fscala-lang.org%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.scala-lang.org/files/archive/spec/2.12/03-types.html#compound-types">"Compound Types in Scala"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Compound+Types+in+Scala&rft_id=https%3A%2F%2Fwww.scala-lang.org%2Ffiles%2Farchive%2Fspec%2F2.12%2F03-types.html%23compound-types&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://dotty.epfl.ch/docs/reference/new-types/intersection-types.html">"Intersection Types in Dotty"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Intersection+Types+in+Dotty&rft_id=http%3A%2F%2Fdotty.epfl.ch%2Fdocs%2Freference%2Fnew-types%2Fintersection-types.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.typescriptlang.org/">"TypeScript - JavaScript that scales"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=TypeScript+-+JavaScript+that+scales.&rft_id=https%3A%2F%2Fwww.typescriptlang.org%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://whiley.org/">"Whiley: an Open Source Programming Language with Extended Static Checking"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Whiley%3A+an+Open+Source+Programming+Language+with+Extended+Static+Checking&rft_id=http%3A%2F%2Fwhiley.org%2F&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> <li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222" /><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://whiley.org/download/WhileyLanguageSpec.pdf">"Whiley language specification"</a> <span class="cs1-format">(PDF)</span><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-08-01</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Whiley+language+specification&rft_id=http%3A%2F%2Fwhiley.org%2Fdownload%2FWhileyLanguageSpec.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AIntersection+type" class="Z3988"></span></span> </li> </ol></div></div> <div class="navbox-styles"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div><div role="navigation" class="navbox" aria-labelledby="Data_types177" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374" /><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239400231" /><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Data_types" title="Template:Data types"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Data_types" title="Template talk:Data types"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Data_types" title="Special:EditPage/Template:Data types"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Data_types177" style="font-size:114%;margin:0 4em"><a href="/wiki/Data_type" title="Data type">Data types</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Units_of_information" title="Units of information">Uninterpreted</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Bit" title="Bit">Bit</a></li> <li><a href="/wiki/Byte" title="Byte">Byte</a></li> <li><a href="/wiki/Ternary_numeral_system" title="Ternary numeral system">Trit</a></li> <li><a href="/wiki/Ternary_numeral_system#Tryte" title="Ternary numeral system">Tryte</a></li> <li><a href="/wiki/Word_(computer_architecture)" title="Word (computer architecture)">Word</a></li> <li><a href="/wiki/Bit_array" title="Bit array">Bit array</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Numeric</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Arbitrary-precision_arithmetic" title="Arbitrary-precision arithmetic">Arbitrary-precision or bignum</a></li> <li><a href="/wiki/Complex_data_type" title="Complex data type">Complex</a></li> <li><a href="/wiki/Decimal_data_type" title="Decimal data type">Decimal</a></li> <li><a href="/wiki/Fixed-point_arithmetic" title="Fixed-point arithmetic">Fixed point</a></li> <li><a href="/wiki/Floating-point_arithmetic" title="Floating-point arithmetic">Floating point</a> <ul><li>Reduced precision <ul><li><a href="/wiki/Minifloat" title="Minifloat">Minifloat</a></li> <li><a href="/wiki/Half-precision_floating-point_format" title="Half-precision floating-point format">Half precision</a></li> <li><a href="/wiki/Bfloat16_floating-point_format" title="Bfloat16 floating-point format">bfloat16</a></li></ul></li> <li><a href="/wiki/Single-precision_floating-point_format" title="Single-precision floating-point format">Single precision</a></li> <li><a href="/wiki/Double-precision_floating-point_format" title="Double-precision floating-point format">Double precision</a></li> <li><a href="/wiki/Quadruple-precision_floating-point_format" title="Quadruple-precision floating-point format">Quadruple precision</a></li> <li><a href="/wiki/Octuple-precision_floating-point_format" title="Octuple-precision floating-point format">Octuple precision</a></li> <li><a href="/wiki/Extended_precision" title="Extended precision">Extended precision</a> <ul><li><a href="/wiki/Long_double" title="Long double">Long double</a></li></ul></li></ul></li> <li><a href="/wiki/Integer_(computer_science)" title="Integer (computer science)">Integer</a> <ul><li><a href="/wiki/Signedness" title="Signedness">signedness</a></li></ul></li> <li><a href="/wiki/Interval_arithmetic#Implementations" title="Interval arithmetic">Interval</a></li> <li><a href="/wiki/Rational_data_type" title="Rational data type">Rational</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Pointer_(computer_programming)" title="Pointer (computer programming)">Pointer</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Memory_address" title="Memory address">Address</a> <ul><li><a href="/wiki/Physical_address" title="Physical address">physical</a></li> <li><a href="/wiki/Virtual_address_space" title="Virtual address space">virtual</a></li></ul></li> <li><a href="/wiki/Reference_(computer_science)" title="Reference (computer science)">Reference</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Plain_text" title="Plain text">Text</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Character_(computing)" title="Character (computing)">Character</a></li> <li><a href="/wiki/String_(computer_science)" title="String (computer science)">String</a> <ul><li><a href="/wiki/Null-terminated_string" title="Null-terminated string">null-terminated</a></li></ul></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Composite_data_type" title="Composite data type">Composite</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Algebraic_data_type" title="Algebraic data type">Algebraic data type</a> <ul><li><a href="/wiki/Generalized_algebraic_data_type" title="Generalized algebraic data type">generalized</a></li></ul></li> <li><a href="/wiki/Array_data_type" class="mw-redirect" title="Array data type">Array</a></li> <li><a href="/wiki/Associative_array" title="Associative array">Associative array</a></li> <li><a href="/wiki/Class_(computer_programming)" title="Class (computer programming)">Class</a></li> <li><a href="/wiki/Dependent_type" title="Dependent type">Dependent</a></li> <li><a href="/wiki/Intuitionistic_type_theory#Equality_type" title="Intuitionistic type theory">Equality</a></li> <li><a href="/wiki/Inductive_type" title="Inductive type">Inductive</a></li> <li><a class="mw-selflink selflink">Intersection</a></li> <li><a href="/wiki/List_(abstract_data_type)" title="List (abstract data type)">List</a></li> <li><a href="/wiki/Object_(computer_science)" title="Object (computer science)">Object</a> <ul><li><a href="/wiki/Metaobject" title="Metaobject">metaobject</a></li></ul></li> <li><a href="/wiki/Option_type" title="Option type">Option type</a></li> <li><a href="/wiki/Product_type" title="Product type">Product</a></li> <li><a href="/wiki/Record_(computer_science)" title="Record (computer science)">Record or Struct</a></li> <li><a href="/wiki/Refinement_type" title="Refinement type">Refinement</a></li> <li><a href="/wiki/Set_(abstract_data_type)" title="Set (abstract data type)">Set</a></li> <li><a href="/wiki/Union_type" title="Union type">Union</a> <ul><li><a href="/wiki/Tagged_union" title="Tagged union">tagged</a></li></ul></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Boolean_data_type" title="Boolean data type">Boolean</a></li> <li><a href="/wiki/Bottom_type" title="Bottom type">Bottom type</a></li> <li><a href="/wiki/Container_(abstract_data_type)" title="Container (abstract data type)">Collection</a></li> <li><a href="/wiki/Enumerated_type" title="Enumerated type">Enumerated type</a></li> <li><a href="/wiki/Exception_handling" title="Exception handling">Exception</a></li> <li><a href="/wiki/Function_type" title="Function type">Function type</a></li> <li><a href="/wiki/Opaque_data_type" title="Opaque data type">Opaque data type</a></li> <li><a href="/wiki/Recursive_data_type" title="Recursive data type">Recursive data type</a></li> <li><a href="/wiki/Semaphore_(programming)" title="Semaphore (programming)">Semaphore</a></li> <li><a href="/wiki/Stream_(computing)" title="Stream (computing)">Stream</a></li> <li><a href="/wiki/Strongly_typed_identifier" title="Strongly typed identifier">Strongly typed identifier</a></li> <li><a href="/wiki/Top_type" title="Top type">Top type</a></li> <li><a href="/wiki/Type_class" title="Type class">Type class</a></li> <li><a href="/wiki/Empty_type" title="Empty type">Empty type</a></li> <li><a href="/wiki/Unit_type" title="Unit type">Unit type</a></li> <li><a href="/wiki/Void_type" title="Void type">Void</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related<br />topics</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Abstract_data_type" title="Abstract data type">Abstract data type</a></li> <li><a href="/wiki/Boxing_(computer_science)" class="mw-redirect" title="Boxing (computer science)">Boxing</a></li> <li><a href="/wiki/Data_structure" title="Data structure">Data structure</a></li> <li><a href="/wiki/Generic_programming" title="Generic programming">Generic</a></li> <li><a href="/wiki/Kind_(type_theory)" title="Kind (type theory)">Kind</a> <ul><li><a href="/wiki/Metaclass" title="Metaclass">metaclass</a></li></ul></li> <li><a href="/wiki/Parametric_polymorphism" title="Parametric polymorphism">Parametric polymorphism</a></li> <li><a href="/wiki/Primitive_data_type" title="Primitive data type">Primitive data type</a></li> <li><a href="/wiki/Interface_(object-oriented_programming)" title="Interface (object-oriented programming)">Interface</a></li> <li><a href="/wiki/Subtyping" title="Subtyping">Subtyping</a></li> <li><a href="/wiki/Type_constructor" title="Type constructor">Type constructor</a></li> <li><a href="/wiki/Type_conversion" title="Type conversion">Type conversion</a></li> <li><a href="/wiki/Type_system" title="Type system">Type system</a></li> <li><a href="/wiki/Type_theory" title="Type theory">Type theory</a></li> <li><a href="/wiki/Variable_(computer_science)" title="Variable (computer science)">Variable</a></li></ul> </div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐api‐int.codfw.main‐5f6dc849d4‐4sr7n Cached time: 20250306131821 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.487 seconds Real time usage: 0.652 seconds Preprocessor visited node count: 3138/1000000 Post‐expand include size: 73712/2097152 bytes Template argument size: 1290/2097152 bytes Highest expansion depth: 8/100 Expensive parser function count: 122/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 142799/5000000 bytes Lua time usage: 0.274/10.000 seconds Lua memory usage: 5745550/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 461.319 1 -total 43.31% 199.806 1 Template:RefList 18.94% 87.377 3 Template:Cite_journal 17.26% 79.640 1 Template:Short_description 16.80% 77.491 1 Template:Type_systems 16.15% 74.522 1 Template:Sidebar 13.47% 62.129 21 Template:Cite_web 10.05% 46.371 2 Template:Pagetype 9.60% 44.287 1 Template:Data_types 9.14% 42.176 1 Template:Navbox --> <!-- Saved in parser cache with key enwiki:pcache:24140211:|#|:idhash:canonical and timestamp 20250306131821 and revision id 1259099901. Rendering was triggered because: api-parse --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?useformat=desktop&type=1x1&usesul3=0" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Intersection_type&oldid=1259099901">https://en.wikipedia.org/w/index.php?title=Intersection_type&oldid=1259099901</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Type_theory" title="Category:Type theory">Type theory</a></li><li><a href="/wiki/Category:Type_systems" title="Category:Type systems">Type systems</a></li><li><a href="/wiki/Category:Data_types" title="Category:Data types">Data types</a></li><li><a href="/wiki/Category:Composite_data_types" title="Category:Composite data types">Composite data types</a></li><li><a href="/wiki/Category:Polymorphism_(computer_science)" title="Category:Polymorphism (computer science)">Polymorphism (computer science)</a></li><li><a href="/wiki/Category:TypeScript" title="Category:TypeScript">TypeScript</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_matches_Wikidata" title="Category:Short description matches Wikidata">Short description matches Wikidata</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 23 November 2024, at 10:24<span class="anonymous-show"> (UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Intersection_type&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/static/images/footer/wikimedia-button.svg" width="84" height="29"><img src="/static/images/footer/wikimedia.svg" width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy"></picture></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><picture><source media="(min-width: 500px)" srcset="/w/resources/assets/poweredby_mediawiki.svg" width="88" height="31"><img src="/w/resources/assets/mediawiki_compact.svg" alt="Powered by MediaWiki" lang="en" width="25" height="25" loading="lazy"></picture></a></li> </ul> </footer> </div> </div> </div> <div class="vector-header-container vector-sticky-header-container"> <div id="vector-sticky-header" class="vector-sticky-header"> <div class="vector-sticky-header-start"> <div class="vector-sticky-header-icon-start vector-button-flush-left vector-button-flush-right" aria-hidden="true"> <button class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-sticky-header-search-toggle" tabindex="-1" data-event-name="ui.vector-sticky-search-form.icon"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </button> </div> <div role="search" class="vector-search-box-vue vector-search-box-show-thumbnail vector-search-box"> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail"> <form action="/w/index.php" id="vector-sticky-search-form" class="cdx-search-input cdx-search-input--has-end-button"> <div class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia"> <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <div class="vector-sticky-header-context-bar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-sticky-header-toc" class="vector-dropdown mw-portlet mw-portlet-sticky-header-toc vector-sticky-header-toc vector-button-flush-left" > <input type="checkbox" id="vector-sticky-header-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-sticky-header-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-sticky-header-toc-label" for="vector-sticky-header-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-sticky-header-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div class="vector-sticky-header-context-bar-primary" aria-hidden="true" ><span class="mw-page-title-main">Intersection type</span></div> </div> </div> <div class="vector-sticky-header-end" aria-hidden="true"> <div class="vector-sticky-header-icons"> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-talk-sticky-header" tabindex="-1" data-event-name="talk-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbles mw-ui-icon-wikimedia-speechBubbles"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-subject-sticky-header" tabindex="-1" data-event-name="subject-sticky-header"><span class="vector-icon mw-ui-icon-article mw-ui-icon-wikimedia-article"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-history-sticky-header" tabindex="-1" data-event-name="history-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-history mw-ui-icon-wikimedia-wikimedia-history"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only mw-watchlink" id="ca-watchstar-sticky-header" tabindex="-1" data-event-name="watch-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-star mw-ui-icon-wikimedia-wikimedia-star"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-edit-sticky-header" tabindex="-1" data-event-name="wikitext-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-wikiText mw-ui-icon-wikimedia-wikimedia-wikiText"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-ve-edit-sticky-header" tabindex="-1" data-event-name="ve-edit-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-edit mw-ui-icon-wikimedia-wikimedia-edit"></span> <span></span> </a> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only" id="ca-viewsource-sticky-header" tabindex="-1" data-event-name="ve-edit-protected-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-editLock mw-ui-icon-wikimedia-wikimedia-editLock"></span> <span></span> </a> </div> <div class="vector-sticky-header-buttons"> <button class="cdx-button cdx-button--weight-quiet mw-interlanguage-selector" id="p-lang-btn-sticky-header" tabindex="-1" data-event-name="ui.dropdown-p-lang-btn-sticky-header"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>Add languages</span> </button> <a href="#" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive" id="ca-addsection-sticky-header" tabindex="-1" data-event-name="addsection-sticky-header"><span class="vector-icon mw-ui-icon-speechBubbleAdd-progressive mw-ui-icon-wikimedia-speechBubbleAdd-progressive"></span> <span>Add topic</span> </a> </div> <div class="vector-sticky-header-icon-end"> <div class="vector-user-links"> </div> </div> </div> </div> </div> <div class="mw-portlet mw-portlet-dock-bottom emptyPortlet" id="p-dock-bottom"> <ul> </ul> </div> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.canary-68cdbf68f5-zsxk2","wgBackendResponseTime":163,"wgPageParseReport":{"limitreport":{"cputime":"0.487","walltime":"0.652","ppvisitednodes":{"value":3138,"limit":1000000},"postexpandincludesize":{"value":73712,"limit":2097152},"templateargumentsize":{"value":1290,"limit":2097152},"expansiondepth":{"value":8,"limit":100},"expensivefunctioncount":{"value":122,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":142799,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 461.319 1 -total"," 43.31% 199.806 1 Template:RefList"," 18.94% 87.377 3 Template:Cite_journal"," 17.26% 79.640 1 Template:Short_description"," 16.80% 77.491 1 Template:Type_systems"," 16.15% 74.522 1 Template:Sidebar"," 13.47% 62.129 21 Template:Cite_web"," 10.05% 46.371 2 Template:Pagetype"," 9.60% 44.287 1 Template:Data_types"," 9.14% 42.176 1 Template:Navbox"]},"scribunto":{"limitreport-timeusage":{"value":"0.274","limit":"10.000"},"limitreport-memusage":{"value":5745550,"limit":52428800}},"cachereport":{"origin":"mw-api-int.codfw.main-5f6dc849d4-4sr7n","timestamp":"20250306131821","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Intersection type","url":"https:\/\/en.wikipedia.org\/wiki\/Intersection_type","sameAs":"http:\/\/www.wikidata.org\/entity\/Q85769734","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q85769734","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2009-08-28T06:58:50Z","dateModified":"2024-11-23T10:24:21Z","headline":"concept in type theory"}</script> </body> </html>