Most undergraduates take a compiler course in which they implement
C, Java or Scheme. I have yet to see a course at any university,
however, in which Haskell is used as the project language. [...] The
closest project I’ve seen to this is a minimal Haskell dialect
called duet.
Ben Lynn has been working on such a Haskell compiler[0], self-hosting and with IO too. It's a little unusual in its approach to compilation (targets combinatory logic and executes via graph reduction), but it's a great example nonetheless, from which one could build an undergraduate course.Code generation is a difficult issue, compiling a lazy functional language to assembly could easily fill up two semesters of classes alone.
The VM in C is really small and the compiler can be built up incrementally[1].