{"id":1822,"date":"2012-10-12T20:00:47","date_gmt":"2012-10-12T19:00:47","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=1822"},"modified":"2012-09-23T08:58:06","modified_gmt":"2012-09-23T07:58:06","slug":"the-alfe-type-system","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/the-alfe-type-system\/","title":{"rendered":"The ALFE type system"},"content":{"rendered":"<p>I want to write a series of posts about the rich type system I want to implement for <a href=\"https:\/\/www.reenigne.org\/blog\/bootstrapping-a-compiler-from-nothing\">ALFE<\/a>. This post will serve as an index to them.<\/p>\n<p>I recently tried doing a bit of programming in <a href=\"http:\/\/www.haskell.org\">Haskell<\/a>, and although I didn't produce anything worth showing off, I did get a bit of a feel for the language and how it works. One of my favorite things about Haskell is the rich type system, and I want to use some of its ideas in ALFE. Some of the ALFE types below are inspired by Haskell types.<\/p>\n<p>Given types <strong>Foo<\/strong>, <strong>Bar<\/strong> and <strong>Baz<\/strong> I would like ALFE to have the following types:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/pointers-in-alfe\"><strong>Foo*<\/strong><\/a> - a pointer type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/function-types-in-alfe\"><strong>Foo(Bar)<\/strong><\/a> (aka <strong>Foo -> Bar<\/strong>) - a function type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/sum-types-in-alfe\"><strong>Foo | Bar<\/strong><\/a> - a \"sum\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/maybes-in-alfe\"><strong>Foo?<\/strong><\/a> - a \"Maybe\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/product-types-in-alfe\"><strong>(Foo, Bar)<\/strong><\/a> - a \"product\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/sequence-types-in-alfe\"><strong>[Foo]<\/strong><\/a> - a \"sequence\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/fixed-length-arrays-in-alfe\"><strong>Foo[2]<\/strong><\/a> - a fixed length array type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/the-bottom-type-in-alfe\"><strong>Bottom<\/strong><\/a> - the \"bottom\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/the-variant-type-in-alfe\"><strong>Variant<\/strong><\/a> - the \"variant\" type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/the-label-type-in-alfe\"><strong>Label<\/strong><\/a> - the \"label\" type.<\/li>\n<li><strong>Complex&lt;Foo&gt;<\/strong> - a complex number type.<\/li>\n<li><strong>Rational&lt;Foo&gt;<\/strong> - a rational type.<\/li>\n<li><strong>String<\/strong> - the string type (usually represented in memory as UTF-8 in some form).<\/li>\n<li><strong>CodePoint<\/strong> - a type capable of holding any Unicode code point.<\/li>\n<li><strong>Fixed&lt;Foo, Bar&gt;<\/strong> - a fixed point fractional type.<\/li>\n<li><strong>Boolean<\/strong> - the boolean type.<\/li>\n<li><strong>Int1<\/strong>, <strong>Int2<\/strong>, <strong>Int4<\/strong>, <strong>Int8<\/strong>, <strong>Byte<\/strong>, <strong>Int16<\/strong>, <strong>Int32<\/strong>, <strong>Int64<\/strong>, <strong>Int128<\/strong>, <strong>Int256<\/strong>, <strong>Int512<\/strong>, <strong>UInt1<\/strong>, <strong>UInt2<\/strong>, <strong>UInt4<\/strong>, <strong>UInt8<\/strong>, <strong>UByte<\/strong>, <strong>UInt16<\/strong>, <strong>UInt32<\/strong>, <strong>UInt64<\/strong>, <strong>UInt128<\/strong>, <strong>UInt256<\/strong>, <strong>UInt512<\/strong>, <strong>NInt1<\/strong>, <strong>NInt2<\/strong>, <strong>NInt4<\/strong>, <strong>NInt8<\/strong>, <strong>NByte<\/strong> <strong>NInt16<\/strong>, <strong>NInt32<\/strong>, <strong>NInt64<\/strong>, <strong>NInt128<\/strong>, <strong>NInt256<\/strong>, <strong>NInt512<\/strong> - fixed-width integer types.<\/li>\n<li><strong>Word<\/strong>, <strong>Int<\/strong>, <strong>HalfWord<\/strong>, <strong>QuarterWord<\/strong>, <strong>DoubleWord<\/strong>, <strong>QuadWord<\/strong>, <strong>UWord<\/strong>, <strong>UInt<\/strong>, <strong>UHalfWord<\/strong>, <strong>UQuarterWord<\/strong>, <strong>UDoubleWord<\/strong>, <strong>UQuadWord<\/strong>, <strong>NWord<\/strong>, <strong>NInt<\/strong>, <strong>NHalfWord<\/strong>, <strong>NQuarterWord<\/strong>, <strong>NDoubleWord<\/strong>, <strong>NQuadWord<\/strong>, <strong>FastInt1<\/strong>, <strong>FastInt2<\/strong>, <strong>FastInt4<\/strong>, <strong>FastInt8<\/strong>, <strong>FastByte<\/strong>, <strong>FastInt16<\/strong>, <strong>FastInt32<\/strong>, <strong>FastInt64<\/strong>, <strong>FastInt128<\/strong>, <strong>FastInt256<\/strong>, <strong>FastInt512<\/strong>, <strong>FastUInt1<\/strong>, <strong>FastUInt2<\/strong>, <strong>FastUInt4<\/strong>, <strong>FastUInt8<\/strong>, <strong>FastUByte<\/strong>, <strong>FastUInt16<\/strong>, <strong>FastUInt32<\/strong>, <strong>FastUInt64<\/strong>, <strong>FastUInt128<\/strong>, <strong>FastUInt256<\/strong>, <strong>FastUInt512<\/strong>, <strong>FastNInt1<\/strong>, <strong>FastNInt2<\/strong>, <strong>FastNInt4<\/strong>, <strong>FastNInt8<\/strong>, <strong>FastNByte<\/strong> <strong>FastNInt16<\/strong>, <strong>FastNInt32<\/strong>, <strong>FastNInt64<\/strong>, <strong>FastNInt128<\/strong>, <strong>FastNInt256<\/strong>, <strong>FastNInt512<\/strong> - machine-dependent integer types.<\/li>\n<li><strong>WordString<\/strong>, <strong>Integer<\/strong>, <strong>Unsigned<\/strong> - arbitrary-precision integer types.<\/li>\n<li><strong>Float16<\/strong>, <strong>Float32<\/strong>, <strong>Float64<\/strong>, <strong>Float128<\/strong> - fixed-length floating-point types.<\/li>\n<li><strong>Float<\/strong> - machine-dependent floating point types.<\/li>\n<li><strong>Floating<\/strong> - arbitrary-precision floating point type.<\/li>\n<li><a href=\"https:\/\/www.reenigne.org\/blog\/concrete-data-type\"><strong>Concrete<\/strong><\/a> (possibly also specializations like <strong>Length<\/strong>, <strong>Time<\/strong>, <strong>Area<\/strong>, <strong>MagneticFluxDensity<\/strong> etc.)<\/li>\n<\/ul>\n<p>There's still a lot about this that isn't finalized. For example, I might use some templates to avoid having all those fixed-width and machine-dependent types.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to write a series of posts about the rich type system I want to implement for ALFE. This post will serve as an index to them. I recently tried doing a bit of programming in Haskell, and although I didn't produce anything worth showing off, I did get a bit of a feel [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,27],"tags":[],"class_list":["post-1822","post","type-post","status-publish","format-standard","hentry","category-computer","category-language"],"_links":{"self":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/comments?post=1822"}],"version-history":[{"count":11,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1822\/revisions"}],"predecessor-version":[{"id":1883,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1822\/revisions\/1883"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=1822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=1822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=1822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}