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

"And they might be right. But mathematical functions have one big advantage over non-mathematical ones — their type signature tells you everything that the function does. This is probably the reason why most functional languages are strongly-typed."

I'm confused about this statement. types give you important contextual information about the function in a summarized form, but surely we can have two functions with the same type signature that perform different mappings.



> surely we can have two functions with the same type signature that perform different mappings.

Yes - and you can count the mappings! Enums are sometimes referred to as 'sum types' because you can just add up the number of different states they can be in. Structs are sometimes call 'product types' because you can calculate the number of states they can be in by multiplying the number of states of their members. And functions are 'exponential types'.


This might be true in a programming language but it’s not for mathematical functions which is what they refer to in the first half of this paragraph.

I think what they mean is that two functions won’t have the exact same signature and result typings, though in practice this isn’t normally true for computer systems. Although there’s an argument that if it has those exact same things maybe you don’t need two functions but to improve your one function to be more robust.




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

Search: