added support for reading type variables in functions and defining higher order functions with type vars