Posts

Showing posts with the label category-theory

Is Haskell's `Const` Functor analogous to the constant functor from category theory?

18 1 I understand that many of the names in Haskell are inspired by category theory terminology, and I'm trying to understand exactly where the analogy begins and ends. The Category Hask I already know that Hask is not (necessarily) a category due to some technical details about strictness/laziness and seq , but let's put that aside for now. For clarity, The objects of Hask are concrete types, that is, types of kind * . This includes function types like Int -> [Char] , but not anything that requires a type parameter like Maybe :: * -> * . However, the concrete type Maybe Int :: * belongs to Hask . Type constructors / polymorphic functions are more like natural transformations (or other more general maps from Hask to itself), rather than morphis...

Can the composite pattern be used to generate HTML from a tree and handle the indenting as well, or this inherently not possible?

6 I watched this video on the composite pattern, where the main example is how to use the pattern as a mean to generate HTML code from a tree structure describing a todo list where each item can be in turn a todo list, and it seems a convenient test-bed, so here it is a target HTML: [ ] Main <ul> <li>[ ] 1.</li> <li>[ ] 2. <ul> <li>[ ] 2.1</li> <li>[ ] 2.2</li> </ul> </li> <li>[ ] 3.</li> </ul> (Sorry if the top [ ] Main doesn't make sense, but I don't know HTML; furthermore that's irrelevant to my question, I believe.) I understand that design patterns are mostly an OOP "thing", however I'm often referring to the article Design P...