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

Generics and composability are orthogonal concepts, to me. I'm not really sure what sort of composability you're talking about. Can you provide an example for me to rip apart?



"Modularity" is nearly defined by the ability to forget certain details of an interface so as to leave freedom to change the underlying details while maintaining the behavior at the interface (Reynold's Abstraction Principle). In almost the same breath one would declare that types are a primary mechanism to achieve this. [0]

    Type structure is a syntactic discipline for
    enforcing levels of abstraction.
Modularity is more or less required in order to take a stab at defining or talking about composability, but is "good" modularity necessary (or sufficient) for achieving composability?

I don't have a bulletproof argument here, but essentially I'd like to say that greater modularity allows you to forget inessential details and subsequently increase the surface area with which you can compose your modules.

So finally, we come to generics as a powerful tool for using types to erase inessential details. Generics essentially operate via providing a new logical structure to types, the ability to introduce and operate sensibly over type variables. So I would argue that a type language without generics is much like a programming language without variables [1]. You are perhaps not completely crippled, but pretty close.

So, my argument is something like "without generics your type language is crippled so as to make control of modularity very weak which will prevent you (syntactically) from ensuring composability".

The "(syntactically)" bit is important since, as we all know, you can achieve modularity and composability "by hand" through code generation, copy and pasting, creating commenting policies... but then we've stumbled back into the "static types versus dynamic types" argument, so let's not rehash it.

[0] https://wiki.mpi-sws.org/star/paramore?action=AttachFile&do=...

[1] These kind of variables, not "mutable cell" style variables: https://existentialtype.wordpress.com/2012/02/01/words-matte...


> generics as a powerful tool for using types to erase inessential details.

That's the key - generics are one way to accomplish things, but they're not the only way.


I wouldn't argue otherwise. Instead, I argued that types are the way and that without generics your type language is crippled.


While that's true, I don't think that's enough to make things "orthogonal," at least as I would use the word.


Anything to do with higher-order functions, least of all

    compose :: (b -> c) -> (a -> b) -> a -> c

?


I think there's a typo in your signature. It should be:

    compose :: (b -> c) -> (a -> b) -> a -> c
Other than that, I agree!


> I think there's a typo in your signature.

You think right, that'll teach me (once again) not to typecheck my comments. Thanks, and fixed.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: