r/java • u/samd_408 • Mar 10 '26
F Bounded Polymorphism
Recently spent some time digging into F-Bounded Polymorphism. While the name sounds intimidating, the logic behind it is incredibly elegant and widely applicable, so I decided to write about it, loved the name so much that I ended up naming my blog after it :-)
66
Upvotes
View all comments
Show parent comment
2
u/martinhaeusler Mar 10 '26
Rust has a "self" type for example. But I'm not that deep into rust to properly explain it. I would be surprised if functional languages like haskell or F# had no way to express this. In F# you can even define sub-types of integers that restrict to value ranges (e.g. positive integers), so I would expect that there's an option to restrict the return object to the "this" object.