Encoding. Binary sums/coproducts › Introduction [01GJ]

We expect to have two constructors, corresponding to the left and right injections of the binary sum.

\frac { u:A }{ \mathsf {inl}~u:A+B } \qquad \frac { u:B }{ \mathsf {inr}~u:A+B }

We can achieve this by defining the two constructors to pair the appropriate label with the data:

\begin {aligned} \mathsf {inl}~u &:\equiv \left \langle \mathsf {true},u\right \rangle \\ \mathsf {inr}~u &:\equiv \left \langle \mathsf {false},u\right \rangle \end {aligned}

Make sure you understand for yourself why these are well-typed!