You might want to look at Malcolm Wallace's HMake - there is both the code and a paper describing it. Quoting the paper: "hi - hmake interactive - is a small program, itself written in Haskell, which imitates many of the interactive features of Hugs."