<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=Language_Reference%2FBounded_polymorphism</id>
	<title>Language Reference/Bounded polymorphism - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=Language_Reference%2FBounded_polymorphism"/>
	<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;action=history"/>
	<updated>2026-04-26T10:00:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4604&amp;oldid=prev</id>
		<title>Thomas Linder Puls: release</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4604&amp;oldid=prev"/>
		<updated>2019-03-12T16:13:05Z</updated>

		<summary type="html">&lt;p&gt;release&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:13, 12 March 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{languageReferenceNavbar|Bounded polymorphism}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{languageReferenceNavbar|Bounded polymorphism}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Template:NonReleased}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4594&amp;oldid=prev</id>
		<title>Thomas Linder Puls: Not released</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4594&amp;oldid=prev"/>
		<updated>2019-02-25T15:33:16Z</updated>

		<summary type="html">&lt;p&gt;Not released&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:33, 25 February 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{languageReferenceNavbar|Bounded polymorphism}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{languageReferenceNavbar|Bounded polymorphism}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Template:NonReleased}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4593&amp;oldid=prev</id>
		<title>Thomas Linder Puls: navbar</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4593&amp;oldid=prev"/>
		<updated>2019-02-25T15:31:47Z</updated>

		<summary type="html">&lt;p&gt;navbar&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:31, 25 February 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{languageReferenceNavbar|Bounded polymorphism}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4590&amp;oldid=prev</id>
		<title>Thomas Linder Puls: Thomas Linder Puls moved page Bounded polymorphism to Language Reference/Bounded polymorphism</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4590&amp;oldid=prev"/>
		<updated>2019-02-25T15:27:45Z</updated>

		<summary type="html">&lt;p&gt;Thomas Linder Puls moved page &lt;a href=&quot;/index.php?title=Bounded_polymorphism&quot; class=&quot;mw-redirect&quot; title=&quot;Bounded polymorphism&quot;&gt;Bounded polymorphism&lt;/a&gt; to &lt;a href=&quot;/index.php?title=Language_Reference/Bounded_polymorphism&quot; title=&quot;Language Reference/Bounded polymorphism&quot;&gt;Language Reference/Bounded polymorphism&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:27, 25 February 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4589&amp;oldid=prev</id>
		<title>Thomas Linder Puls: initial</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Language_Reference/Bounded_polymorphism&amp;diff=4589&amp;oldid=prev"/>
		<updated>2019-02-25T15:20:53Z</updated>

		<summary type="html">&lt;p&gt;initial&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The following example can be used as a motivation for bounded polymorphism.&lt;br /&gt;
