<div dir="ltr">Hey all,&nbsp;<div>Today I had a small exchange with another reddit user about CT and why is important to Haskell programming...&nbsp;</div><div>What I don&#39;t get yet (as the subject says) is a real-world example on where you might apply cathegory theory to a recursion. Here is the small thread :</div>
<div><br></div><div><div>fbru02:</div><div><br></div><div>Sorry for maybe the OT posting but I have a question of my own:</div><div>While learning Haskell and being a curious procrastinator I started learning Category theory but although I get , I don&#39;t get it yet.</div>
<div>What I want to ask is practical uses of cathegory theory ? I know that it is used for high availability systems for theoretical proof that a System has the correct side effects. Also I know there are in reality recursions that might need this stuff as they are not as simple as what one would write in a toy project. What are this recursion schemes ?? What other uses there are for CT?</div>
<div><br></div><div>nbloomf:</div><div><br></div><div>Disclaimer- I am only beginning to understand this stuff myself. I am also a mathematician, not a computer scientist or a professional programmer.</div><div>Two papers that give a good overview of what categories can do are &quot;Functional Programming with Bananas, Lenses, etc.&quot; and &quot;Recursion Schemes from Comonads&quot;.</div>
<div>My understanding of the role of categories in FP (at least partly) is as follows. Arbitrary recursion is very useful to writers of programs. However, like arbitrary GOTOs, it can make it hard to see what&#39;s &quot;really&quot; happening in a program. A long time ago people figured out that fold/reduce was a common recursive pattern, but it was generally only used on lists and couldn&#39;t express all the recursion people wanted to do. More recently it was discovered that if your language is strongly typed, you can think of the types as objects in a category. Then some type constructors become endofunctors, and the traditional fold can be expressed as a particular map, parameterized by the functor, having a nice universal property. Moreover, as the &quot;Recursion schemes from comonads&quot; paper discusses, by parameterizing on the comonad the fold operator can become several different recursion schemes. This means a much smaller amount of code can express a larger number of ideas- even ideas that haven&#39;t been had yet. Moreover, it makes optimizations (such as fold fusion) much more powerful.</div>
<div>So the real power of category theory is as a metalanguage- these ideas might never have become &quot;obvious&quot; without the language of functors, algebras, initial objects, and such.</div><div><br></div><div>fbru02 :</div>
<div>thank you for great response. Have you yourself used this parametraizing of the comonad? In which context or solving which problem and why couldn&#39;t you solving easily making a normal named recursion :D</div><div>
Thanks a lot ! :D</div><div><br></div><div>Thanks !</div></div><div><br></div><div><br>-- <br>Federico Brubacher<br><a href="http://www.fbrubacher.com">www.fbrubacher.com</a><br><br>Colonial Duty Free Shop<br><a href="http://www.colonial.com.uy">www.colonial.com.uy</a><br>

</div></div>