Parametric polymorphism: Difference between revisions
Content added Content deleted
(cat:type system) |
|||
Line 369: | Line 369: | ||
binary_tree_of "node-type" = ("node-type",(binary_tree_of "node-type")%Z)%drWZwlwAZ</lang> |
binary_tree_of "node-type" = ("node-type",(binary_tree_of "node-type")%Z)%drWZwlwAZ</lang> |
||
(The %Z type operator constructs a "maybe" type, i.e., the free union of its operand type |
(The <code>%Z</code> type operator constructs a "maybe" type, i.e., the free union of its operand type |
||
with the null value. Others shown above are standard stack manipulation primitives, e.g. d (dup) and w (swap), used to build the type expression tree.) At the other extreme, one may construct an equivalent parameterized type in |
with the null value. Others shown above are standard stack manipulation primitives, e.g. <code>d</code> (dup) and <code>w</code> (swap), used to build the type expression tree.) At the other extreme, one may construct an equivalent parameterized type in |
||
point-free form. |
point-free form. |
||
<lang Ursala>binary_tree_of = %-hhhhWZAZ</lang> |
<lang Ursala>binary_tree_of = %-hhhhWZAZ</lang> |
||
Line 387: | Line 387: | ||
example = (binary_tree_map "s". "s"--"s") x</lang> |
example = (binary_tree_map "s". "s"--"s") x</lang> |
||
Type signatures are not associated with function declarations, but |
Type signatures are not necessarily associated with function declarations, but |
||
have uses in the other contexts such as assertions and compiler directives |
have uses in the other contexts such as assertions and compiler directives |
||
(e.g., #cast). Here is the output. |
(e.g., <code>#cast</code>). Here is the output. |
||
<pre> |
<pre> |
||
'foofoo': ('barbar': (),'bazbaz': ()) |
'foofoo': ('barbar': (),'bazbaz': ()) |