[Ur] Five weird questions involving kind `Name` vs type `string`

Stefan Scott Alexander stefanscottalexx at gmail.com
Sun Jul 26 16:51:57 EDT 2015


I'm curious about differences (and possible relationships or conversions?)
between:

- things of kind `Name`
- things type `string`

I'm fairly certain the answers to questions (1) and (2) and (3) below are
all "No".

The answers to questions (4) and (5) are probably also "No" - but maybe
not...

----------

Questions:

(1) Given a string such as:

  "Field1"

is there any way to refer to the corresponding Name, ie:

  #Field1

?

---------

(2) Is it possible for a function to have a signature like:

  val makeName str : string -> [ nm :: Name ]

In other words, is it possible for a function to *return* something of kind
`Name`?

---------


(3)(a) Is there some syntax like the following in Ur/Web:

  val myFieldName = "Field1"
  #{myFieldName}

?

---------

(3)(b) Is there some syntax like the following in Ur/Web:

  #{"Field1"}

?

---------

(4) The following function occurs in files crud.urs / crud.ur of the Crud1,
Crud2, Crud3 demos:

  *.urs

  val checkboxWidget_n : nm :: Name -> xml form [] [nm = widget]

  *.ur

  val checkboxWidget_n = [nm :: Name] => <xml><checkbox{nm}/></xml>


Would some syntax like the following be possible (using type `string`
instead of kind `Name`):

  *.urs

    val checkboxWidget_s : str : string -> xml form [] [#{str} = widget]

  *.ur

    val checkboxWidget_s = str : string => <xml><checkbox{str}/></xml>

?

---------

(5) Can something of type `string` (instead of something of kind `Name`) be
used in the __ positions in examples (a) or (b) shown below:

(a)

  <xml><checkbox{__}/></xml>

(b)

  <xml>
    <select{__}>
      <option>"New York"</option>
      <option>"London"</option>
      <option>"Paris"</option>
    </select>
  </xml>

?

---------

Thanks for any help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150726/7e926590/attachment.html>


More information about the Ur mailing list