[Ur] 'Anonymous function remains' in state monad

Adam Chlipala adamc at csail.mit.edu
Fri Aug 15 12:18:14 EDT 2014


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)
>>>        



More information about the Ur mailing list