Good for you!

Here is a short article on building npm-package for ATS:

http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/index.html

Building npm-package for ATS is a pretty new thing. There is unfortunately 
not much
doc at this moment. Maybe you could try to write something after this 
experience :)

By the way, various stream_vt functions in your code are already declared 
in the following file:

prelude/SATS/stream_vt.sats

I thought that part of the reason you implemented them was to get yourself 
familiar with ATS.

For instance, you can use stream_vt_map_cloptr for stream_vt_usermap; the 
former also frees
the (linear) closure it uses.

On Tuesday, March 14, 2017 at 7:12:24 PM UTC-4, August Alm wrote:
>
> Hooray! So did I. :) Thanks for, well everything.
>
> Am I correct in believing there is some sort of tutorial on how to best 
> publish ATS packages using NPM in the pipeline?
>
> Den tisdag 14 mars 2017 kl. 23:57:39 UTC+1 skrev gmhwxi:
>>
>>
>> Here is a way to fix it:
>>
>> fun {a, b: vt0ype}
>> stream_vt_usermap (
>>     xs: stream_vt(a),
>>     f: a -<cloref1> b
>>   ) : stream_vt(b) = let
>>     implement stream_vt_usermap$fopr<a, b>(x) = f(x)
>>   in stream_vt_usermap_aux(xs) end
>>
>> When using stream_vt_usermap, please pass lam(r) => extract_errs(r)
>>
>> There are two other places where you need this kind of change. Then you
>> should be able to compile the entire program. I just did.
>>
>> On Thursday, March 2, 2017 at 5:04:35 PM UTC-5, August Alm wrote:
>>>
>>> Hi!
>>>
>>> I'm in over my head and tried writing a CSV-parser using linear lazy 
>>> streams. My code thus far is 600 lines and almost to my own surprise I get 
>>> it to compile! However, there is something fishy because I get a segfault 
>>> when applying my program to an actual CSV-file. I've been trying to debug 
>>> using gdb but the fault eludes me. Since I don't expect anyone to mull 
>>> through 600 lines of code, I am hoping these code snippets are enough for 
>>> one of you guys to give me some advice.
>>>
>>> This code executes just fine:
>>>
>>>         implement main0 () = {
>>>            
>>>            val test = stream_vt_make_cons(
>>>                             'a', stream_vt_make_cons(
>>>                                     ';', 
>>> stream_vt_make_sing('b')))          (* the stream ('a', ';', 'b') *)
>>>            val lexed = lex_csv(true, ';', test)
>>>            val h = (lexed.head())
>>>            val- CSV_Field(r) = h
>>>            val a = r.csvFieldContent
>>>            val () = println!(a)
>>>          
>>>          }
>>>
>>> Here [lex_csv] is my 600-line alogrithm. It reads a [stream_vt(char)] 
>>> and gives back a [stream_vt(CSVEntry)], where [CSVEntry] is a record type, 
>>> one of whose fields is [CSVFieldContent]. When executing the program I get 
>>> "a" printed to the console.
>>>
>>> This code results in a segfault:
>>>
>>>         implement main0 () = {
>>>         
>>>            val inp = fileref_open_exn("small.csv", file_mode_r)
>>>            val ins = streamize_fileref_char(inp)
>>>            val lexed = lex_csv(true, ';', ins)
>>>            val () = fileref_close(inp)
>>>            val h = (lexed.head())
>>>            val- CSV_Field(r) = h
>>>            val a = r.csvFieldContent
>>>            val () = println!(a)
>>>          
>>>          }
>>>
>>> The file "small.csv" only contains the string "a;b". Hence I would 
>>> expect this code to give the result as the previous one! But, it doesn't 
>>> just return something else, it segfaults.
>>>
>>> gdb indicates there is a malloc problem having to do with 
>>> "GC_clear_stack_inner", in case that's helpful. (I'm a mathematician who 
>>> recently left academia after postdoc and decided to teach myself 
>>> programming to become more useful outside of academia; hence I understand 
>>> type systems and the like--the mathy stuff--a lot better than I understand 
>>> memory allocation and other stuff that most programmers are supposed to be 
>>> confident with.)
>>>
>>> What could be the problem here?
>>>
>>> Best wishes,
>>> August
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/af1c39e5-d47a-4eed-a8bc-5a7a5dbfaf34%40googlegroups.com.

Reply via email to