Hi Adam/Ziv, thanks for the information. *"The short answer is to use the FFI to do the relevant computation in another language. C is the easiest choice to get working, but Edward Yang's Logitext sets up Haskell for this. You're then free to give the function a non-transaction type."*
Is there an example (in C) of this on the webpage or github (I could only find documentation but no specific example). For example suppose I have an array of ints in ur. I pass this to a c function int addArray(int* p, int sizeOfArray) and then get the sum of the elements of the array back in ur/web. And then I wrap the operation as a pure function (i.e. non-transaction type). Thanks On Tue, Dec 29, 2015 at 5:48 PM, Ziv Scully <[email protected]> wrote: > The short answer is to use the FFI to do the relevant computation in > another language. C is the easiest choice to get working, but Edward Yang's > Logitext sets up Haskell for this. You're then free to give the function a > non-transaction type. > > It might be possible to write the ST monad using the FFI. One can > implement types and functions for references, arrays, etc. in C, use .urp > declarations mark all these functions as effectful, and wrap these types > and functions in a module that enforces the typical ST types, which is > straightforward with Ur/Web's rank-N types. That said, the lack of garbage > collection could make this complicated. I'm not sure how safe it is to > store Ur/Web structures in references (the structure might get freed) or > how to free any allocated ST structures. The first problem has an easy > half-solution: if there are some types that are safely usable in ST > references, use a closed type class to enumerate them. (See the interface > for Basis.sql_injectable for a similar example.) > > > On Tuesday, December 29, 2015, Adam Chlipala <[email protected]> wrote: > >> I wonder if this source file would be of interest, from Sergey Mironov's >> urweb-monad-pack library. >> https://github.com/grwlf/urweb-monad-pack/blob/master/state.ur >> >> I'm not familiar enough with Haskell myself to know whether it's a >> perfect match. >> >> On 12/23/2015 11:16 AM, Artella Coding wrote: >> >>> Hi, is there something like a haskell runST monad ( >>> https://wiki.haskell.org/Monad/ST) in ur/web, so that I can perform >>> mutations within a pure function? >>> >>> For example I might want to have my pure function make a copy of a large >>> array, and then perform the relevant mutations on this copy, before >>> returning this copy. The function is pure in that it does not modify the >>> input nor does it require data from the "outside world", and yet relies on >>> mutations of the internal copy (which it employs for the sake of >>> efficiency). >>> >> >> _______________________________________________ >> Ur mailing list >> [email protected] >> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur >> > > _______________________________________________ > Ur mailing list > [email protected] > http://www.impredicative.com/cgi-bin/mailman/listinfo/ur > >
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
