摘要:
Observing intermediate values helps to understand what is going on when your program runs. For lazy functional languages Gill presented an observation method that preserves the program's semantics. However, users need to define for each type how its values are observed: a laborious task and a mistake can yield misleading observations and even cause non-termination. Here we define how any value can be observed based on the structure of its type by applying generic programming. Furthermore, we present an extension to specify per observation point how much to observe of a value. We discuss how to obtain behaviour dependent on class membership with type-generic programming and with meta programming. (C) 2017 Elsevier Ltd. All rights reserved.