Re: Why my code occurs `unsolved constraint` error?

2018-11-08 Thread Kiwamu Okabe
On Fri, Nov 9, 2018 at 1:18 PM Hongwei Xi wrote: > >>Are there some difference on type inference? > Hongwei > > There are equivalent in terms of dynamic semantics. > They are not equivalent with respect to the way in which > type inference is handled. Thanks. Clear for me. I should choose `let

Re: Why my code occurs `unsolved constraint` error?

2018-11-08 Thread Hongwei Xi
>>I believe both styles are equivalent. >>Are there some difference on type inference? > Hongwei There are equivalent in terms of dynamic semantics. They are not equivalent with respect to the way in which type inference is handled. On Thu, Nov 8, 2018 at 7:26 PM Kiwamu Okabe wrote: > Dear

Re: Why my code occurs `unsolved constraint` error?

2018-11-08 Thread Kiwamu Okabe
Dear Artyom and Hongwei, thanks for your kind reply. On Mon, Nov 5, 2018 at 9:51 PM Artyom Shalkhakov wrote: > The "state types" are described here: > > http://www.ats-lang.org/MYDATA/Xanadu-lics00.pdf > > section 4.3. The section talks about synthesizing these state types. I guess > that ATS2

Re: Why my code occurs `unsolved constraint` error?

2018-11-05 Thread Artyom Shalkhakov
Hi Kiwamu, Sorry for the delay, I missed your reply. On Friday, November 2, 2018 at 5:29:00 AM UTC+2, Kiwamu Okabe wrote: > > Dear Hongwei and Artyom, > > On Fri, Nov 2, 2018 at 12:03 PM gmhwxi > > wrote: > > The way you wrote the code makes it a bit difficult to > > do typechecking. Try to

Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread Kiwamu Okabe
Dear Hongwei and Artyom, On Fri, Nov 2, 2018 at 12:03 PM gmhwxi wrote: > The way you wrote the code makes it a bit difficult to > do typechecking. Try to change the interface for utf8_to_unicode > as follows: Thanks! It's fixed! https://travis-ci.org/metasepi/uemacs-bohai/builds/449662253 > I

Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread gmhwxi
The way you wrote the code makes it a bit difficult to do typechecking. Try to change the interface for utf8_to_unicode as follows: extern fun utf8_to_unicode {l1:addr} {i,m:nat | i < m} {l2:addr} ( pf: !unicode_t@l1 | line: !strnptr(l2,m), index: int(i), len: int(m), res: ptr(l1)): uint =

Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread Kiwamu Okabe
Dear Artyom, thanks for your kind reply. On Thu, Nov 1, 2018 at 5:12 PM Artyom Shalkhakov wrote: > You should put at at every branch (so on every [if] and on every [case]). > That's because the > variable [line] is of linear type, and the annotation basically says that in > every alternative

Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread Artyom Shalkhakov
Hi Kiwamu, чт, 1 нояб. 2018 г. в 10:00, Kiwamu Okabe : > Dear Artyom and Hongwei, > sorry for my late reply. > > On Mon, Oct 29, 2018 at 5:17 PM Artyom Shalkhakov > wrote: > > While I'm not sure why your code fails, it's an interesting project > you've started. > > Thanks. It's very fun and

Re: Why my code occurs `unsolved constraint` error?

2018-11-01 Thread Kiwamu Okabe
Dear Artyom and Hongwei, sorry for my late reply. On Mon, Oct 29, 2018 at 5:17 PM Artyom Shalkhakov wrote: > While I'm not sure why your code fails, it's an interesting project you've > started. Thanks. It's very fun and good exercise for me. > Actually, I have an idea about your code. You

Re: Why my code occurs `unsolved constraint` error?

2018-10-29 Thread Hongwei Xi
Forgot to uncomment. Artyom is right. You could write the code as follows (so as to avoid the need for type annotation): implement utf8_to_unicode (pf | line, index, len, res) = let fun loop1 (c: char, mask: uint, bytes: uint): (uint, uint) = if ((($UN.cast{uint}{char} c) land mask) != 0U)

Re: Why my code occurs `unsolved constraint` error?

2018-10-29 Thread Hongwei Xi
I tried and there was no problem. I used ATS2-0.3.12. On Mon, Oct 29, 2018 at 2:52 AM Kiwamu Okabe wrote: > Dear all, > > Why following code occurs `unsolved constraint` error? > > > https://github.com/metasepi/uemacs-bohai/blob/8b2b657c829be1025433f3083aa5cf3b1d040cb6/DATS/utf8.dats#L60 > >

Re: Why my code occurs `unsolved constraint` error?

2018-10-29 Thread Artyom Shalkhakov
Hi Kiwamu, While I'm not sure why your code fails, it's an interesting project you've started. Please don't hesitate telling us more about it! Actually, I have an idea about your code. You may have to an annotation like if :( line: strnptr(m) ) => .. then ... else ... onto your conditionals.

Why my code occurs `unsolved constraint` error?

2018-10-29 Thread Kiwamu Okabe
Dear all, Why following code occurs `unsolved constraint` error? https://github.com/metasepi/uemacs-bohai/blob/8b2b657c829be1025433f3083aa5cf3b1d040cb6/DATS/utf8.dats#L60 ``` $ vi DATS/utf8.dats --snip-- implement utf8_to_unicode (pf | line, index, len, res) = bytes where { fun loop1 (c: