{#comments}
============
Types as Comments
-----------------
**Types are Machine Checked Comments**
+ Express same *requirements*
+ But *connected to* code
**Always in sync as code changes**
Liquid Types as Machine Checked Comments
========================================
Example: Data.Map
-----------------
**Requirement**
`Map a b` is a *binary search* ordered tree
Example: Data.Map
-----------------
**Comment**
\begin{spec}
-- @join@ assumes that all values in [l] < [k]
-- and all values in [r] > [k], and
-- that [l] and [r] are valid trees.
\end{spec}
**Type**
\begin{spec}
join :: k:a -> b
-> l:Map {v:a | v < k} b
-> r:Map {v:a | v > k} b
-> Map a b
\end{spec}
Example: Data.ByteString
------------------------
**Requirement**
Fast, low-level indices into a `ByteString` must be in bounds.
Example: Data.ByteString
------------------------
**Comment**
\begin{spec}
-- Unsafe 'ByteString' index (subscript) ...
-- omits the bounds check, which means there
-- is an obligation to ensure the bounds are
-- checked in some other way.
\end{spec}
Example: Data.ByteString
------------------------
**Requirement**
Fast *truncation* requires valid size.
Example: Data.ByteString
------------------------
**Comment**
\begin{spec}
-- omits the checks on @n@ so there is
-- an obligation to provide a proof
-- that @0 <= n <= 'length' xs@
\end{spec}
**Type**
\begin{spec}
unsafeTake :: n:Nat
-> {v:ByteString | n <= bLength v}
-> {v:ByteString | n = bLength v}
\end{spec}
{#cont}
=========
Continue
--------
[[continue...]](12_Conclusion.lhs.slides.html)
{#recap}
=========
Recap
-----
1. Refinements: Types + Predicates
2. Subtyping: SMT Implication
3. Measures: Strengthened Constructors
4. Abstract: Refinements over functions and data
5. **Evaluation**
6.