[Ur] 'Anonymous function remains' in state monad

Sergey Mironov grrwlf at gmail.com
Fri Aug 15 14:46:22 EDT 2014


OK, I understand the idea. Unfortunately, compiler seems to go crazy
after this change. The first error message is following:

urweb -dbms sqlite ./test/Test4
/home/grwlf/proj/urweb-monad-pack/test/Test4.ur:10:11: (to 10:20)
Unification failure
Expression:  MO.get [<UNIF:U11::Type>] {}
  Have con:
<UNIF:U11::Type> -> option (<UNIF:U11::Type> * <UNIF:U11::Type>)
  Need con:  <UNIF:U8::Type -> Type> <UNIF:U9::Type>

Looks like it doesn't want to use the monad_state instance as aid for
code generation or something like that..
I've pushed the changes to the github.



2014-08-15 20:18 GMT+04:00 Adam Chlipala <adamc at csail.mit.edu>:
> Ah, yes, I was able to reproduce the issue.  Like you, I'm surprised that
> the other examples were working, with a datatype constructor that takes a
> function as an argument!  That's the sort of higher-order stuff that
> confuses the compiler in general, and you were just getting lucky with
> various program analyses being smart enough.  With the [query] call, you can
> see the effectful pattern match that confuses the compiler, by passing the
> '-dumpSource' command-line option.
>
> However, the problem is easy to fix by replacing in state.ur the definition
>   datatype state st a = State of (st -> S.m (st * a))
> with
>   type state st a = st -> S.m (st * a)
>
> That is, just use a type synonym instead of a datatype.  Other parts of the
> signature and its implementation must be changed, but it's pretty
> straightforward.
>
> I hope there are no objections to satisfying the compiler by simplifying the
> program in this way. :)
>
>
> On 08/15/2014 04:51 AM, Sergey Mironov wrote:
>>
>> I've re-checked the compiler verison. Looks like it is correct.
>> Originally, the last failed [query] call was commented out, may it be
>> the source of confusion? I've remove that comment so XmlGen now fails
>> as is. Could you please try again?
>>
>>>>
>>>> [...]
>>>>
>>>>
>>>> [3] - https://github.com/grwlf/urweb-monad-pack (the whole project)
>>>>
>
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur



More information about the Ur mailing list