What exactly is $\hat{\psi}^\dagger(x)$? An operator or a function? I've recently read Cohen-Tannoudji on quantum mechanics to try to better understand Dirac notation.  A homework problem is giving me some trouble though.  I'm unsure if I've learned enough yet to understand this.
The creation operator is defined as:
$$\hat{a}_k^\dagger = (2 \pi)^{-1/2}\int dx\,e^{ikx} \hat{\psi}^\dagger(x)$$
From my notes, I have $\hat{\psi}(x)$ defined (in one dimension) as:
$$\hat{\psi}^\dagger(x) \lvert 0\rangle = \lvert x\rangle $$


*

*Cohen-Tannoudji says linear operators take a ket vector and associate them with another ket vector within $\mathscr{E}$ space.  $\hat{\psi}^\dagger(x)$ does not look like a linear operator to me.  It looks like an operator-function hybrid.  What do you call this thing?  How is it rigorously defined?  Why is $x$ not a subscript?


Assuming it's a linear operator and proceeding anyway, let's apply $\hat{a}_k^\dagger$ to some  ket vector:
$$\hat{a}_k^\dagger = \left( (2 \pi)^{-1/2}\int dx\,e^{ikx} \hat{\psi}^\dagger(x) \right)\lvert\phi\rangle$$
I assume the order of operation is to apply $\hat{\psi}^\dagger(x)$ first to $\lvert\phi\rangle$, then multiply by $e^{ikx}$, then integrate, then multiply by $(2\pi)^{-1/2}$


*

*How do I integrate over the ket vector $e^{ikx}\hat{\psi}^\dagger(x)\lvert\phi\rangle$?  Such an operation does not seem to be defined.  I can integrate over complex numbers, but not kets. I still don't understand why $k$ is a subscript but $x$ is an operator-function-hybrid variable. What am I missing here?

 A: 
Cohen-Tannoudji says linear operators take a ket vector and associate them with another ket vector within $\mathscr{E}$ space.

That's the correct definition of an operator. Within the scope of quantum mechanics, anything that acts on one quantum state (i.e. ket) to produce another quantum state, in other words anything that can be written as
$$\text{[stuff]}\lvert a\rangle = \lvert b\rangle$$
is an operator. And assuming the transformation rule denoted by $\text{[stuff]}$ satisfies the conditions of linearity, it is further called a linear operator. But for the question you're asking, it's not really relevant whether or not the operator is linear.
Anyway, we have a transformation rule on kets, which I've denoted $\text{[stuff]}$. I use this notation to make the point that literally any combination of symbols which occurs in this context will represent an operator. It doesn't have to be a single letter, it doesn't have to have a hat over it. Sure, $A$ can represent an operator ($A\lvert a\rangle = \lvert b\rangle$), but you could also call an operator $\text{Bob}$ (as in $\text{Bob}\lvert a\rangle = \lvert b\rangle$), or label it with a smiley face. Or, in this case, you could label an operator $\hat{\psi}^\dagger(x)$, which you should think about first and foremost as just some combination of symbols that labels an operator.
Of course, there is a reason that Cohen-Tannoudji et al. choose that particular combination of symbols to label their operator. What you're dealing with here is not just a single, fixed operator, but a whole infinite set of operators, one associated with each spatial point $x$. In other words, $\hat{\psi}^\dagger(x)$ is the output of a mapping of points to operators. This is also known as an operator-valued field. The mapping is implicitly defined by the rule
$$\hat{\psi}^\dagger(x)\lvert 0\rangle = \lvert x\rangle$$
or in words,

$\hat{\psi}^\dagger$ maps the point $x$ to the operator which transforms the state $\lvert 0\rangle$ into the state $\lvert x\rangle$

