[Ur] Browser-based adventure game

Saulo Araujo saulo2 at gmail.com
Wed Oct 12 12:56:51 EDT 2016


Hi Michael,

I am afraid I cannot give you "definitive" answers for much of your
questions. Anyway, I will try my best :)

- Is there a more convenient syntax for list construction than "1 :: 2 :: 3
> :: []", something like "[1, 2, 3]"?
>
I am afraid there is not.


> - I had to pass both a "gameState" and a "source gameState" parameter to
> the "render" function (for the same game state). Is there a way around that?
>
Yes. You can change the render function to produce a "signal xbody" rather
than producing a "xbody":

fun render (sgs : source gameState) : signal xbody =
    gs <- signal sgs;
    return (let
fun cols (row : int) (col : int) : xtr =
(* ... *)
</xml>
   end)

Now you can pass the signal render produces to the signal attribute of the
dyn tag:

(* Entry point of the program. *)
fun main () : transaction page =
(* ... *)
        <dyn signal={render state} />
(* ... *)
        </body></xml>


> - I minimized the use of mutable data. So when the game state changes much
> of the page gets updated. This should probably be done in a more
> fine-grained way in reality.
>
As long there is no performance problem, I think your implementation is
fine.


> - Does Ur/Web do tail-call optimization?
>
I believe it does.

Sincerely,
Saulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20161012/eeee6313/attachment.html>


More information about the Ur mailing list