[Ur] Unification Problems

David Snider david at davidsnider.net
Sun Oct 21 19:04:13 EDT 2012


Oh, sorry. That is because I accidentally posted the version with your 
suggested change in it.

What I'm trying to figure out is why I have to put an explicit type here:

fun checkPassword (r : {Email : string, Password : string}) =

instead of just using:
fun checkPassword r =


On 10/21/2012 06:50 PM, Adam Chlipala wrote:
> On 10/21/2012 06:41 PM, David Snider wrote:
>> My user.urs file has:
>>
>> val main : unit -> transaction page
>
> Well, I copied your code into a .ur file, gave it a .urs file like the 
> above, and changed the [Sha.hash] references to use an identity 
> function instead.  It all type-checks for me.  I would need a 
> self-contained complete source archive to say anything else.
>
>> On 10/21/2012 06:16 PM, Adam Chlipala wrote:
>>> That didn't turn out to be it.  Your [main] function is ambiguous; 
>>> it's not obvious from the code there now that it returns standalone 
>>> pages.  You can use type annotations in your .ur file to indicate 
>>> the type, but it would be better to create a .urs file declaring 
>>> [main] as in most of the demos.
>>>
>>> On 10/21/2012 05:55 PM, David Snider wrote:
>>>> Ah, OK...
>>>>
>>>> Here is the whole source:
>>>> http://pastebin.com/EZMqZVkd
>>>>
>>>> Is it that it can't decide whether to take it from the User table 
>>>> record or the cookie record?
>>>>
>>>> On 10/21/2012 05:42 PM, Adam Chlipala wrote:
>>>>> I need more context to give a complete answer.  The error message 
>>>>> means that some type is not uniquely determined, and the message 
>>>>> will show you where the undetermined type appears.
>>>>>
>>>>> My first guess, though: Start the function declaration like this:
>>>>>     fun checkPassword (r : {Email : string, Password : string}) =
>>>>>
>>>>> Otherwise, there might be other fields in [r].
>>>>>
>>>>> On 10/21/2012 05:39 PM, David Snider wrote:
>>>>>> What's the correct way of doing this?
>>>>>>
>>>>>> Error: Some constructor unification variables are undetermined in 
>>>>>> declaration
>>>>>>
>>>>>> cookie userSession : { Email : string, Password : string }
>>>>>>
>>>>>> ... snip ...
>>>>>>
>>>>>> fun checkPassword r =
>>>>>> let
>>>>>>    val cryptPass = {Email=r.Email, Password=Sha.hash r.Password}
>>>>>> in
>>>>>>    re' <- oneOrNoRows1(SELECT user.Id
>>>>>>                         FROM user
>>>>>>                        WHERE user.Email = {[cryptPass.Email]}
>>>>>>                          AND user.Password = 
>>>>>> {[cryptPass.Password]});
>>>>>>    case re' of
>>>>>>       None => return False
>>>>>>     | Some re => setCookie userSession { Value = cryptPass, 
>>>>>> Expires=None,Secure=False };
>>>>>>       return True
>>>>>> end
>>>>>
>
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur




More information about the Ur mailing list