My mistake. I did not read the Text.CSV.ByteString document carefully. parseCSV requires a strict ByteString, but I was feeding a lazy one.<br><br>Have a good weekend!<br><br>Hong<br><br><div class="gmail_quote">On Fri, Nov 6, 2009 at 3:47 PM, Hong Yang <span dir="ltr">&lt;<a href="mailto:hyangfji@gmail.com">hyangfji@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I have the following code:<br><br>$$$$$$$$<br>module Main where<br><br>import System.Environment (getArgs)<br>
import Text.CSV.ByteString<br>import qualified Data.ByteString.Lazy.Char8 as L<br><br>main = do<br>       [args] &lt;- getArgs<br>
       file &lt;- L.readFile args<br>       let result = parseCSV file<br>       case result of<br>            Nothing       -&gt; putStrLn &quot;Error when parsing!&quot;<br>            Just contents -&gt; do<br>                               putStrLn &quot;parsing OK!&quot;<br>

                               -- map_header_records contents<br>$$$$$$$$<br><br>which yielded the error as follows:<br><br>    Couldn&#39;t match expected type `Data.ByteString.Internal.ByteString&#39;<br>           against inferred type `L.ByteString&#39;<br>

    In the first argument of `parseCSV&#39;, namely `file&#39;<br>    In the expression: parseCSV file<br>    In the definition of `result&#39;: result = parseCSV file<br><br>readFile in the Data.ByteString.Lazy.Char8 module returns ByteString type. Since the module is qualified as L, L.readFile returns L.ByteString. But parseCSV expects a ByteString. Sometimes this is annoying, because it makes type matching difficult (at least for me, a beginner). I really wish Haskell can intelligently treat L.ByteString, M.ByteString, and whatever X.ByteString the same as ByteString, and match them.<br>

<br>Can someone tell me how to solve the above problem?<br><br>Thanks,<br><font color="#888888"><br>Hong<br>
</font></blockquote></div><br>