Metamorphic programming is an approach to extend the structured recursive programming discipline, which favors the use of fold operations over general recursion, to abstract data types. The key idea is to represent an ADT by two parts, a constructorand a destructor,which are essentially functions to/from a common representation. Then a fold can work on an ADT by applying parameter functions to values that are delivered by the ADT's own destructor. Fold operations that use as a parameter the constructor of another ADT, called ADT transformers,play an important role and offer a concise programming style. Several laws for ADT folds and transformers exist that can be used for program optimization and verification.
Staapl is a collection of abstractions for metaprogramming microcontrollers from within PLT Scheme. The core of the system is a programmable code generator structured around a functional concatenative macro language adapted to a 2-stack machine model. On top of this it includes a syntax frontend for creating Forth style languages, a backend code generator for the Microchip PIC18 microcontroller architecture, and interaction tools for shortening the edit-compile-run cycle. It is structured as a code library to facilitate integration into larger systems employing a model-based design approach. The primary, practical goal is to provide a tool chain for programming low-end (8-bit) microcontrollers in a Forth-style language extended with powerful metaprogramming facilities. The secondary goal is to generalize and modularize this approach and extend it in two directions: to provide a standard machine model as an abstraction point for a large class of small embedded processo