In Q#'s type documentation, it is mentioned that you can create signatures like this:
function ConjugateInvertibleWith : (inner: ((Qubit => Unit) : Adjoint), outer : ((Qubit => Unit) : Adjoint)) : ((Qubit => Unit) : Adjoint)
My question is: how is this function actually implemented.
Presumably a function with this name will return an operation that, when invoked, calls outer, then inner, then adjoint outer. However, I have no idea how to actually write a function like this. In particular, it's not clear how to write the equivalent of a lambda with a closure. For example, if I try to declare an operation inside a function (similar to how you can def inside a def in python), I get a syntax error.
Does this have to be done in a non-Q# library, like in C#, then imported into Q#? If so, how?