<div>Hello,</div><div><br></div><div>I need a function and wonder whether I can copy some existing code so I don&#39;t have to write it myself.</div><div><br></div><div>It should split a string into a list of strings:</div>
<div><br></div><div>    splitAtTopLevelCommas :: String -&gt; [String]</div><div><br></div><div>I need something similar to `splitOn &quot;,&quot;` from the Text package with the property</div><div><br></div><div>    intercalate &quot;,&quot; . splitAtTopLevelCommas = id</div>
<div><br></div><div>But it should split the string only on a few commas, not all. You can think of the result list as representations of Haskell values, for example</div><div><br></div><div>    splitAtTopLevelCommas &quot;True,(1,(2,[3,4])),Just (&#39;a&#39;,\&quot;)\&quot;)&quot;</div>
<div><br></div><div>should yield</div><div><br></div><div>    [&quot;True&quot;, &quot;(1,(2,[3,4]))&quot;, &quot;Just (&#39;a&#39;,\&quot;)\&quot;)&quot;]</div><div><br></div><div>I expect writing this function to be quite tedious (ignore commas in parens, ignore parens in strings, quotation, ...) and would prefer to copy code from some parsing library. Do you have an idea what I could use? Or how to solve it from scratch in a few lines?</div>
<div><br></div><div>Sebastian</div>