Designing effects as data structures