typing recursive and mutually recursive functions