Parametric polymorphism: Difference between revisions

m
(cat:type system)
Line 369:
 
binary_tree_of "node-type" = ("node-type",(binary_tree_of "node-type")%Z)%drWZwlwAZ</lang>
(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. <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.
<lang Ursala>binary_tree_of = %-hhhhWZAZ</lang>
Line 387:
 
example = (binary_tree_map "s". "s"--"s") x</lang>
Type signatures are not necessarily associated with function declarations, but
have uses in the other contexts such as assertions and compiler directives
(e.g., <code>#cast</code>). Here is the output.
<pre>
'foofoo': ('barbar': (),'bazbaz': ())
Anonymous user