Knowledge

Function type

Source 📝

1444:) of set-theoretic functions between them. Clearly this space of functions is larger than the number of functions that can be defined in any programming language, as there exist only countably many programs (a program being a finite sequence of a finite number of symbols) and one of the set-theoretic functions effectively solves the 167:
The syntax used for function types in several programming languages can be summarized, including an example type signature for the higher-order
1472: 1736: 2107: 1741: 168: 55:
A function type depends on the type of the parameters and the result type of the function (it, or more accurately the unapplied
1731: 1726: 1714: 1615: 1458:) to model programming language concepts such as function types. It turns out that restricting expression to the set of 1428:
The function type in programming languages does not correspond to the space of all set-theoretic functions. Given the
1892: 1548: 1865: 156: 1982: 1787: 1719: 1681: 1417: 317: 202: 1025: 1882: 1812: 1660: 1441: 650: 481: 77: 41: 2137: 1772: 1463: 765: 45: 37: 1760: 1480:, not continuity in the real analytical sense). Even then, the set of continuous function contains the 2070: 2022: 1934: 1912: 1907: 1835: 1701: 1655: 1493: 912: 1944: 1608: 1540: 1141: 2097: 2012: 1136: 907: 197: 152: 1840: 1696: 1650: 1451: 1830: 1805: 1405: 49: 1532: 2168: 2163: 1632: 1509: 1437: 1131: 901: 192: 81: 69: 1580: 8: 2158: 2102: 2080: 2007: 1860: 1852: 1601: 1533: 1459: 88: 1381:
When looking at the example type signature of, for example C#, the type of the function
2085: 2065: 2017: 1992: 1777: 1746: 1528: 1503: 1429: 133: 65: 21: 1972: 1902: 1877: 1691: 1686: 1544: 2117: 2002: 1800: 1558: 1401: 129: 56: 17: 2122: 1987: 1939: 1872: 1467: 1445: 141: 2075: 1897: 1887: 1795: 1514: 1477: 1433: 1409: 184: 117: 1568: 2152: 1455: 1954: 1929: 1393: 145: 73: 1484:
function, which cannot be correctly defined in all programming languages.
2132: 2127: 1977: 1924: 1751: 1021: 577: 2037: 2032: 1949: 1917: 1822: 1765: 2112: 2090: 2047: 2042: 1709: 1665: 1624: 1462:
is not sufficient either if the programming language allows writing
2027: 1498: 137: 1584:, The Univalent Foundations Program, Institute for Advanced Study 1246: 151:
The function type can be considered to be a special case of the
1593: 1454:
concerns itself with finding more appropriate models (called
1017: 390: 1645: 1572: 1436:
as the domain and the booleans as range, then there are an
1387:
Func<Func<A,B>,Func<B,C>,Func<A,C>>
48:
has or can be assigned, or an argument or result type of a
1582:
Homotopy Type Theory: Univalent Foundations of Mathematics
155:, which among other properties, encompasses the idea of a 1640: 148:; this is explored in detail in the article on currying. 132:. The class of such maps or functions is called the 80:, a function type depends on exactly two types, the 1470:). Expression must be restricted to the so-called 1466:(which is the case if the programming language is 2150: 1609: 1616: 1602: 1423: 162: 104:, following mathematical convention, or 94:. Here a function type is often denoted 2151: 1527: 1283:is the more general type (see below). 1597: 1562:Foundations for Programming Languages 1557: 1476:(corresponding to continuity in the 13: 110:, based on there existing exactly 14: 2180: 52:taking or returning a function. 1535:Types and Programming Languages 1506:, category-theoretic equivalent 72:where functions are defined in 68:). In theoretical settings and 1623: 1: 1682:Arbitrary-precision or bignum 1521: 1464:non-terminating computations 78:simply typed lambda calculus 7: 1487: 1400:, it is more common to use 10: 2185: 1539:. The MIT Press. pp.  1517:, set-theoretic equivalent 2056: 2023:Strongly typed identifier 1965: 1851: 1821: 1786: 1674: 1631: 1494:Cartesian closed category 1382: 1287: 1177: 1129: 1061: 948: 899: 801: 666: 593: 517: 406: 333: 239: 190: 176: 140:makes the function type 2098:Parametric polymorphism 1137:parametric polymorphism 908:parametric polymorphism 198:parametric polymorphism 118:set-theoretic functions 1452:Denotational semantics 1424:Denotational semantics 153:dependent product type 1406:higher order function 1132:first-class functions 902:first-class functions 193:first-class functions 163:Programming languages 116:(exponentially many) 70:programming languages 50:higher-order function 1510:First-class function 1473:continuous functions 1460:computable functions 1438:uncountably infinite 169:function composition 157:polymorphic function 2103:Primitive data type 2008:Recursive data type 1861:Algebraic data type 1737:Quadruple precision 1529:Pierce, Benjamin C. 36:) is the type of a 2066:Abstract data type 1747:Extended precision 1706:Reduced precision 1504:Exponential object 1430:countably infinite 134:exponential object 66:higher-kinded type 22:mathematical logic 2146: 2145: 1878:Associative array 1742:Octuple precision 1559:Mitchell, John C. 1379: 1378: 1254:std::function< 2176: 2118:Type constructor 2003:Opaque data type 1935:Record or Struct 1732:Double precision 1727:Single precision 1618: 1611: 1604: 1595: 1594: 1565: 1564:. The MIT Press. 1554: 1538: 1415: 1399: 1388: 1384: 1375: 1374: 1371: 1368: 1365: 1362: 1359: 1356: 1353: 1350: 1347: 1344: 1341: 1338: 1335: 1332: 1329: 1326: 1323: 1320: 1317: 1314: 1311: 1308: 1305: 1302: 1299: 1296: 1293: 1290: 1282: 1241: 1240: 1237: 1234: 1231: 1228: 1225: 1222: 1219: 1216: 1213: 1210: 1207: 1204: 1201: 1198: 1195: 1192: 1189: 1186: 1183: 1180: 1174: 1125: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1100: 1097: 1094: 1091: 1088: 1085: 1082: 1079: 1076: 1073: 1070: 1067: 1064: 1058: 1012: 1011: 1008: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 966: 963: 960: 957: 954: 951: 945: 895: 894: 890: 887: 884: 881: 877: 874: 870: 867: 864: 861: 857: 854: 851: 847: 844: 841: 838: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 798: 760: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 663: 645: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 590: 572: 571: 568: 565: 562: 559: 556: 553: 550: 547: 544: 541: 538: 535: 532: 529: 526: 523: 520: 514: 476: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 403: 385: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 330: 312: 311: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 248: 245: 242: 236: 174: 173: 130:category of sets 115: 109: 103: 63: 62: 57:type constructor 18:computer science 2184: 2183: 2179: 2178: 2177: 2175: 2174: 2173: 2149: 2148: 2147: 2142: 2123:Type conversion 2058: 2052: 1988:Enumerated type 1961: 1847: 1841:null-terminated 1817: 1782: 1670: 1627: 1622: 1588:See section 1.2 1551: 1524: 1490: 1468:Turing complete 1446:halting problem 1434:natural numbers 1426: 1413: 1408:parameters and 1397: 1386: 1372: 1369: 1366: 1363: 1360: 1357: 1354: 1351: 1348: 1345: 1342: 1339: 1336: 1333: 1330: 1327: 1324: 1321: 1318: 1315: 1312: 1309: 1306: 1303: 1300: 1297: 1294: 1291: 1288: 1280: 1271: 1264: 1253: 1238: 1235: 1232: 1229: 1226: 1223: 1220: 1217: 1214: 1211: 1208: 1205: 1202: 1199: 1196: 1193: 1190: 1187: 1184: 1181: 1178: 1172: 1163: 1156: 1146: 1135: 1122: 1119: 1116: 1113: 1110: 1107: 1104: 1101: 1098: 1095: 1092: 1089: 1086: 1083: 1080: 1077: 1074: 1071: 1068: 1065: 1062: 1056: 1047: 1040: 1030: 1009: 1006: 1003: 1000: 997: 994: 991: 988: 985: 982: 979: 976: 973: 970: 967: 964: 961: 958: 955: 952: 949: 940: 931: 924: 917: 905: 892: 888: 885: 882: 879: 875: 872: 868: 865: 862: 859: 855: 852: 849: 845: 842: 839: 836: 832: 829: 826: 823: 820: 817: 814: 811: 808: 805: 802: 793: 784: 777: 770: 757: 754: 751: 748: 745: 742: 739: 736: 733: 730: 727: 724: 721: 718: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 673: 670: 667: 655: 642: 639: 636: 633: 630: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 582: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 509: 500: 493: 486: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 395: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 322: 309: 306: 303: 300: 297: 294: 291: 288: 285: 282: 279: 276: 273: 270: 267: 264: 261: 258: 255: 252: 249: 246: 243: 240: 230: 221: 214: 207: 196: 165: 111: 105: 95: 60: 59: 12: 11: 5: 2182: 2172: 2171: 2166: 2161: 2144: 2143: 2141: 2140: 2135: 2130: 2125: 2120: 2115: 2110: 2105: 2100: 2095: 2094: 2093: 2083: 2078: 2076:Data structure 2073: 2068: 2062: 2060: 2054: 2053: 2051: 2050: 2045: 2040: 2035: 2030: 2025: 2020: 2015: 2010: 2005: 2000: 1995: 1990: 1985: 1980: 1975: 1969: 1967: 1963: 1962: 1960: 1959: 1958: 1957: 1947: 1942: 1937: 1932: 1927: 1922: 1921: 1920: 1910: 1905: 1900: 1895: 1890: 1885: 1880: 1875: 1870: 1869: 1868: 1857: 1855: 1849: 1848: 1846: 1845: 1844: 1843: 1833: 1827: 1825: 1819: 1818: 1816: 1815: 1810: 1809: 1808: 1803: 1792: 1790: 1784: 1783: 1781: 1780: 1775: 1770: 1769: 1768: 1758: 1757: 1756: 1755: 1754: 1744: 1739: 1734: 1729: 1724: 1723: 1722: 1717: 1715:Half precision 1712: 1702:Floating point 1699: 1694: 1689: 1684: 1678: 1676: 1672: 1671: 1669: 1668: 1663: 1658: 1653: 1648: 1643: 1637: 1635: 1629: 1628: 1621: 1620: 1613: 1606: 1598: 1592: 1591: 1578: 1566: 1555: 1549: 1523: 1520: 1519: 1518: 1515:Function space 1512: 1507: 1501: 1496: 1489: 1486: 1478:Scott topology 1425: 1422: 1410:type inference 1377: 1376: 1285: 1276: 1269: 1262: 1249: 1243: 1242: 1175: 1168: 1161: 1154: 1144: 1139: 1127: 1126: 1059: 1052: 1045: 1038: 1028: 1014: 1013: 946: 936: 929: 922: 915: 910: 897: 896: 799: 789: 782: 775: 768: 762: 761: 664: 653: 647: 646: 591: 580: 574: 573: 515: 505: 498: 491: 484: 478: 477: 404: 393: 387: 386: 331: 320: 314: 313: 237: 226: 219: 212: 205: 200: 188: 187: 185:type signature 181: 178: 164: 161: 76:, such as the 9: 6: 4: 3: 2: 2181: 2170: 2167: 2165: 2162: 2160: 2157: 2156: 2154: 2139: 2136: 2134: 2131: 2129: 2126: 2124: 2121: 2119: 2116: 2114: 2111: 2109: 2106: 2104: 2101: 2099: 2096: 2092: 2089: 2088: 2087: 2084: 2082: 2079: 2077: 2074: 2072: 2069: 2067: 2064: 2063: 2061: 2055: 2049: 2046: 2044: 2041: 2039: 2036: 2034: 2031: 2029: 2026: 2024: 2021: 2019: 2016: 2014: 2011: 2009: 2006: 2004: 2001: 1999: 1998:Function type 1996: 1994: 1991: 1989: 1986: 1984: 1981: 1979: 1976: 1974: 1971: 1970: 1968: 1964: 1956: 1953: 1952: 1951: 1948: 1946: 1943: 1941: 1938: 1936: 1933: 1931: 1928: 1926: 1923: 1919: 1916: 1915: 1914: 1911: 1909: 1906: 1904: 1901: 1899: 1896: 1894: 1891: 1889: 1886: 1884: 1881: 1879: 1876: 1874: 1871: 1867: 1864: 1863: 1862: 1859: 1858: 1856: 1854: 1850: 1842: 1839: 1838: 1837: 1834: 1832: 1829: 1828: 1826: 1824: 1820: 1814: 1811: 1807: 1804: 1802: 1799: 1798: 1797: 1794: 1793: 1791: 1789: 1785: 1779: 1776: 1774: 1771: 1767: 1764: 1763: 1762: 1759: 1753: 1750: 1749: 1748: 1745: 1743: 1740: 1738: 1735: 1733: 1730: 1728: 1725: 1721: 1718: 1716: 1713: 1711: 1708: 1707: 1705: 1704: 1703: 1700: 1698: 1695: 1693: 1690: 1688: 1685: 1683: 1680: 1679: 1677: 1673: 1667: 1664: 1662: 1659: 1657: 1654: 1652: 1649: 1647: 1644: 1642: 1639: 1638: 1636: 1634: 1633:Uninterpreted 1630: 1626: 1619: 1614: 1612: 1607: 1605: 1600: 1599: 1596: 1589: 1585: 1583: 1579: 1577: 1575: 1570: 1569:function type 1567: 1563: 1560: 1556: 1552: 1550:9780262162098 1546: 1542: 1537: 1536: 1530: 1526: 1525: 1516: 1513: 1511: 1508: 1505: 1502: 1500: 1497: 1495: 1492: 1491: 1485: 1483: 1479: 1475: 1474: 1469: 1465: 1461: 1457: 1453: 1449: 1447: 1443: 1439: 1435: 1431: 1421: 1419: 1411: 1407: 1403: 1398:std::function 1395: 1390: 1286: 1284: 1279: 1275: 1268: 1261: 1257: 1250: 1248: 1245: 1244: 1176: 1171: 1167: 1160: 1153: 1149: 1145: 1143: 1140: 1138: 1133: 1128: 1060: 1055: 1051: 1044: 1037: 1033: 1029: 1027: 1023: 1019: 1016: 1015: 947: 944: 939: 935: 928: 921: 916: 914: 911: 909: 903: 898: 800: 797: 792: 788: 781: 774: 769: 767: 764: 763: 665: 662: 658: 654: 652: 649: 648: 592: 589: 585: 581: 579: 576: 575: 516: 513: 508: 504: 497: 490: 485: 483: 480: 479: 405: 402: 398: 394: 392: 389: 388: 332: 329: 325: 321: 319: 316: 315: 238: 234: 229: 225: 218: 211: 206: 204: 201: 199: 194: 189: 186: 182: 179: 175: 172: 170: 160: 158: 154: 149: 147: 143: 139: 136:. The act of 135: 131: 127: 123: 119: 114: 108: 102: 98: 93: 90: 86: 83: 79: 75: 71: 67: 58: 53: 51: 47: 43: 39: 35: 31: 27: 26:function type 23: 19: 1997: 1903:Intersection 1587: 1581: 1573: 1561: 1534: 1481: 1471: 1450: 1440:number (2 = 1427: 1394:type erasure 1391: 1385:is actually 1380: 1277: 1273: 1266: 1259: 1255: 1252: 1251:Not unique. 1169: 1165: 1158: 1151: 1147: 1053: 1049: 1042: 1035: 1031: 942: 937: 933: 926: 919: 795: 790: 786: 779: 772: 660: 656: 587: 583: 511: 506: 502: 495: 488: 400: 396: 327: 323: 232: 227: 223: 216: 209: 166: 150: 146:product type 125: 121: 112: 106: 100: 96: 91: 84: 74:curried form 54: 33: 29: 25: 15: 2169:Type theory 2164:Subroutines 2133:Type theory 2128:Type system 1978:Bottom type 1925:Option type 1866:generalized 1752:Long double 1697:Fixed point 1482:parallel-or 1396:in C++11's 1022:Objective-C 578:Standard ML 44:to which a 34:exponential 2159:Data types 2153:Categories 2038:Empty type 2033:Type class 1983:Collection 1940:Refinement 1918:metaobject 1766:signedness 1625:Data types 1522:References 171:function: 30:arrow type 2113:Subtyping 2108:Interface 2091:metaclass 2043:Unit type 2013:Semaphore 1993:Exception 1898:Inductive 1888:Dependent 1853:Composite 1831:Character 1813:Reference 1710:Minifloat 1666:Bit array 1402:templates 120:mappings 42:parameter 2138:Variable 2028:Top type 1893:Equality 1801:physical 1778:Rational 1773:Interval 1720:bfloat16 1531:(2002). 1499:Currying 1488:See also 1432:type of 1418:closures 1343:function 1319:function 1295:function 1289:function 1130:Without 906:without 794:) -> 510:) => 208:Func< 183:Example 180:Notation 177:Language 138:currying 87:and the 46:function 38:variable 2081:Generic 2057:Related 1973:Boolean 1930:Product 1806:virtual 1796:Address 1788:Pointer 1761:Integer 1692:Decimal 1687:Complex 1675:Numeric 1571:at the 1456:domains 1392:Due to 1383:compose 1370:compose 1188:compose 1072:compose 1024:, with 953:compose 806:compose 671:compose 595:compose 522:compose 408:compose 335:compose 318:Haskell 259:compose 144:to the 142:adjoint 128:in the 64:, is a 2071:Boxing 2059:topics 2018:Stream 1955:tagged 1913:Object 1836:String 1547:  1543:–100. 1416:) for 1026:blocks 891:-> 878:-> 871:-> 848:-> 659:-> 643:'c 637:'a 628:'b 622:'a 610:'c 604:'b 586:-> 399:-> 326:-> 82:domain 1966:Other 1950:Union 1883:Class 1873:Array 1656:Tryte 1281:)> 1272:,..., 1247:C++11 1164:,..., 1048:,..., 932:,..., 918:func( 900:With 785:,..., 755:-> 743:-> 734:-> 710:-> 692:>( 651:Swift 640:-> 634:-> 625:-> 616:-> 607:-> 567:=> 555:=> 537:=> 501:,..., 482:Scala 471:' 468:-> 462:' 459:-> 450:' 447:-> 441:' 435:-> 426:' 423:-> 417:' 391:OCaml 380:-> 374:-> 365:-> 356:-> 347:-> 222:,..., 191:With 89:range 61:· → · 2086:Kind 2048:Void 1908:List 1823:Text 1661:Word 1651:Trit 1646:Byte 1545:ISBN 1414:auto 1404:for 1367:> 1361:> 1346:< 1337:> 1322:< 1313:> 1298:< 1292:< 1233:)))( 1150:(*)( 1117:)))( 1034:(^)( 998:func 980:func 962:func 956:func 827:> 809:< 766:Rust 674:< 668:func 304:> 292:< 289:Func 280:> 268:< 265:Func 256:> 244:< 241:Func 235:> 28:(or 24:, a 20:and 1945:Set 1641:Bit 1576:Lab 1355:int 1349:int 1331:int 1325:int 1307:int 1301:int 1236:int 1230:int 1215:int 1209:int 1194:int 1179:int 1120:int 1114:int 1099:int 1093:int 1078:int 1063:int 1018:C++ 1010:int 1004:int 992:int 986:int 974:int 968:int 950:var 771:fn( 519:def 124:to 40:or 32:or 16:In 2155:: 1586:. 1541:99 1448:. 1420:. 1389:. 1239:); 1227:)( 1212:), 1206:)( 1123:); 1111:)( 1096:), 1090:)( 1020:, 941:) 913:Go 880:fn 860:fn 858:: 837:fn 835:: 803:fn 561:): 338::: 310:); 203:C# 159:. 99:→ 1617:e 1610:t 1603:v 1590:. 1574:n 1553:. 1442:c 1412:( 1373:; 1364:) 1358:) 1352:( 1340:, 1334:) 1328:( 1316:( 1310:) 1304:( 1278:n 1274:α 1270:2 1267:α 1265:, 1263:1 1260:α 1258:( 1256:ρ 1224:g 1221:* 1218:( 1203:f 1200:* 1197:( 1191:( 1185:* 1182:( 1173:) 1170:n 1166:α 1162:2 1159:α 1157:, 1155:1 1152:α 1148:ρ 1142:C 1134:, 1108:g 1105:^ 1102:( 1087:f 1084:^ 1081:( 1075:( 1069:^ 1066:( 1057:) 1054:n 1050:α 1046:2 1043:α 1041:, 1039:1 1036:α 1032:ρ 1007:) 1001:( 995:) 989:) 983:( 977:, 971:) 965:( 959:( 943:ρ 938:n 934:α 930:2 927:α 925:, 923:1 920:α 904:, 893:C 889:) 886:A 883:( 876:) 873:C 869:) 866:B 863:( 856:g 853:, 850:B 846:) 843:A 840:( 833:f 830:( 824:C 821:, 818:B 815:, 812:A 796:ρ 791:n 787:α 783:2 780:α 778:, 776:1 773:α 758:C 752:) 749:A 746:( 740:) 737:B 731:) 728:A 725:( 722:: 719:g 716:, 713:C 707:) 704:B 701:( 698:: 695:f 689:C 686:, 683:B 680:, 677:A 661:ρ 657:α 631:) 619:( 613:) 601:( 598:: 588:ρ 584:α 570:C 564:A 558:B 552:A 549:: 546:g 543:, 540:C 534:B 531:: 528:f 525:( 512:ρ 507:n 503:α 499:2 496:α 494:, 492:1 489:α 487:( 474:c 465:a 456:) 453:b 444:a 438:( 432:) 429:c 420:b 414:( 411:: 401:ρ 397:α 383:c 377:a 371:) 368:b 362:a 359:( 353:) 350:c 344:b 341:( 328:ρ 324:α 307:g 301:B 298:, 295:A 286:, 283:f 277:C 274:, 271:B 262:( 253:C 250:, 247:A 233:ρ 231:, 228:n 224:α 220:2 217:α 215:, 213:1 210:α 195:, 126:B 122:A 113:B 107:B 101:B 97:A 92:B 85:A

Index

computer science
mathematical logic
variable
parameter
function
higher-order function
type constructor
higher-kinded type
programming languages
curried form
simply typed lambda calculus
domain
range
set-theoretic functions
category of sets
exponential object
currying
adjoint
product type
dependent product type
polymorphic function
function composition
type signature
first-class functions
parametric polymorphism
C#
Haskell
OCaml
Scala
Standard ML

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.