<div dir="ltr">Greetings John. Fair enough. What I usually use is something along the lines of:<div><br></div><div>type 'a tree = Empty | Node of 'a tree * 'a * 'a tree</div><div><br></div><div>I would prefer to use a record for the Node case but in my experience having to cobble together mutually recursive types as in:</div><div><br></div><div>







<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><b>type</b> </span><span class="">'a node </span><span class="">=</span><span class=""> </span><span class="">{</span><span class="">info</span><span class="">:</span><span class=""> </span><span class="">'a</span><span class="">;</span><span class=""> left</span><span class="">:</span><span class=""> </span><span class="">'a tree</span><span class="">;</span><span class=""> right</span><span class="">:</span><span class=""> </span><span class="">'a tree</span><span class="">}</span><span class="">                         <br></span><span class=""><b>and</b></span><span class=""> </span><span class="">'a tree </span><span class="">=</span><span class=""> Empty </span><span class="">|</span><span class=""> Node </span><span class="">of</span><span class=""> 'a node                                         </span></blockquote></div><div><br></div><div>is basically a show stopper for many --- it needlessly obscures the natural recursive structure of the tree.</div><div><br></div><div>Bob</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 2, 2016 at 4:11 PM, John Whitington <span dir="ltr"><<a href="mailto:jgw25@cam.ac.uk" target="_blank">jgw25@cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Robert,<span class=""><br>
<br>
Robert Muller wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Greetings. As I understand it, an upcoming release of OCaml is going to<br>
support anonymous (or were they called "inlined"??) records. This is<br>
going to be very helpful in an intro classroom where students will be<br>
able to work with more intuitive definitions of trees. I assume that<br>
we'll be able to write something like:<br>
<br>
type 'a tree = Leaf of 'a | Node of {info: 'a; left : 'a tree; right :<br>
'a tree}<br>
<br>
and we won't have to fiddle around with mutually recursive type<br>
definitions. We will be distributing a VM to students at the start of<br>
class (January 19). I would prefer to distribute only one VM during the<br>
semester and I would prefer that the VM was configured with the compiler<br>
supporting anonymous records.<br>
</blockquote>
<br></span>
Not an answer to your question, but some students find intuition in simply reordering to put 'left' on the left and 'right' on the right, with the data in the middle:<br>
<br>
type 'a tree = Leaf | Node of 'a tree * 'a * 'a tree<br>
<br>
Also a question: your type has data at the leaf as well as at nodes. Most people don't do that for a standard tree type, seeing the form I give above as more "natural" -- do you find your way has a teaching (or other) advantage?<span class="HOEnZb"><font color="#888888"><br>
<br>
John<br>
</font></span></blockquote></div><br></div>