From jovontan at gmail.com Tue May 2 13:45:20 2017 From: jovontan at gmail.com (Jovon Tan) Date: Tue, 2 May 2017 11:45:20 +0800 Subject: [m-users.] Trying out https://github.com/juliensf/mercury-csv Message-ID: Hi, 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. writer(Record, !IO) :- print(Record, !IO). %-----------------------------------------------------------------------------% Regards, WK -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfischer at opturion.com Tue May 2 14:26:08 2017 From: jfischer at opturion.com (Julien Fischer) Date: Tue, 2 May 2017 14:26:08 +1000 (AEST) Subject: [m-users.] Trying out https://github.com/juliensf/mercury-csv In-Reply-To: References: Message-ID: 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. From jovontan at gmail.com Tue May 2 15:34:27 2017 From: jovontan at gmail.com (Jovon Tan) Date: Tue, 2 May 2017 13:34:27 +0800 Subject: [m-users.] Trying out https://github.com/juliensf/mercury-csv In-Reply-To: References: Message-ID: 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 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: From jfischer at opturion.com Tue May 2 17:27:13 2017 From: jfischer at opturion.com (Julien Fischer) Date: Tue, 2 May 2017 17:27:13 +1000 (AEST) Subject: [m-users.] Trying out https://github.com/juliensf/mercury-csv In-Reply-To: References: Message-ID: On Tue, 2 May 2017, Jovon Tan wrote: > Ah, yes, that does it. Thanks, Julien. > By the way, thanks for your mercury-csv package too. You're welcome. Cheers, Julien. > > On 2 May 2017 at 12:26, Julien Fischer 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. > > > >