Automatic Synthesis of Typed Lambda-Programs on Term Algebras