tag:blogger.com,1999:blog-22587889.post5226755050089626353..comments2017-04-22T23:46:38.498+05:30Comments on Ruminations of a Programmer: Does category theory make you a better programmer ?Debasish Ghoshhttps://plus.google.com/106871002817915335660noreply@blogger.comBlogger22125tag:blogger.com,1999:blog-22587889.post-23219566033389789262015-08-08T00:00:34.139+05:302015-08-08T00:00:34.139+05:30Hello Akram -
Thanks for the kind words. Also it ...Hello Akram -<br /><br />Thanks for the kind words. Also it feels good to hear that you find my latest book interesting enough.Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-12972365072440263312015-08-07T19:06:07.787+05:302015-08-07T19:06:07.787+05:30Hi Debasish - As I returned to re-read this fantas...Hi Debasish - As I returned to re-read this fantastic post, I glanced at my prior comment and cringed upon realizing that I had inadvertently mixed up your name with the name of a good friend of mine... My apologies!<br /><br />BTW, I'm looking forward to buying your book <b><a href="http://manning.com/ghosh2/" rel="nofollow">Functional and Reactive Domain Modeling</a></b> as soon as it's published - Another friend of mine here in Austin (Texas) is, in fact, currently reviewing your upcoming book through Manning Publications' MEAP process, and has a lot of good things to say about it!<br /><br />Best,<br />AkramAkram Ahmadhttp://www.blogger.com/profile/14201606904750701863noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-15912090137406013282015-07-29T18:31:17.018+05:302015-07-29T18:31:17.018+05:30Ashish, your book DSLs in Action (Manning) is one ...Ashish, your book <i>DSLs in Action</i> (Manning) is one of my favorites! I recently reviewed on my blog the best Scala books in print (<b><a href="http://programming-digressions.blogspot.com/" rel="nofollow">Programming Digressions</a></b>). Given how your fine book has fantastic portions dealing with Scala in the DSL world, I made sure to mention some details about your book in my comments that accompany that particular blog - Keep up your great work!Akram Ahmadhttp://www.blogger.com/profile/14201606904750701863noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-45214768396776556402015-06-04T12:33:17.067+05:302015-06-04T12:33:17.067+05:30I started with Conceptual Mathematics (http://www....I started with Conceptual Mathematics (http://www.amazon.com/Conceptual-Mathematics-First-Introduction-Categories/dp/052171916X), which does a great job teaching the basics.Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-50136232061724188632015-06-04T12:27:04.235+05:302015-06-04T12:27:04.235+05:30Can you recommend any good introductory books on c...Can you recommend any good introductory books on category theory from programmers ?piyushmaheshhttp://www.blogger.com/profile/11078759951817026087noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-84617951705337576852012-12-12T09:03:06.558+05:302012-12-12T09:03:06.558+05:30Good article.Good article.Best Traininghttp://www.besttraining.com.au/noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-66342958143094125782012-09-18T23:30:28.780+05:302012-09-18T23:30:28.780+05:30I think providing good and fast software solutions...I think providing good and fast software solutions for normal people's problems makes you a good dev. This one: <a href="http://www.kammerath.co.uk/The-Joys-of-functional-programming-in-Scala.html" rel="nofollow">Scala programming</a> pretty much describes some Scala things. I find it quite important to ensure people are able to use your software. To be honest I never found a client who was really interested in what type of language is in the background. Most users don't care...Jan Kammerathhttp://www.blogger.com/profile/00119010240516864739noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-75194700547193892822012-09-07T10:56:31.305+05:302012-09-07T10:56:31.305+05:30It’s hard to find knowledgeable people on this top...It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thank you and giving great information about how to make better programmer.<br />seanbellhttp://brendanbarnett.yolasite.com/noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-80877915015956332872012-08-06T15:41:46.600+05:302012-08-06T15:41:46.600+05:30Rob - Thanks for pointing out .. fixed.Rob - Thanks for pointing out .. fixed.Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-50733367305559838022012-08-06T15:20:38.482+05:302012-08-06T15:20:38.482+05:30The first sentence following the third snippet loo...The first sentence following the third snippet looks incorrect. Aren't the last two expressions typewise equal to f and g respectively (rather than to each other)?Robhttp://www.blogger.com/profile/13437579402617554176noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-6169351425175960222012-08-02T15:39:46.365+05:302012-08-02T15:39:46.365+05:30Exactly!Exactly!Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-28841333603141017062012-08-02T15:31:55.889+05:302012-08-02T15:31:55.889+05:30Ah, got it!
There are no *instances* of type Noth...Ah, got it!<br /><br />There are no *instances* of type Nothing, but there are *expressions* of type nothing (a diverging computation). And then, indeed, there are no products, if as your element you take such a computation.<br /><br />Thanks,<br />AdamAdam Warskihttp://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-44701535479448450742012-08-02T14:24:46.497+05:302012-08-02T14:24:46.497+05:30I am not sure I get your question ..
However in c...I am not sure I get your question ..<br /><br />However in categorical domain, we don't have the bottom. Hence the equations hold good. While in the programming model, unless we assume a strong functional model, the bottom is the spoilsport.<br /><br />But I think you are pointing to something else ..Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-85722395656907840632012-08-02T14:09:28.752+05:302012-08-02T14:09:28.752+05:30Hmm aren't some levels mixed here?
For a cate...Hmm aren't some levels mixed here?<br /><br />For a categorical product we need the diagram to commute and the product object to be unique up to isomorphism, that is ;pi_1 = f etc., there's no notion of "elements" of the objects, as the (fst p, snd p) = p formula could suggest.<br /><br />The data type _|_ (Nothing in Scala) in uninhabited, that is there are no instances of this type. So we can take "a" p, as there is none.Adam Warskihttp://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-62760408178041309382012-08-02T10:09:55.218+05:302012-08-02T10:09:55.218+05:30For a Product type we need to satisfy the followin...For a Product type we need to satisfy the following rules (easier to explain in Haskell):<br /><br />fst (a, b) = a // _1 in Scala<br />snd (a, b) = b // _2 in Scala<br /><br />In order to be a categorical product it also has to satisfy the following rule for a product type p:<br /><br />(fst p, snd p) = p<br /><br />Now if you substitute _|_ for p, then you get<br /><br />(_|_, _|_) = _|_<br /><br />which fails in Haskell, since the above is false.<br /><br />A categorical product for Haskell would be unlifted, and would be considered non-bottom if either component were non-bottom, but bottom if both were. But we don't have those available.<br /><br />The above explanation is from Dan Doyle's comment in James Iry's blog post that I referred to in the article (http://james-iry.blogspot.in/2011/05/why-eager-languages-dont-have-products.html#comment-201436254).<br /><br />Hope this helps ..Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-12024802998107411192012-08-01T23:41:55.405+05:302012-08-01T23:41:55.405+05:30Hello,
nice article!
One thing I don't unders...Hello,<br /><br />nice article!<br />One thing I don't understand, why: "... the Product type fails miserably in presence of the Bottom data type (_|_) represented by Nothing ..."?<br /><br />AdamAdam Warskihttp://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-81456354316065775282012-07-31T08:56:02.432+05:302012-07-31T08:56:02.432+05:30Some good discussions on proggit .. http://www.red...Some good discussions on proggit .. http://www.reddit.com/r/programming/comments/xdz76/does_category_theory_make_you_a_better_programmer/ and Google+ https://plus.google.com/101021359296728801638/posts/GzNEMhGRcpYDebasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-70358322265504451502012-07-31T03:18:03.527+05:302012-07-31T03:18:03.527+05:30Strictly speaking, products are not defined as set...Strictly speaking, products are not defined as sets of tuples. The tuples are just a realization of a product in a specific category (the category of sets is the simplest example). In fact, in pure category theory there is no such thing as a set or an element. In this way, you can define things like the category of types, which has absolutely nothing to do with sets.<br /><br />It's an important fact that <i>not all categories have products.</i> A category with products is a strong assumption, and if you talk about "elements" of sets in your category, then you're probably working under the assumption that your category is abelian. At least, this is the main content of the Freyd-Mitchell embedding theorem, which says that every abelian category can be thought of as a category of R-modules (and hence, of sets).j2kunhttp://www.blogger.com/profile/08041921049916424212noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-11694550819798727112012-07-30T20:59:23.496+05:302012-07-30T20:59:23.496+05:30Hi Tim -
Consider the definition of a Cartesian p...Hi Tim -<br /><br />Consider the definition of a Cartesian product between 2 Sets. In category theory, we define it as follows:<br />For all sets C, if there exists a morphism f: C -> A and g: C -> B, then there exists a *unique* h given by h: C -> A × B (typically written ) such that π1 ◦ h = f and π2 ◦ h = g.<br />The object C exists to show that the morphism h: C -> A x B is unique upto isomorphism. In other words, if we have 2 such objects C1 and C2, such that both C1 and C2 morph to A x B (and either of them can be called the Product of A and B), then C1 is isomorphic to C2.<br />In terms of the programming model, if we had C1 as Int and C2 as XInt (some other type), but both map to the product of Int x String, then we can say that Int is isomorphic to XInt. This goes to show that for every pair of Scala types, the Product or Tuple2 is uniquely defined.<br />Does this clear things a bit ?Debasish Ghoshhttp://www.blogger.com/profile/01613713587074301135noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-57122561944218912342012-07-30T19:19:14.002+05:302012-07-30T19:19:14.002+05:30Thank you for this Debashish, it's really enli...Thank you for this Debashish, it's really enlightening. However, I'm having a little trouble working out what the category 'C' denotes in your sum and product examples - the types of 'f' and 'g' in the scala example of a product seem to suggest that C is the type Integer (and is therefore the same as A?) - but I'm having a hard time seeing the significance of this (or indeed working out what the types of f, g, and [f,g] should be for the 'sum' example. Might you be able to shed some light on this?<br /><br />Thanks,<br /><br />TimTimhttp://www.blogger.com/profile/12034234138335949178noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-9363537983846711432012-07-30T18:21:04.720+05:302012-07-30T18:21:04.720+05:30Hi Debasish, great post, thanks!Hi Debasish, great post, thanks!Erikhttp://www.blogger.com/profile/02171032058375638764noreply@blogger.comtag:blogger.com,1999:blog-22587889.post-72916053531911615332012-07-30T17:54:06.648+05:302012-07-30T17:54:06.648+05:30Hi there, You have done an excellent job. I'l...Hi there, You have done an excellent job. I'll certainly digg it and personally recommend to my friends. I'm confident they'll be benefited from this site.<br /><i>My web blog</i> - <b><a href="http://www.gcrit.com/scripting-languages/" rel="nofollow">scripting vs programming language</a></b>Anonymousnoreply@blogger.com