'when' macro, 'simplify' function, and 'visit' function