That said, I wonder if it's at all possible to replace sets (to do all which is founded on sets) with a simple untyped lambda calculus (which I think is "functions at their most abstract") and then re-build mathematics on top of that?
I suppose the idea would be to define sets in terms of lambdas and then show all the set axioms etc...
This occured to me when I noticed that 'standard' set theory defines functions in terms of sets. If sets can be constructed (defined) in terms of lambdas (and types?), then yes to my own question.