-- | Instantiates a generic expression with the given type arguments.

term :: TypeEnv -> Term Type -> [Type] -> K (Term Type)
term tenv t args = foldlM go t args
  where
  go (Generic _name x expr _origin) arg = Substitute.term tenv x arg expr
  go _ _ = do