<div dir="ltr">Dear All,<div><br></div><div>Recently I have been doing a lot of CSV processing. I initially tried to use the Data.Csv (cassava) library provided on Hackage, but I found this to still be too slow for my needs. In the meantime I have reverted to hacking something together in C, but I have been left wondering whether a tidy solution might be possible to implement in Haskell.</div>
<div><br></div><div>I would like to build a library that satisfies the following: </div><div><br></div><div>1) Run a function &lt;&lt;f :: a_1 -&gt; ... -&gt; a_n -&gt; m (Maybe (b_1, ..., b_n))&gt;&gt;, with &lt;&lt;m&gt;&gt; some monad and the &lt;&lt;a&gt;&gt;s and &lt;&lt;b&gt;&gt;s being input and output.</div>
<div><br></div><div>2) Be able to specify a maximum record string length and output record string length, so that the string buffers used for reading and outputting lines can be reused, preventing the need for allocating new strings for each record.</div>
<div><br></div><div>3) Allocate only once, the memory where the parsed input values, and output values are put.</div><div><br></div><div>4) The library&#39;s main function should take some kind of data structure describing the types of the function, the function itself and the filenames of input and output (could also be stdin/stdout).</div>
<div><br></div><div>I am not sure yet what would be that best value of &lt;&lt;m&gt;&gt;. I would like to most importantly efficiently, and if possible, purely allow changes in state to a number of variables, such as an aggregation over a certain field in the input. I do not currently have knowledge of the FFI, and how it might be used in this case. I would appreciate any suggestions as to where I should look further.</div>
<div><br></div><div>Regards,</div><div><br></div><div>Justin Paston-Cooper</div></div>