&gt; We do not know a whole lot about code just because it has type checked. It may feel like you do, but that&#x27;s just a feeling.<p>You can know a whole lot because it type-checked. What exactly you know depends on how you leveraged the type system.<p>For example, if you define a red black tree as is defined here:
<a href="https:&#x2F;&#x2F;github.com&#x2F;yairchu&#x2F;red-black-tree&#x2F;blob&#x2F;master&#x2F;RedBlackTree.hs#L26-L37" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yairchu&#x2F;red-black-tree&#x2F;blob&#x2F;master&#x2F;RedBla...</a><p>You <i>know</i> code will <i>never</i> generate trees that break the red&#x2F;black invariants. The tree is <i>guaranteed</i> to be balanced by the type checking process.<p>&gt; The name of the function might be `sort`, but it could actually fail to sort items, in spite of type checking<p>Unless you use a dependently-typed language.<p>Consider this `sort` definition:<p><pre><code>  sort : (in:List n a) -&gt; (out:SortedList n a, IsPermutation in out)
</code></pre>
&quot;List n a&quot; is a list of length &quot;n&quot; of values of type &quot;a&quot;. 
&quot;SortedList n a&quot; is a sorted list of length &quot;n&quot; of values of type &quot;a&quot;. &quot;IsPermutation a b&quot; is a proof that a is a permutation of b (returned from sort).<p>Here&#x27;s how you can define a type like SortedList:<p><pre><code>  type SortedList n a =
    exists min. SortedList&#x27; min n a
  data SortedList&#x27; min n a where
    Empty : SortedList&#x27; min 0 a
    Cons : LessOrEq x y -&gt; (x:a) -&gt; SortedList&#x27; y n a -&gt; SortedList&#x27; x (1+n) a
</code></pre>
SortedList thus embeds a proof alongside each element that it is less than or equal to the lower-bound of the remaining list (i.e: the next element).<p>Type-checking this guarantees that `sort` does the right thing, modulo resource-use&#x2F;performance (or termination, depending on your type checker).<p>Resource use (bounding) can also be type-checked, but requires leveraging the type system even more.<p>These guarantees aren&#x27;t free -- you have to write the types for them, and you have to prove them by instantiating values of these types. But you can opt in or out of each of these guarantees -- leverage the type system as much as you want.<p>With dynamic typing, you just don&#x27;t have this tool at your disposal at all. No flexibility to guarantee anything. You&#x27;re <i>forced</i> to opt out completely.