Spacing setting of math mode

Assuming you don't need the thing in subscripts or superscripts, the easiest way is to exit from math mode, doubling the \thinmuskip, reentering math mode, typesetting the lists and go back.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\cls}[2]{%
  \mathord{\mbox{%
    \thinmuskip=2\thinmuskip
    $(#1\mid#2)$%
  }}%
}

\begin{document}

$( a, b,c,d \mid e,f,g,h)$

$(a,\, b,\, c,\, d \mid e,\, f,\, g,\, h)$

$\cls{a,b,c,d}{e,f,g,h}$

\end{document}

enter image description here

A different solution that allows for resizing the parentheses as usual for commands defined with \DeclarePairedDelimiter, see the examples. It also has a friendlier syntax.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\AtBeginDocument{\mathchardef\clscomma=\mathcode`, }

\ExplSyntaxOn
\NewDocumentCommand{\cls}{som}
 {
  \group_begin:
  \IfBooleanTF{#1}
   {
    \hs_cls_auto:n { #3 }
   }
   {
    \hs_cls_manual:nn { #2 } { #3 }
   }
  \group_end:
 }

\cs_new_protected:Nn \hs_cls_auto:n
 {
  \__hs_cls_activate_comma:
  \__hs_cls_activate_bar:n { \;\middle\vert\; }
  \left( #1 \right)
 }

\cs_new_protected:Nn \hs_cls_manual:nn
 {
  \__hs_cls_activate_comma:
  \__hs_cls_activate_bar:n { \__hs_cls_mid:n {#1} }
  \__hs_cls_open:n {#1} #2 \__hs_cls_close:n {#1}
 }

\cs_new_protected:Nn \__hs_cls_activate_comma:
 {
  \char_set_active_eq:nN { `, } \__hs_cls_comma:
  \mathcode`,="8000 \scan_stop:
 }

\cs_new_protected:Nn \__hs_cls_comma: { \clscomma\, }

\cs_new_protected:Nn \__hs_cls_activate_bar:n
 {
  \cs_set_protected:Nn \__hs_cls_bar: { #1 }
  \char_set_active_eq:nN { `| } \__hs_cls_bar:
  \mathcode`|="8000 \scan_stop:
 }

\cs_new_protected:Nn \__hs_cls_open:n
 {
  \tl_if_novalue:nTF { #1 } { ( } { \mathopen{#1(} }
 }
\cs_new_protected:Nn \__hs_cls_mid:n
 {
  \tl_if_novalue:nTF { #1 } { \mid } { \mathrel{#1\vert} }
 }
\cs_new_protected:Nn \__hs_cls_close:n
 {
  \tl_if_novalue:nTF { #1 } { ) } { \mathclose{#1)} }
 }
\ExplSyntaxOff

\begin{document}

$( a, b,c,d \mid e,f,g,h)$

$(a,\, b,\, c,\, d \mid e,\, f,\, g,\, h)$

$\cls{a,b,c,d|e,f,g,h}$

$\cls[\Big]{a,b,c,d|e,f,g,h}$

$\cls*{\dfrac{a}{2},b,c,d|e,f,g,h}$

\end{document}

enter image description here


You can process each of the two lists (left and right) using etoolbox and a cunning delimiter trick:

enter image description here

\documentclass{article}

\usepackage{etoolbox}

% https://tex.stackexchange.com/a/89187/5764
\newcommand{\printlist}[2][,]{%
  \def\itemdelim{\def\itemdelim{#1}}% Item delimiter delayed by one cycle
  \renewcommand*{\do}[1]{\itemdelim##1}% How each item is processed
  \docsvlist{#2}}% Process CSV list

\makeatletter
\def\@LandR#1|#2\relax{\def\leftlist{#1}\def\rightlist{#2}}%
\def\LandR#1{%
  \@LandR#1\relax
  \left( % Left bracket
  \edef\x{\noexpand\printlist[,\,]{\leftlist}}\x
  \,\middle|\, % Middle divider
  \edef\x{\noexpand\printlist[,\,]{\rightlist}}\x
  \right) % Right bracket
}
\makeatother

\begin{document}

$\left( a, b, c, d | e, f, g, h \right)$

$\LandR{a, b, c, d | e, f, g, h}$

\end{document}

Each list is printed using \printlist[,\,], which adds a small space \, after each delimiter ,. You can adjust the layout of the left/right bracket and middle divider.

If you wish to include larger constructions, you may need to use \noexpand, as in

\LandR{\noexpand\frac{a}{b}, c, d, e | f, g, h, \noexpand\frac{i}{j}}