<div class="hintbox">We could also use a triple of <span class="fixed">(Int, Int, Int)</span> to represent a road section. Using tuples instead of making your own algebraic data types is good for some small localized stuff, but it’s usually better to make a new type for things like this. It gives the type system more information about what’s what. We can use <span class="fixed">(Int, Int, Int)</span> to represent a road section or a vector in 3D space and we can operate on those two, but that allows us to mix them up. If we use <span class="fixed">Section</span> and <span class="fixed">Vector</span> data types, then we can’t accidentally add a vector to a section of a road system.</div>
0 commit comments