{"id":23714,"date":"2023-05-09T02:29:34","date_gmt":"2023-05-09T02:29:34","guid":{"rendered":"https:\/\/www.booksofall.com\/?post_type=product&#038;p=23714"},"modified":"2023-05-09T02:29:53","modified_gmt":"2023-05-09T02:29:53","slug":"category-theory-for-programmers","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/","title":{"rendered":"Category Theory for Programmers"},"content":{"rendered":"<h2>Category: The Essence of Composition<\/h2>\n<p>A category is an embarrassingly simple concept. A category consists of <i>objects\u00a0<\/i>and\u00a0<i>arrows\u00a0<\/i>that go between them. That\u2019s why categories are so easy to represent pictorially. An object can be drawn as a circle or a point, and an arrow\u2026 is an arrow. (Just for variety, I will occasionally draw objects as piggies and arrows as fireworks.) But the essence of a category is\u00a0<i>composition<\/i>. Or, if you prefer, the essence of composition is a category. Arrows compose, so if you have an arrow from object A to object B, and another arrow from object B to object C, then there must be an arrow \u2014 their composition \u2014 that goes from A to C.<\/p>\n<h4>1.1 Arrows as Functions<\/h4>\n<p>Is this already too much abstract nonsense? Do not despair. Let\u2019s talk concretes. Think of arrows, which are also called\u00a0<i>morphisms<\/i>, as functions. You have a <a href=\"https:\/\/www.britannica.com\/science\/function-mathematics\">function<\/a> f that takes an argument of type A and returns a B. You have another function g that takes a B and returns a C. You can compose them by passing the result of f to g. You have just defined a new function that takes an A and returns a C.<\/p>\n<p id=\"nUBEvTx\"><img loading=\"lazy\" decoding=\"async\" width=\"645\" height=\"365\" class=\"alignnone size-full wp-image-23718 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/05\/img_6459ae10b88d3.png\" alt=\"\" \/><\/p>\n<p>In math, such composition is denoted by a small circle between functions: ? \u2218 ? . Notice the right to left order of composition. For some people this is confusing. You may be familiar with the pipe notation in Unix, as in:<\/p>\n<p>lsof | grep Chrome<\/p>\n<p>or the chevron &gt;&gt; in F#, which both go from left to right. But in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mathematics\">mathematics<\/a> and in <a href=\"https:\/\/www.tutorialspoint.com\/haskell\/haskell_functions.htm\">Haskell<\/a> functions compose right to left. It helps if you read g\u25e6f as \u201cg <i>after\u00a0<\/i>f.\u201d<\/p>\n<p>Let\u2019s make this even more explicit by writing some <a href=\"https:\/\/en.wikipedia.org\/wiki\/C_(programming_language)\">C code<\/a>. We have one function f that takes an argument of type A and returns a value of type B:<\/p>\n<p>B f(A a);<\/p>\n<p>and another:<\/p>\n<p>C g(B b);<\/p>\n<p>Their composition is:<\/p>\n<p>C g_after_f(A a)<br \/>\n{<br \/>\nreturn g(f(a));<br \/>\n}<\/p>\n<p>Here, again, you see right-to-left composition: g(f(a)); this time in C.<\/p>\n<p>I wish I could tell you that there is a template in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/C%2B%2B_Standard_Library\">C++ Standard Library<\/a> that takes two functions and returns their composition, but there isn\u2019t one. So let\u2019s try some Haskell for a change. Here\u2019s the declaration of a function from A to B:<\/p>\n<p>f :: A -&gt; B<\/p>\n<p>Similarly:<\/p>\n<p>g :: B -&gt; C<\/p>\n<p>Their composition is:<\/p>\n<p>g . f<\/p>\n<p>Once you see how simple things are in Haskell, the inability to express straightforward functional concepts in C++ is a little embarrassing. In fact, Haskell will let you use Unicode characters so you can write com- position as:<\/p>\n<p><span dir=\"ltr\" role=\"presentation\">g<\/span> <span dir=\"ltr\" role=\"presentation\">\u25e6<\/span> <span dir=\"ltr\" role=\"presentation\">f<\/span><\/p>\n<p>You can even use Unicode double colons and arrows:<\/p>\n<p>f \u2237 A \u2192 B<\/p>\n<p>So here\u2019s the first Haskell lesson: Double colon means \u201chas the type of\u2026\u201d A function type is created by inserting an arrow between two types. You compose two functions by inserting a period between them (or a Unicode circle).<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/category-theory-for-programmers-1clkjpk7ak?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23719,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!"},"product_brand":[],"product_cat":[385],"product_tag":[],"class_list":{"0":"post-23714","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-theoretical-computer-science","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Category Theory for Programmers - BooksOfAll Portuguese<\/title>\n<meta name=\"description\" content=\"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Category Theory for Programmers - BooksOfAll Portuguese\" \/>\n<meta property=\"og:description\" content=\"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Portuguese\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-09T02:29:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\" \/><meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"827\" \/>\n\t<meta property=\"og:image:height\" content=\"1169\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/\",\"url\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/\",\"name\":\"Category Theory for Programmers - BooksOfAll Portuguese\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\",\"datePublished\":\"2023-05-09T02:29:34+00:00\",\"dateModified\":\"2023-05-09T02:29:53+00:00\",\"description\":\"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"Category Theory for Programmers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/pt\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Category Theory for Programmers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#website\",\"url\":\"https:\/\/www.booksofall.com\/pt\/\",\"name\":\"BooksOfAll Portuguese\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/pt\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#organization\",\"name\":\"BooksOfAll Portuguese\",\"url\":\"https:\/\/www.booksofall.com\/pt\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Portuguese\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Category Theory for Programmers - BooksOfAll Portuguese","description":"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/","og_locale":"pt_PT","og_type":"article","og_title":"Category Theory for Programmers - BooksOfAll Portuguese","og_description":"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!","og_url":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/","og_site_name":"BooksOfAll Portuguese","article_modified_time":"2023-05-09T02:29:53+00:00","og_image":[{"url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","type":"","width":"","height":""},{"width":827,"height":1169,"url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","twitter_misc":{"Tempo estimado de leitura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/","url":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/","name":"Category Theory for Programmers - BooksOfAll Portuguese","isPartOf":{"@id":"https:\/\/www.booksofall.com\/pt\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","datePublished":"2023-05-09T02:29:34+00:00","dateModified":"2023-05-09T02:29:53+00:00","description":"Category theory provides framework for understanding the structure of systems, which is relevant for computer science and programming. Learn more here!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/"]}]},{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#primaryimage","url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","contentUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2023\/05\/Category-Theory-for-Programmers.jpg","width":"827","height":"1169","caption":"Category Theory for Programmers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/pt\/category-theory-for-programmers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/pt\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/pt\/categories\/"},{"@type":"ListItem","position":3,"name":"Category Theory for Programmers"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/pt\/#website","url":"https:\/\/www.booksofall.com\/pt\/","name":"BooksOfAll Portuguese","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/pt\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/pt\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-PT"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/pt\/#organization","name":"BooksOfAll Portuguese","url":"https:\/\/www.booksofall.com\/pt\/","logo":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/pt\/wp-content\/uploads\/sites\/8\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Portuguese"},"image":{"@id":"https:\/\/www.booksofall.com\/pt\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product\/23714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/media\/23719"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/media?parent=23714"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_brand?post=23714"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_cat?post=23714"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/pt\/wp-json\/wp\/v2\/product_tag?post=23714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}