Check if the return type matches.

Use ReaderMonad to keep track of the return type of the current function.