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

Jovon Tan jovontan at gmail.com
Tue May 2 13:45:20 AEST 2017


I'm new to mercury and I'm trying to process CSV data using the package

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.
writer(Record, !IO) :-
    print(Record, !IO).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20170502/e3917b11/attachment.html>

More information about the users mailing list