[Ur] json implementation - need some help understanding what's happening here?

Marc Weber marco-oweber at gmx.de
Tue Dec 14 11:26:51 EST 2010


val json_record : ts ::: {Type}     -- implicit. is automatically inferred
    -> folder ts                    -- first arg?
    -> $(map json ts)               -- second arg?
    -> $(map (fn _ => string) ts)   -- third arg?
    -> json $ts                     -- result type?


1) map json?
  Now: What does "map json" exacly mean? What does mapping over a class
  (json is a class?) do?

  Is map described somewhere? It seems to be a primop because its listed
  in the syntax files and in the lexer file.

  That also seems to be the reason why map is called mp in all
  remaining files (eg list.ur)

2) number of arguments? I'm still totally missing the point. json_record
    is used like this:

        type address = {StreetAddress : string,
                        City : string,
                        State : string,
                        PostalCode : string}


        val json_address : json address = json_record {StreetAddress = "streetAddress",
                                                       City = "city",
                                                       State = "state",
                                                       PostalCode = "postalCode"}
    only one argument is passed - however json_record still has 3
    explicit ones?

      -> folder ts                    -- first arg?
      -> $(map json ts)               -- second arg?
      -> $(map (fn _ => string) ts)   -- third arg?


    Which section of the manual do I have to understand so that I can
    follow what ur is doing here?

3) is it possible to write a generic show function which does not
   require json_record to be called for each possible record type?

   I'm keen on understanding how to write a show function for record
   types - it does not exist yet.

Marc Weber



More information about the Ur mailing list