(I'm assuming that $\lvert x\rangle$ and $\lvert 0\rangle$ have already been suitably defined, and that the operator space is suitably defined and/or restricted such that there is a unique choice of operator which transforms the latter into the former).
When you have an operator field, you can use it in many of the same ways you would use any other function; in particular, you can use it in an integral. Remember that an integral is, in principle, a sum of an infinite number of infinitesimal contributions. When you write something like
$$c = \int\mathrm{d}x f(x)$$
you're computing the product $f(x)\mathrm{d}x$ at every $x$ and adding them all up. You have a rule for adding up function values, so you can turn this integral into a number. Similarly, an integral like
$$\lvert c\rangle = \int\mathrm{d}x\lvert x\rangle$$
is the "weighted" sum of all the kets $\lvert x\rangle\mathrm{d}x$ (where $\mathrm{d}x$ is the "weight") associated with different positions. Unlike the earlier case, you may not be able to directly simplify this integral as is, other than just making up a new symbol for it ($\lvert c\rangle$), but you can "save" it until a later point in the calculation where you are able to do something with it. For example, if you're later asked to compute $\langle y\rvert c\rangle$, you can use the definition of $\lvert c\rangle$ to write
$$\langle y\rvert c\rangle = \langle y\rvert\biggl(\int\mathrm{d}x\lvert x\rangle\biggr) = \int\mathrm{d}x\langle y\rvert x\rangle = \int\mathrm{d}x\delta(y - x) = 1$$
or equivalently,
$$\langle y\rvert c\rangle = \langle y\rvert\biggl(\int\mathrm{d}x\hat{\psi}^\dagger(x)\lvert 0\rangle\biggr) = \int\mathrm{d}x\langle y\rvert \hat{\psi}^\dagger(x) \lvert 0\rangle = \int\mathrm{d}x\delta(y - x) = 1$$
Or if you're later asked to apply an operator to $\lvert c\rangle$, assuming the operator is linear (and thus commutes with integration), you can use the same sort of trick.
Finally, you mentioned being confused as to why $\hat{\psi}^\dagger(x)$ is written in a way that looks like a function but $\hat{a}_k^\dagger$ is written with a subscript. That's just an aesthetic choice; they both mean the same thing. Just as $\hat{\psi}^\dagger(x)$ is the operator associated with the point $x$ by some particular mapping, so $\hat{a}^\dagger_k$ is the operator associated with the wavenumber $k$ by some particular mapping. You could just as well write it as $\hat{a}^\dagger(k)$, or write the other one as $\hat{\psi}^\dagger_x$.
A: An operator is a function1, nothing else. Not any function is an operator (in the sense the word is used in QM); in particular, $\hat\psi^\dagger$ is not an operator. It's a function mapping spatial coordinates $x$ to – operators! We might write it
$$
  \hat\psi^\dagger \colon\quad \mathbb{R}^3 \to (\mathscr{E} \to \mathscr{E}).
$$
Hence, $\hat\psi^\dagger(x) \colon \mathscr{E} \to \mathscr{E}$, i.e. it is just an operator.
Now, that notation with multiple arrows is (unfortunately, IMO) seldom used in physics, but it's used all the time in functional programming. Take a look at any piece of Haskell code, and you'll find plenty of type signatures something like
map :: (a -> b) -> ([a] -> [b])

which looks, I suppose, a bit bewildering at first. But it's quite simple actually; via a very fundamental mathematical technique called (un)currying, we know that a function that returns a function is basically just a function of two arguments:
$$
  A \to (B \to C) \simeq (A,B) \to C
$$
Applied to the Haskell example, this tells us that the map function could be written in a programming language with C-like syntax as something like2
b[] map( (*b)(a) f, a[] vals );

Applied to our quantum mechanics topic, it means we could also write
$$
  \hat\psi^\dagger \colon\quad (\mathbb{R}^3, \mathscr{E}) \to \mathscr{E}
$$

$\hat\psi^\dagger$ is a function taking spatial coordinates and a ket vector, and returning a ket vector.

...which is kind of obvious. The only difference is that we would now write $\hat\psi^\dagger(x, |0\rangle)$ instead of $\hat\psi^\dagger(x)|0\rangle$. The latter, usual way of writing it is, it turns out, much more convenient, but it's really just a trivial syntax transformation.

1 In fact, unbounded operators like position in continuous space are not functions on the whole Hilbert space. They are still functions, but only on a dense subset; in physics this subtlety is often neglected.
2 In actually valid C++, it might be
template<typename A, typename B>
std::list<B> map(std::function<B(A)> f, std::list<A> vals);

A: I don't think it's particularly usefull to distinguish an operator from a function, but maybe this helps: If $x$ is a variable of type $\mathbb R$ and $V$ is a vector space, then for a fixed term $x_0\in \mathbb R$, the object $A(x_0)$ is an operator of type $V\to V$. The object $A(x)$ with $x$ free is of type $\mathbb R\to(V\to V)$.
Something more to think about: Consider the Schrödinger equation 
$$\forall t.\ i \hbar\ \dot \Psi (t)=H \Psi(t)$$
with $\dot \Psi (t):=\frac{\mathrm d\Psi}{\mathrm dt} (t)$. For each fixed $t_0$ the object $\Psi(t_0)$ is an element of the Hilbert space $\mathcal H$. The three objects $\Psi$, $\dot \Psi$ and $H \Psi$ all are of type $\mathbb R\to\mathcal H$. The object $\frac{\mathrm d}{\mathrm dt}$ is of type $(\mathbb R\to\mathcal H)\to(\mathbb R\to\mathcal H)$ and from the Schrödinger equation you'd say so is $H$. What I'm getting at is that in the definition of Hamiltonians, you generally set up objects $H':\mathcal H\to \mathcal H$. 
For example if you define $H':=\sum_k \hbar\omega_k\, a_k^\dagger a_k$. 
To get the expression on the right in the Schrödinger equation from such a $H'$, you must first fix take a vector $\Phi$ and fix $t$, evaluate to $\Psi(t)$ which is of type $\mathcal H$ (and not of type $\mathbb R\to\mathcal H$), then apply $H'$ and finally (lambda) abstract the variable $t$ again. So $H=\lambda\Psi. \lambda t$. So $H=\lambda\Psi.\,\lambda t.\,H'\left(\mathrm{eval}(\Psi,t)\right)$.
See Apply#Universal_property, Lambda_abstraction.
A: You already have lots of great answers to your main question, but there's still some clarity to be had regarding your final point:

How do I integrate over the ket vector $e^{ikx}\hat{\psi}^\dagger(x)\lvert\phi\rangle$?  Such an operation does not seem to be defined.  I can integrate over complex numbers, but not kets.

Essentially, your question boils down to this:

I have a function $f:\mathbb R\rightarrow\mathcal H$ that takes real numbers $x\in\mathbb R$ into vectors $|f(x)\rangle$ in some Hilbert space $\mathcal H$. Is it possible to define the integral 
  $$|F\rangle=\int\text dx \,|f(x)\rangle\text ?$$

To answer this, I'd like to point out that the question itself is independent of whether $\mathcal H$ is finite-dimensional or not (though the answer may be). In particular, for $\mathcal H=\mathbb R^3$ and changing $x$ for some time $t$, you can rephrase this as, say finding the impulse $\mathbf I=\int_{t_1}^{t_2}\mathbf F(t)\text dt$ due to some force $\mathbf F(t)$.
How, then, is one to approach such a problem? One way to do this is to consider Riemann sums of the function over finer and finer grids, and this will be fine where it is defined, in both the finite and infinite-dimensional cases. However, any serious theory of integration should really be dealing with Lebesgue measures and integrals to be of much use, as these are at the heart of all the strong convergence theorems.
To use the strong machinery of Lebesgue integration, the right approach turns out to be a thoughtful take on the naïve idea:
Do it component-by-component.
This is usually what you end up doing in 3D euclidean space anyway, right? Saying "components", though, kind of implies a commitment to a certain basis. To eliminate this, you should see "components" as simply real-valued linear functions on your Hilbert space: $F_i=\hat{\mathbf e}_i \cdot \mathbf F$. The crucial thing, then, is linear functionals, which live in the dual space $\mathcal H^\ast$, otherwise known as bras.
To put this on a firmer basis, then, your integral $|F\rangle$ is defined to coincide with the component-wise integral of your function in any basis.

The integral $|F\rangle=\int\text dx \,|f(x)\rangle$ of a vector-valued function $f:\mathbb R\rightarrow\mathcal H$ is the vector $|F\rangle$ such that 
  $$\langle \phi|F\rangle=\int\text dx \,\langle\phi|f(x)\rangle$$
  for all bras $\langle \phi|\in\mathcal H^\ast$, if such a vector exists.

This now translates the (hard) problem of integrating ket-valued functions into the (easier) problem of integrating complex-valued functions. Of course, this needs a lot more precision as to which classes of bras are allowed and what happens if some of those integrals are undefined or divergent, but those are in my opinion non-crucial details.
However, this just shifts away the problem and hides it inside the weasel phrase "if it exists". You can't simply define your problem away! Given the definition above, you still have the burden of theorem-proof on you to prove that your definition is general enough to include the classes of functions you might find useful. Here's a short sketch of how you prove that the integral does exist, and in which conditions:


*

*Define some sort of acceptable class of bras $\langle \phi|$ on which you want to project.

*Define "integrable ket-valued functions" as those $|f(x)\rangle$such that the complex-valued function $\langle \phi|f(x)\rangle$ is Lebesgue integrable for all acceptable $\langle \phi|$.

*You can then define the integral $\int\text dx \,\langle\phi|f(x)\rangle$ for all acceptable $\langle \phi|$. This is linear in $\langle \phi|$ and it is continuous (so you can linearize over infinite sums as well) for well-behaved enough $|f(x)\rangle$.

*This then defines a continuous linear map $\langle\phi|\mapsto\int\text dx \,\langle\phi|f(x)\rangle\in \mathbb C$; that is, an element of the double dual $\mathcal H^{\ast\ast}$.

*For a reflexive Hilbert space, the double dual is canonically isomorphic to $\mathcal H$, which means that your element of the double dual corresponds to some ket in $\mathcal H$.

*Bingo! that ket is $|F\rangle$.

A: It is just a matter of notations. For some reasons, physicists tends to note position using a function notation $\hat \psi(x)$, and momentum with a subscript $\hat a_k$. It is just a matter of taste $\hat \psi(x)=\hat \psi_x$.
You seem to be confused by the use of a continuous value for the "index" $x$. If you prefer (and I think that is what mathematicians do), you can discretize space and note $x$ as a discrete position. Then the operator $\hat \psi_x^\dagger$ creates a particle at position $x$ and acts on a Fock space for each point in space. Let's say that there is three points in our discretization : $x_1$, $x_2$, $x_3$ and let's note the number of particle at these point as $|n_1,n_2,n_3\rangle$. Then $\hat \psi_{x_1}^\dagger|0,0,0\rangle=|1,0,0\rangle$,  $\hat \psi_{x_2}^\dagger|0,0,0\rangle=|0,1,0\rangle$, etc.
We can also superpose these kets : $|1,0,0\rangle+|0,1,0\rangle=\hat\psi_{x_1}^\dagger|0,0,0\rangle+\hat\psi_{x_2}^\dagger|0,0,0\rangle=\sum_i \alpha_i \hat\psi_i^\dagger|0,0,0\rangle=\hat a^\dagger|0,0,0\rangle$, with the corresponding complex number $\alpha_i$. We see that $\hat a^\dagger=\sum_i \alpha_i \hat\psi_i^\dagger$
In the continuum limit (infinite number of point in space), one usually use the "function notation" $\psi(x)$, and the summations of states/operators become integrals. The Fourier transform of an operator is just the sum of operators with weight $e^{i k x}$.
