Comment by winwang
13 hours ago
I think it depends on what you mean by "is a function". You can think of a constant, `x` as `x_: () -> {x}` (i.e. everything can be indirected). It could be argued that this is "philosophically" "useful" since getting (using) the value of `x`, even as an actual constant, requires at the least loading it as an immediate into the ALU (or whatever execution unit).
Even non-functional relations can be turned into functions (domain has to change). Like a circle, which is not a function of the x-axis, can be parameterized by an angle theta (... `0 <= theta < 2pi`)
That we can add structure to something doesn't mean the something is the structure. Part of the problem is op didn't define their domain. Is a civil war a function? A dog? Okay, keep it within math/programming, fair enough. A set is not a function. It just isn't. Can you wrap it in a function that maps NULL->set()? Sure, but that is a different thing. It is a function that returns a set, it is not a set. Is 3 a set because I can construct {3}? No, 3 is a natural number, which in that construct is an element of the set. A group is a set of elements with a certain properties (binary op, unity/neutral element, inverse, etc). That doesn't make the group equal to a field (the elements might be members of a field, such as the reals). It is composed of elements of a field. Different things.
I'm taking a more mathematical than programming stance here, but op didn't define their domain, and all this originally came from math, so I'm comfortable with that choice.
But, take rand(), which programmers call a function. Is that a function? Certainly not in the mathematical definition, which requires a unique output for every input. We can use your null wrapper to force it to take an input, but the codomain is not a one-to-one mapping, to say the least.
Or even take an array. I disagree it is a function. A const array, sure. My arrays tend to mutate, and there goes that 1->1 mapping.
I think in this context, it is function as in a lambda in LC.
The answer is pretty much, yes, everything can be a function. e.g. A KV Map can be a function "K -> Maybe V"
P.S. If this style of thinking appeals to you, go read Algebra Driven Design! https://leanpub.com/algebra-driven-design