mkInferType' :: (Ord a, UnificationContext e m (TyAst ki ty) (TyAstVar a), MonadError e m, AsUnknownTypeError e)
        => (Term ki ty pt tm a -> UnifyT ki ty a m (Type ki ty a))
        -> ([UConstraint (TyAst ki ty) (TyAstVar a)] -> m (M.Map (TyAstVar a) (TyAst ki ty (TyAstVar a))))
        -> Term ki ty pt tm a
        -> m (Type ki ty a)
mkInferType' go unifyFn x = do
  (ty, cs) <- runWriterT $ go x
  let ty' = review _Unwrapped ty
  s <- unifyFn cs
  let ty'' = mapSubst _TyAstVar s ty'
  return $ review _Wrapped ty''
mkInferType' :: (Ord a, UnificationContext e m (TyAst ki ty) (TyAstVar a), MonadError e m, AsUnknownTypeError e)
        => (Term ki ty pt tm a -> UnifyT ki ty a m (Type ki ty a))
        -> ([UConstraint (TyAst ki ty) (TyAstVar a)] -> m (M.Map (TyAstVar a) (TyAst ki ty (TyAstVar a))))
        -> Term ki ty pt tm a
        -> m (Type ki ty a)
mkInferType' go unifyFn x = do
  (ty, cs) <- runWriterT $ go x
  let ty' = review _Unwrapped ty
  s <- unifyFn cs
  let ty'' = mapSubst _TyAstVar s ty'
  return $ review _Wrapped ty''
mkInferType' go unifyFn x = do
  (ty, cs) <- runWriterT $ go x
  let ty' = review _Unwrapped ty
  s <- unifyFn cs
  let ty'' = mapSubst _TyAstVar s ty'
  return $ review _Wrapped ty''