refactor types from infer.hs to types.hs; fix bug in inferFuncType