{"id":21925,"date":"2018-06-25T14:24:13","date_gmt":"2018-06-25T18:24:13","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21925"},"modified":"2018-06-26T11:03:51","modified_gmt":"2018-06-26T15:03:51","slug":"open-sourcing-nonempty","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/06\/25\/open-sourcing-nonempty\/","title":{"rendered":"Open Sourcing NonEmpty"},"content":{"rendered":"<p><a href=\"https:\/\/www.pointfree.co\/blog\/posts\/7-open-sourcing-nonempty\">Point-Free<\/a> (via <a href=\"https:\/\/twitter.com\/olebegemann\/status\/1011209964596203520\">Ole Begemann<\/a>):<\/p>\n<blockquote cite=\"https:\/\/www.pointfree.co\/blog\/posts\/7-open-sourcing-nonempty\">\n<p>We believe that a compiler proven non-empty type is incredibly important for every developer to have at\ntheir disposal, and so that&rsquo;s why today we are open sourcing our\n<a href=\"https:\/\/github.com\/pointfreeco\/swift-nonempty\">NonEmpty<\/a> library.<\/p>\n<p>[&#8230;]<\/p>\n<p>The core of the library is just a single generic type, <code>NonEmpty&lt;C&gt;<\/code>, which allows you to transform any\ncollection type <code>C<\/code> into a non-empty version of itself. The majority of the code in the library consists\nof conformances on <code>NonEmpty<\/code> to make it act as much like the collection that it wraps.<\/p>\n<p>[&#8230;]<\/p>\n<p>We encourage the reader\nto start looking critically at their own application code, their library API&rsquo;s and their interactions with\nother API&rsquo;s to see where non-empty types might be appropriate. By pushing the non-emptiness requirement to\nthe type level you get to enforce this invariant in a single place rather than sprinkle <code>if<\/code>&rsquo;s and <code>guard<\/code>&rsquo;s\ninto your code.<\/p>\n<\/blockquote>\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2015\/09\/03\/why-dependent-types-matter\/\">Why Dependent Types Matter<\/a>.<\/p>\n\n<p>Update (2018-06-26): <a href=\"https:\/\/twitter.com\/olebegemann\/status\/1011361585024131073\">Ole Begemann<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/olebegemann\/status\/1011361585024131073\">\n<p>Important caveat: because NonEmpty stores its first element separate from the rest, it doesn&rsquo;t necessarily capture all of the underlying collection&rsquo;s semantics. E.g. <code>NonEmpty&lt;Set&lt;Int&gt;&gt;<\/code> doesn&rsquo;t guarantee that all elements are unique unless you take special precautions.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Point-Free (via Ole Begemann): We believe that a compiler proven non-empty type is incredibly important for every developer to have at their disposal, and so that&rsquo;s why today we are open sourcing our NonEmpty library. [&#8230;] The core of the library is just a single generic type, NonEmpty&lt;C&gt;, which allows you to transform any collection [&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":"2018-06-26T15:03:53Z","apple_news_api_id":"68ad1274-c36f-4503-8303-e42b09de2f60","apple_news_api_modified_at":"2018-06-26T15:03:54Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AaK0SdMNvRQODA-QrCd4vYA","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":[74,71,901],"class_list":["post-21925","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-opensource","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21925","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=21925"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21925\/revisions"}],"predecessor-version":[{"id":21931,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21925\/revisions\/21931"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}