Fix invalid reference to ty

Thanks for the wonderful module does exactly what I was looking for. Seems like there's a small bug in ty.inst.of function referencing ty.fun instead of s.fun.