[Ur] Polymorphic variants and JSON

Adam Chlipala adamc at impredicative.com
Sat Apr 14 20:15:10 EDT 2012


Edward Z. Yang wrote:
> Excerpts from Edward Z. Yang's message of Sat Apr 14 19:29:32 -0400 2012:
>> This particular permutation gives me:
>>
>>      /home/ezyang/Dev/logitext/meta/json.ur:300:55-300:69: Can't resolve type class instance
>>      Class constraint:  Top.folder[[Type]] rest
>>
>> and I don't know how to spell the implicit arguments correctly or what
>> folder I should be giving it (it's /almost/ 'fl' except that the
>> entries in front need to be lopped off).  Is there a version of fold which
>> also gives me folders?
> Here's an idea: fold once to get a record of folders, and fold again
> with that. But maybe the unification won't be clever enough.

Oh, yeah; I didn't think of this issue.  It's probably easier to stop 
using [Variant.weaken]; instead, you can choose your accumulator type to 
be polymorphic in an extra type-level record to concatenate into the 
index to [variant].  (This general pattern appears a few times in 
variant.ur, including in the first function definition.)



More information about the Ur mailing list