| >Filters tend to run concurrently and, importantly, do not return their results, they pass them on to the next filter in the pipeline. Filters are functions. They are one and the same. For unix it's a function that takes in a string and outputs a string. The unix world reduces everything into a singular type. You will note that unix "filters" cannot compose with functions of "other" types either. If unix included types like arrays or ints in stdout you would have the same typing problems as you have with functions. In the unix world all your types are strings so things seem simpler, but in reality your little unix programs need to deserialize the strings into proper types in order to do anything meaningful. You could achieve the same thing if you used functions that returned strings all the time then did internal deserialization but that's not really a solution. I do get your point about arity and parameter types. You're referring to the fact that not all functions can compose UNLESS they have compatible types and an arity of 1 in the parameters and an arity of 1 in the return value (Golang for example can have arity > 1 in the return value). However this arity issue doesn't really exist. A function with Arity of two is isomorphic to a function of arity 1 that takes in a 2-tuple as input. f(a, b) -> c
f'(Tuple[a, b]) -> c
g(d) -> Tuple[a, b]
Both f' and f are equivalent in theory. Plus you can compose g with f'.The only compatibility problems with composition among functions in the end is just types (not arity) but this problem still exists even in the unix world... it's just hidden from you because you don't actually watch the programs perform deserialization and serialization. |
As I explained before: no they are not.
They have some similarities, but they also have the important differences I outlined above.
The single type is also a restriction relative to the functional model, and crucial to (syntactic) composability.
> If unix included types like arrays or ints in stdout ...
But it doesn't...
> you would have the same typing problems as you have with functions.
...so you don't.
> 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.
> it's just hidden from you
Exactly. It is hidden in Unix and not in FP. That's a difference.
> You could achieve the same thing if you used functions that returned strings
Two points:
(1) you write that you "could" achieve the same thing. Meaning that, once again, they actually are not the same. Otherwise the "could" wouldn't make sense (and it does).
(2) returning strings would not be the same at all, because filters do not "return" their results. They return status codes. The result is not returned, it is passed directly to the next filter, continuously.
So: it is good to recognize that 'X is similar to Y', but that doesn't imply that 'X is just Y'.