[m-users.] Trying out https://github.com/juliensf/mercury-csv

Jovon Tan jovontan at gmail.com
Tue May 2 15:34:27 AEST 2017


Ah, yes, that does it. Thanks, Julien.
By the way, thanks for your mercury-csv package too.

Regards,
WK

On 2 May 2017 at 12:26, Julien Fischer <jfischer at opturion.com> wrote:

>
> Hi,
>
> On Tue, 2 May 2017, Jovon Tan wrote:
>
> I'm new to mercury and I'm trying to process CSV data using the package
>>   https://github.com/juliensf/mercury-csv
>>
>> The next paragraph is my test code and mmc is giving me this error.
>>     test_raw_csv.m:034:   type error: unsatisfied typeclass constraint:
>>     test_raw_csv.m:034:     `stream.reader(csv.raw_reader(io.input_stream),
>> csv.record, io.state, Error)'
>> May I know how I should fix my code? Thanks.
>>
>> %-----------------------------------------------------------
>> ------------------%
>> % Program: test_raw_csv.m
>> % Purpose: Read CSV content from stdin and print as raw records to stdout.
>>
>> :- module test_raw_csv.
>> :- interface.
>> :- import_module io.
>> :- pred main(io::di, io::uo) is det.
>>
>> :- implementation.
>>
>> :- import_module csv.
>> :- import_module stream.
>>
>> %-----------------------------------------------------------
>> ------------------%
>>
>> main(!IO) :-
>>     io.stdin_stream(Input, !IO),
>>     process_csv(Input, !IO).
>>
>> :- pred process_csv(io.text_input_stream::in, io::di, io::uo) is det.
>> process_csv(Input, !IO) :-
>>     csv.init_raw_reader(Input, Reader, !IO),
>>     stream.input_stream_fold_state(Reader, writer, _Result, !IO).
>>
>> :- pred writer(record::in, io::di, io::uo) is det.
>>
>
> The raw CSV reader produces values of type 'raw_record' rather than
> 'record', so you need ot change the declaration of writer/3 to:
>
>    :- pred writer(raw_record, io::d, io::uo) is det.
>
> Cheers,
> Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20170502/7099bdaf/attachment.html>


More information about the users mailing list