Hi Haskell-Cafe,<div><br></div><div>Consider a data type such as</div><div><br></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">data Binding = Binding Var (Either Value [Value])</font></div>
<div><br></div><div>representing a variable bound either to a fixed value or that has a list of possible values.</div><div><br></div><div>I&#39;d like to perform an operation on say, the fixed-value members of a list of bindings. <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">Data.Either</font> has &quot;<font class="Apple-style-span" face="&#39;courier new&#39;, monospace">partitionEithers</font>&quot;---I&#39;d essentially like to use partitionEithers, but in a way that it &quot;peeks&quot; into the value field of the binding. For the sake of argument, let&#39;s say I can&#39;t or can&#39;t modify <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">Binding</font> to move the <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">Either</font> to the outside.</div>
<div><br></div><div>What would be an idiomatic Haskell way to accomplish this? Currently I&#39;ve got &quot;<font class="Apple-style-span" face="&#39;courier new&#39;, monospace">liftedPartitionEithers :: [a] -&gt; (a -&gt; Either b c) -&gt; ([a], [a])&quot;</font> which is my own version of <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">partitionEithers</font> that calls a selector first. Another option would be to map each Binding to a new datatype that has the Either on the outside, use partitionEithers, and map back.</div>
<div><br></div><div>Thanks,<br>Aran</div><div><br></div><div><br></div><div><br></div>