<div dir="ltr"><div><div>Ah, yes, that does it. Thanks, Julien.<br></div><div>By the way, thanks for your me<wbr>rcury-csv package too.<br></div><div><br></div>Regards,<br></div>WK<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 May 2017 at 12:26, Julien Fischer <span dir="ltr"><<a href="mailto:jfischer@opturion.com" target="_blank">jfischer@opturion.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
On Tue, 2 May 2017, Jovon Tan wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm new to mercury and I'm trying to process CSV data using the package<br>
<a href="https://github.com/juliensf/mercury-csv" rel="noreferrer" target="_blank">https://github.com/juliensf/me<wbr>rcury-csv</a><br>
<br>
The next paragraph is my test code and mmc is giving me this error.<br>
test_raw_csv.m:034: type error: unsatisfied typeclass constraint:<br>
test_raw_csv.m:034: `stream.reader(csv.raw_reader(<wbr>io.input_stream), csv.record, io.state, Error)'<br>
May I know how I should fix my code? Thanks.<br>
<br>
%-----------------------------<wbr>------------------------------<wbr>------------------%<br>
% Program: test_raw_csv.m<br>
% Purpose: Read CSV content from stdin and print as raw records to stdout.<br>
<br>
:- module test_raw_csv.<br>
:- interface.<br>
:- import_module io.<br>
:- pred main(io::di, io::uo) is det.<br>
<br>
:- implementation.<br>
<br>
:- import_module csv.<br>
:- import_module stream.<br>
<br>
%-----------------------------<wbr>------------------------------<wbr>------------------%<br>
<br>
main(!IO) :-<br>
io.stdin_stream(Input, !IO),<br>
process_csv(Input, !IO).<br>
<br>
:- pred process_csv(io.text_input_stre<wbr>am::in, io::di, io::uo) is det.<br>
process_csv(Input, !IO) :-<br>
csv.init_raw_reader(Input, Reader, !IO),<br>
stream.input_stream_fold_state<wbr>(Reader, writer, _Result, !IO).<br>
<br>
:- pred writer(record::in, io::di, io::uo) is det.<br>
</blockquote>
<br>
The raw CSV reader produces values of type 'raw_record' rather than<br>
'record', so you need ot change the declaration of writer/3 to:<br>
<br>
:- pred writer(raw_record, io::d, io::uo) is det.<br>
<br>
Cheers,<br>
Julien.</blockquote></div><br></div>