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

Polymorphic functions are naturally self-documenting. What you are describing is not polymorphic.

The paper "Theorems for free" describes this: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9...

Here's an example... let's say a function has type

[a] -> [a]

Just by looking at that type, the function has a number of properties.

1. The set of items in the result list are a subset (non-proper) of the set of items in the input list

2. Membership in the result list cannot be determined by the values of the members in the input list... ONLY by position

So, some functions that fit this type and therefore fit these properties...

1. id

2. reverse

3. tail



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

Search: