{"id":11210,"date":"2015-05-13T09:42:34","date_gmt":"2015-05-13T13:42:34","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11210"},"modified":"2015-05-13T09:42:34","modified_gmt":"2015-05-13T13:42:34","slug":"maybe-just-and-none-in-objective-c","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/05\/13\/maybe-just-and-none-in-objective-c\/","title":{"rendered":"Maybe, Just, and None in Objective-C"},"content":{"rendered":"<p><a href=\"http:\/\/www.sicpers.info\/2015\/05\/did-that-work-maybe\/\">Graham Lee<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.sicpers.info\/2015\/05\/did-that-work-maybe\/\">\n<p>OK, if everything succeeds you can use the <code>Maybe<\/code> result (which will be <code>Just<\/code> the value) as if it is the value itself.<\/p>\n<p>[&#8230;]<\/p>\n<p>The other case is that your operation failed, so we need to represent that. We need to know <em>what type<\/em> of object you don&rsquo;t have(!), which will be useful because we can then treat the <em>lack<\/em> of value as if it is an instance of the value. How will this work? In <code>None<\/code>, the no-value version of a <code>Maybe<\/code>, we&rsquo;ll just absorb every message you send.<\/p>\n<p>[&#8230;]<\/p>\n<p>The NSError-star-star convention lets you compose possibly-failing messages and find out either that it succeeded, or where it went wrong. But it doesn&rsquo;t encapsulate what would have happened had it gone right, so you can&rsquo;t just rewind time to where things failed and try again. It is possible to do so, simply by encapsulating the idea that something might work&#8230;maybe.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Graham Lee: OK, if everything succeeds you can use the Maybe result (which will be Just the value) as if it is the value itself. [&#8230;] The other case is that your operation failed, so we need to represent that. We need to know what type of object you don&rsquo;t have(!), which will be useful [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[966,857,54,71],"class_list":["post-11210","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-message-passing","tag-nserror","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=11210"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11210\/revisions"}],"predecessor-version":[{"id":11211,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11210\/revisions\/11211"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}