&lt;br /&gt;
{{Example|Assume that we have a program with two kinds of persons &amp;lt;vp&amp;gt;client&amp;lt;/vp&amp;gt;s and &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt;s, and that we have ordered them in a hierarchy like this:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
interface person&lt;br /&gt;
properties&lt;br /&gt;
    name : string.&lt;br /&gt;
    ...&lt;br /&gt;
end interface person&lt;br /&gt;
&lt;br /&gt;
interface client supports person&lt;br /&gt;
properties&lt;br /&gt;
    clientId : unsigned.&lt;br /&gt;
    ...&lt;br /&gt;
end interface client&lt;br /&gt;
&lt;br /&gt;
interface user supports person&lt;br /&gt;
properties&lt;br /&gt;
    isAdministrator : boolean.&lt;br /&gt;
    ...&lt;br /&gt;
end interface user&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;vp&amp;gt;list::sortBy&amp;lt;/vp&amp;gt; we can create predicate that sorts a list of persons by name like this:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (person* PersonList) -&amp;gt; person* SortedList.&lt;br /&gt;
clauses&lt;br /&gt;
    sortByName(List) :- list::sortBy({ (L, R) = compare(L:name, R:name) }, List).&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Due to the (structural subtyping) type rules of Visual Prolog we use this predicate to sort a list of users:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
SortedList = sortByName(UserList)&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, &amp;lt;vp&amp;gt;SortedList&amp;lt;/vp&amp;gt; is a list of &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;s rather than a list of &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt;s.&lt;br /&gt;
&lt;br /&gt;
So the elements in &amp;lt;vp&amp;gt;SortedList&amp;lt;/vp&amp;gt; does not have the &amp;lt;vp&amp;gt;isAdministrator&amp;lt;/vp&amp;gt; property.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In this example the elements in the &amp;lt;vp&amp;gt;SortedList&amp;lt;/vp&amp;gt; has been &amp;quot;downgraded&amp;quot; from &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt; to &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;.  But if they are users before we sort them then they are also users after they have been sorted.  So we would like to create a sortByName predicate that does not perform such an element downgrade.&lt;br /&gt;
&lt;br /&gt;
So we want to create a predicate that returns the same kind of elements that it receives as input.  A polymorphic declaration like this:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (Elem* PersonList) -&amp;gt; Elem* SortedList.&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
has the desired property.  But it will not work, because this predicate can receive any kind of list as input and you cannot get a &amp;lt;vp&amp;gt;name&amp;lt;/vp&amp;gt; from everything.&lt;br /&gt;
&lt;br /&gt;
This is where bounded polymorphism can help.  With bounded polymorphism you can state that a a type parameter cannot be anything it has to fulfill some &amp;#039;&amp;#039;bound&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Bounds have the form &amp;lt;vp&amp;gt;where X supports Y&amp;lt;/vp&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Example|In our example we can use bounded polymorphism like this:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (Person* PersonList) -&amp;gt; Person* SortedList&lt;br /&gt;
        where Person supports person.&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
Now the type parameter (i.e. &amp;lt;vp&amp;gt;Person&amp;lt;/vp&amp;gt;) can only be a type that supports &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we call the predicate with a user list (&amp;lt;vp&amp;gt;user*&amp;lt;/vp&amp;gt;) then the type variable &amp;lt;vp&amp;gt;Person&amp;lt;/vp&amp;gt; will be &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt; in the declaration, corresponding to this declaration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (user* PersonList) -&amp;gt; user* SortedList&lt;br /&gt;
        where user supports person.&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
* The returned list is a &amp;lt;vp&amp;gt;user*&amp;lt;/vp&amp;gt;&lt;br /&gt;
* The bound is fulfilled because &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt; does support &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we (attempt to) call the predicate with an integer list (&amp;lt;vp&amp;gt;integer*&amp;lt;/vp&amp;gt;) the type variable &amp;lt;vp&amp;gt;Person&amp;lt;/vp&amp;gt; must have the value integer, corresponding to this declaration:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (integer* PersonList) -&amp;gt; integer* SortedList&lt;br /&gt;
        where integer supports person.&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
Then the bound is not fulfilled because &amp;lt;vp&amp;gt;integer&amp;lt;/vp&amp;gt; does &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; support &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Bounds can be put on polymorphic predicates like above, if you need more than one bound you must write like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    pred : (&amp;lt;type1&amp;gt; P1, &amp;lt;type2&amp;gt; P2, ...) -&amp;gt; &amp;lt;return&amp;gt;.&lt;br /&gt;
        where &amp;lt;Sub1&amp;gt; supports &amp;lt;Super1&amp;gt;&lt;br /&gt;
        where &amp;lt;Sub2&amp;gt; supports &amp;lt;Super2&amp;gt;&lt;br /&gt;
        ....&lt;br /&gt;
        where &amp;lt;SubJ&amp;gt; supports &amp;lt;SuperJ&amp;gt;.&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we have put bounds on the parameters we can exploit them in the clauses.&lt;br /&gt;
&lt;br /&gt;
{{Example|&amp;lt;vp&amp;gt;L&amp;lt;/vp&amp;gt; and &amp;lt;vp&amp;gt;R&amp;lt;/vp&amp;gt; has types that supports &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;, so we can obtain the &amp;lt;vp&amp;gt;name&amp;lt;/vp&amp;gt; property from these variables:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
predicates&lt;br /&gt;
    sortByName : (Person* PersonList) -&amp;gt; Person* SortedList&lt;br /&gt;
        where Person supports person.&lt;br /&gt;
clauses&lt;br /&gt;
    sortByName(List) :- list::sortBy({ (L, R) = compare(L:name, R:name) }, List).&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Bounds can also be put on classes.&lt;br /&gt;
&lt;br /&gt;
{{Example|Given &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;s from above, we want to create name maps.  I.e. we want to map from name to person, but also here we want to be able to use this map for users and customers.&lt;br /&gt;
&lt;br /&gt;
The interface does not reflect that we have &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;s in mind (we could also implement this interface for other things than persons):&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
interface nameMap{@Type}&lt;br /&gt;
predicates &lt;br /&gt;
   insert : (@Type Element).&lt;br /&gt;
   tryGet : (string Name) -&amp;gt; @Type.&lt;br /&gt;
interface nameMap&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
But the &amp;lt;vp&amp;gt;personNameMap&amp;lt;/vp&amp;gt; class will only work &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;s&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
class personNameMap{@Person} : nameMap{@Person}&lt;br /&gt;
    where @Person supports person&lt;br /&gt;
end class personNameMap&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
Due to the bound we can use the name property in the implementation of the class:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
implement personNameMap{@Person}&lt;br /&gt;
&lt;br /&gt;
facts&lt;br /&gt;
    theMap : mapM{string Name, @Person} := mapM_redBlack::new().&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    insert(P) :-&lt;br /&gt;
        theMap:set(P:name, P).  % P has a type that supports person, so we can use the name property&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    tryGet(Name) = theMap:tryGet(Name).&lt;br /&gt;
&lt;br /&gt;
end implement personNameMap&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
This class can be used to create a user map:&lt;br /&gt;
&amp;lt;vip&amp;gt;&lt;br /&gt;
facts&lt;br /&gt;
    userMap : nameMap{user} := personNameMap::new().&lt;br /&gt;
&amp;lt;/vip&amp;gt;&lt;br /&gt;
And in that map we can insert &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt; and we can lookup &amp;lt;vp&amp;gt;user&amp;lt;/vp&amp;gt;s (i.e. rather than &amp;lt;vp&amp;gt;person&amp;lt;/vp&amp;gt;s) by name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
In bounds the notion of supports is extended to cover non-object types, in the sense that Sub supports Super if Sub is a subtype of Super.  As example &amp;lt;vp&amp;gt;integer&amp;lt;/vp&amp;gt; is a subtype of &amp;lt;vp&amp;gt;real&amp;lt;/vp&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
</feed>