implement tagged function abstraction