Let us begin, however, with a sketch of the philosophical environment in which Foucault was educated. He entered the École Normale Supérieure (the standard launching pad for major French philosophers) in 1946, during the heyday of existential phenomenology.
Merleau-Ponty, whose lectures he attended, and Heidegger were particularly important. Hegel and Marx were also major concerns, the first through the interpretation of his work offered by Jean Hyppolite and the latter through the structuralist reading of Louis Althusser—both teachers who had a strong impact on Foucault at the École Normale.
It is, accordingly, not surprising that Foucault's earliest works (his long “Introduction” to Dream and Existence by Ludwig Binswanger, a Heideggerian psychiatrist, and Maladie mentale et personalité, a short book on mental illness) were written in the grip of, respectively, existentialism and Marxism. But he soon turned away quite decisively from both.