| >Functions run to completion and return their result. Filters tend to run concurrently and, importantly, do not return their results, they pass them on to the next filter in the pipeline. Let me address this point so it is more clear. Functions by definition do not need to "run" at all. The underlying implementation of a programming language may "run" a function lazily, eagerly or concurrently but that is not what the Definition of a function is describing. A function is simply a relation between two sets, one set called a codomain, another set called a domain is deterministic. That is all. So within unix piping the domain is stdin, the codomain is stdout, the function is the unix program. This paradigm fits the definition of a function and as long as that "function" remains deterministic and compose-able it fits within the paradigm of functional programming BY definition. there is no need to discuss "similarities" here, because it fits the definition therefore it is functional programming. Of course we can get pedantic about certain non-functional use cases but in basically you are fully aware of the generality I'm describing. No point in getting pedantic. Also keep in mind when you "execute" these functions it does not matter HOW these functions are executing whether concurrently, lazily or eagerly. The only important thing is the relation between the domain and codomain. That is all. >The single type is also a restriction relative to the functional model, and crucial to (syntactic) composability. Every unix program must internally deserialize this string type and serialize it again for output. The typing must be handled regardless. It seems like you don't need to deal with it but it's dealt with regardless. You also get inevitable deserialization problems of incorrect types. You do not escape typing in the unix world. >But they are not actually equal (never mind the same), at least not in typed FP, and most FP is typed. A relation that takes a string from a domain and returns a string that is from a codomain is a function that is part of functional programming. This is EXACTLY what a unix program does when relating stdin to stdout and therefore it IS a function and it is FP By definition. You can look at it from another direction. A function that returns an Array does not fit the definition of what a unix program should output to stdout therefore a function IS NOT a unix program. BUT a unix program IS a function. Formally unix programs are just the set of all functions where the domain and codomains are strings. >>Both f' and f are equivalent in theory.
>But they are not actually equal (never mind the same), at least not in typed FP, and most FP is typed. The mathematical term is "isomorphic" meaning you get the EXACT same properties going one way vs. the other way. It's the syntactic sugar that prevents composition. Using multi-arity functions and single arity functions with tuples only involves two additional parenthesis: f(a, b)
f'((a, b))
It's just syntactic sugar that causes a difference to occur.Arity and tuple types are well described to be isomorphic in category theory. I'm not making this up. One way to think about an isomorphism is that if two things are isomorphic then they are just different perspectives of the exact same thing. Any differences are superficial or illusory. >Exactly. It is hidden in Unix and not in FP. That's a difference. Exactly what? If you're not dealing with the type conversions someone else has too. Just because it's hidden from you doesn't mean it doesn't need to be dealt with. Someone has to serialize things and deserialize it. Even from the command line level you cannot escape types. Let's say you have a unix program that can only take numerical strings from stdin. Let's say you pipe english letters to it... if you do then you will have still triggered a sort of type error despite everything being typed as strings in unix. It's just not handled explicitly as a system error. You cannot escape typing even in the unix world because it is in the end just FP. >So: it is good to recognize that 'X is similar to Y', but that doesn't imply that 'X is just Y'. Except we're not talking about similarity. Like I said above X is just Y BY definition. |
Not sure what else I can do to make you understand this.
As such, I am bowing out as I can only repeat what I’ve written.