Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

1. Please keep getting carried away

2. I completely didn't understand how a functor can make a list. Note, to me, a functor is a C++ class that overrides operator(). I loved how your writeup allowed me to understand Cosmos concepts _without_ learning Prolog, so an introduction to functors (maybe a later blog post?) would be warmly appreciated :-)



Yes, C++ is notorious for abusing the “functor” concept in the way you mention. Compare the Wikipedia article: http://en.wikipedia.org/wiki/Functor

A better way to describe a class that defines the »operator apply« is “function object”, as it is called in Lisp.


What the designer calls "functors" just appear to be positional records (or labeled tuples). In Lisp, a list is a series of nested pairs with an empty list as the last element: `(a . (b . ())`. The data structures the designer calls "functors" are just labeled pairs. The Lisp empty list, `()`, is the Cosmos term `Cons`, the Lisp pair `(a . ())` is the Cosmos compound term `Cons(a, Cons)`.


To me, a functor is a ML function from modules to modules :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: