{"id":1847,"date":"2012-10-16T20:00:08","date_gmt":"2012-10-16T19:00:08","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=1847"},"modified":"2012-09-23T09:16:55","modified_gmt":"2012-09-23T08:16:55","slug":"maybes-in-alfe","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/maybes-in-alfe\/","title":{"rendered":"Maybes in ALFE"},"content":{"rendered":"<p>This is part of the <a href=\"https:\/\/www.reenigne.org\/blog\/the-alfe-type-system\">ALFE types series<\/a>.<\/p>\n<p><strong>Foo?<\/strong> is a \"Maybe\" type, also known as an option type. It is syntactic sugar for <strong>Maybe&lt;Foo&gt;<\/strong>. This type has values of <strong>Null<\/strong> (a type with only one value) and <strong>Just&lt;Foo&gt;<\/strong> (which is derived from <strong>Foo<\/strong>) - it's equivalent to <strong>Null | Just&lt;Foo&gt;<\/strong>.<\/p>\n<p>This is particularly handy if <strong>Foo<\/strong> is a pointer type, since ALFE's usual pointer type is not nullable, so this template will give you back C pointer semantics (except with more safety, since it'll force you to explicitly check for <strong>Null<\/strong> before dereferencing). Because of the <strong>Just&lt;&gt;<\/strong> template, it's possible to stack Maybes - so you can have <strong>Foo??<\/strong> with two separate sentinels, <strong>Null<\/strong> and <strong>Just&lt;Null&gt;<\/strong>. If <strong>Foo<\/strong> is a pointer type, the compiler can implement the sentinels just as pointer values that are guaranteed not to point at real objects, just as C and C++ do, so there's no loss of efficiency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is part of the ALFE types series. Foo? is a \"Maybe\" type, also known as an option type. It is syntactic sugar for Maybe&lt;Foo&gt;. This type has values of Null (a type with only one value) and Just&lt;Foo&gt; (which is derived from Foo) - it's equivalent to Null | Just&lt;Foo&gt;. This is particularly handy [&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-1847","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\/1847","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=1847"}],"version-history":[{"count":4,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1847\/revisions"}],"predecessor-version":[{"id":1849,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1847\/revisions\/1849"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=1847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=1847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=1847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}