Implement `when` directive.

Closes #61.