Hacker News new | past | comments | ask | show | jobs | submit login

I like that the article starts with describing Functor as "something almost every developer knows about". That might be a bit of a stretch. I would say almost all developers has interacted with what could be called a functor, but knowing the concept is something different. In certain areas it is starting to get well known though.



I agree, though I think developers should be aware of type-parameters, and should be aware that if A is a subtype of B then List[A] should be considered a subtype of List[B] (which turns List into a functor on types by inclusion). In fact I reckon almost every developer is aware of these things but perhaps doesn't realise the underlying pattern.


> if A is a subtype of B then List[A] should be considered a subtype of List[B]

Well, careful -- I'm sure you know this by your name, but the naive treatment of Java's native array type as A[] <: B[] when A <: B leads to well-known soundness issues.

Fundamentally that's because you can both read and write to Java's arrays; if you assume arrays are read-only then A[] <: B[] is indeed sound.


Yeah I was thinking of the read only kind, you do need to be a bit careful when your objects are mutable ;-)




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

Search: