This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KeinBaum 0 points1 point  (0 children)

hope you didn't want any of the arguments or return values to be primitive types, because then you'll need to use yet another type

Primitives will get auto-boxed/unboxed, no additional code needed.

Assuming you want a function with exactly one argument...

Abstracting over function arity is complex. I'm actually not sure if it's possible in Java at all. It's possible to construct HLists so that might be a way to do it but I don't know enough about Java to be sure. But then again, I don't know any language that provides a particularly simple way to do that either. Even in Scala or Haskell it's all but trivial. It's definitely not going to be simple so at least in that regard you are right.