<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29870</bug_id>
          
          <creation_ts>2016-09-26 06:42:55 +0000</creation_ts>
          <short_desc>Tuple types</short_desc>
          <delta_ts>2016-09-26 06:42:55 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Requirements for Future Versions</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>127530</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-26 06:42:55 +0000</bug_when>
    <thetext>A common use case for maps is to represent composite structures such as the result of fn:random-number-generator, which is a map containing 

number: an xs:double
next: a function
permute: a function

The problem about using maps for such structures is that we can&apos;t describe or constrain their type very accurately: this example simply becomes map(xs:string, item()).

We could introduce tuple types simply as new syntax for constraining the type of a map.

declare function fn:random(...) as 
   tuple{number : xs:double, 
         next : function(*),
         permute : function(item()*) as item()*}

The instances of this type would still be maps, and they would still be instances of map(xs:string, item()), and one could use all the same operations (e.g. random($seed)?permute($x)), but the new item type syntax would allow the required type to be specified more descriptively and precisely, and would allow better static type checking.

The feature has been prototyped in Saxon: see http://dev.saxonica.com/blog/mike/2016/09/tuple-types-and-type-aliases.html

(In this particular example it would be nice to be able to make the type recursive, since the &quot;next&quot; function also returns tuples of this type; but that&apos;s a separate requirement).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>