[Ur] Random numbers/strings?

Daniel Patterson dbpatterson at riseup.net
Tue Dec 29 13:23:23 EST 2009


Not totally - I'm pretty sure I understand how the code should be
written (ie, function has signature:
uw_Basis_string ur_Random_str(uw_context ctx); - which will translate to
Random.str : string within Ur),

But, with that I'm having trouble actually making it available within ur.

I made an .urs file that defines the function as val str : string, and
an .urp file with the ffi for random (which if I understand correctly is
just referring to the .urs file), and declared it to be effectful, but
trying to include the header (with the 'header' directive) the compiler
responded "Unrecognized command 'header'".

Is there a trivial example of a .c/.h/.urp/.urs setup to define
something like Example.hello to return "hello"?

Or, given that I have a C function (defined as above), how do I actually
include it?

Thanks.

On 12/29/2009 12:35 PM, Adam Chlipala wrote:
> Daniel Patterson wrote:
>> What is the best way of getting a random string of characters? Either
>> built in (a random primitive) or a way of exploiting the features of the
>> database (I'm using sqlite, so for example this gives a decent string:
>> SELECT hex(randomblob(30)); within the database interface, but I'm not
>> sure how to get that back into ur).
>>    
> 
> Right now, the compiler isn't set up so nicely to make it easy to expose
> new primitive functions of the database engine.  The easiest way to get
> what you're looking for is to expose a C function via the FFI.  Does the
> manual include enough information to show how to do this?
> 
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur




More information about the Ur mailing list