change typecheck to type inference, add function decl for mapreduce