enum Alphabet { A = 'A', B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a = 'a', b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z }; forall( istype & | istream( istype ) | { istype & ?|?( istype &, E & ); } ) istype & ?|?( istype & is, E & e ) { choose ( e ) { case A: is | label( A ); e = A; case B: is | label( B ); e = B; case C: is | label( C ); e = C; } // choose return is; } forall( ostype & | ostream( ostype ) | { ostype & ?|?( ostype &, E ); } ) ostype & ?|?( ostype & os, E e ) { choose ( e ) { case A: os | label( A ); case B: os | label( B ); case C: os | label( C ); } // choose return os; } enum( char * ) Friends { Fred = "FRED", Mary = "MARY", Jane = "Jane" }; forall( istype & | istream( istype ) | { istype & ?|?( istype &, Friends & ); } ) istype & ?|?( istype & is, Friends & friend ) { choose ( friend ) { case Fred: is | label( A ); friend = A; case Mary: is | label( B ); friend = B; case Jane: is | label( C ); friend = C; } // choose return is; } forall( ostype & | ostream( ostype ) | { ostype & ?|?( ostype &, Friends ); } ) ostype & ?|?( ostype & os, Friends friend ) { choose ( friend ) { case Fred: os | value( Fred ); case Mary: os | value( Mary ); case Jane: os | value( Jane ); } // choose return os; } int main() { E e = A; sin | e; sout | e; Friends friend = Mary; sin | friend; sout | friend; }