<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto">
<div dir="auto">One aspect that I appreciate about Ur/Web is that the xml tags define keys and types that can /potentially/ be included in a tag - that is, a tag does but not need to include all of the keys.</div>
<div dir="auto"><br>
</div>
<div dir="auto">In defining an FFI to a JavaScript library such as Chart.js, config options may be defined in terms of (nested) JavaScript objects with a range of potential keys/fields. Analogous to the xml tags, is there any way to define a record type in
Ur/Web that potentially includes a subset of fields? As an example, a Chart.js config object in JavaScript could be:</div>
<div dir="auto"><br>
</div>
<div dir="auto">val config = {</div>
<div dir="auto"> type: 'bar',</div>
<div dir="auto"> data: {</div>
<div dir="auto"> labels: ['Red', 'Blue'],</div>
<div dir="auto"> datasets: [{</div>
<div dir="auto"> label: '# of Votes',</div>
<div dir="auto"> data: [12, 19],</div>
<div dir="auto"> borderWidth: 1</div>
<div dir="auto"> }]</div>
<div dir="auto"> },</div>
<div dir="auto"> options: {</div>
<div dir="auto"> scales: {</div>
<div dir="auto"> yAxes: [{</div>
<div dir="auto"> ticks: {</div>
<div dir="auto"> beginAtZero: true</div>
<div dir="auto"> }</div>
<div dir="auto"> }]</div>
<div dir="auto"> }</div>
<div dir="auto"> }</div>
<div dir="auto">}</div>
<div dir="auto"><br>
</div>
<div dir="auto">with other keys not specified. The equivalent data in Ur/Web could be:</div>
<div dir="auto"><br>
</div>
<div dir="auto">val config = {</div>
<div dir="auto"> type = 'bar',</div>
<div dir="auto"> data = {</div>
<div dir="auto"> labels = 'Red' :: 'Blue' :: []</div>
<div dir="auto"> datasets= {</div>
<div dir="auto"> label= '# of Votes',</div>
<div dir="auto"> data= 12 :: 19 :: [],</div>
<div dir="auto"> borderWidth = 1</div>
<div dir="auto"> } :: []</div>
<div dir="auto"> },</div>
<div dir="auto"> options= {</div>
<div dir="auto"> scales= {</div>
<div dir="auto"> yAxes= {</div>
<div dir="auto"> ticks= {</div>
<div dir="auto"> beginAtZero= True</div>
<div dir="auto"> }</div>
<div dir="auto"> } :: []</div>
<div dir="auto"> }</div>
<div dir="auto"> }</div>
<div dir="auto">}</div>
<div dir="auto"><br>
</div>
<div dir="auto">with a config type that includes these and other fields. (For this example, I realise that Ur/Web lists would need to be mapped to JavaScript arrays, while the 'type' and 'options' fields are expressed more simply as scalars or nested records.)</div>
<div dir="auto"><br>
</div>
<div dir="auto">Are such "subset" record types possible in Ur/Web? The alternative would be to write many FFI functions to change the individual config parameters.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Sincerely, Mark.</div>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1561.6">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Times; color: #000000; -webkit-text-stroke: #000000; min-height: 14.0px}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Times; color: #000000; -webkit-text-stroke: #000000}
span.s1 {font-kerning: none}
span.s2 {text-decoration: underline ; font-kerning: none; color: #0000ee; -webkit-text-stroke: 0px #0000ee}
</style>
<p class="p1"><span class="s1"></span><br>
</p>
<p class="p1"><span class="s1"></span><br>
</p>
<p class="p2"><span class="s1"><i>När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter.
</i><a href="https://ki.se/medarbetare/integritetsskyddspolicy"><span class="s2">Här finns information om hur KI behandlar personuppgifter</span></a>.<span class="Apple-converted-space"> </span></span></p>
<p class="p1"><span class="s1"></span><br>
</p>
<p class="p2"><span class="s1"><i>Sending email to Karolinska Institutet (KI) will result in KI processing your personal data.</i>
<a href="https://ki.se/en/staff/data-protection-policy"><span class="s2">You can read more about KI’s processing of personal data here</span></a>.<span class="Apple-converted-space"> </span></span></p>
</body>
</html>