ComplexIntegerTest.java
package com.acme.math;

import church.lang.ByteStream;
import church.lang.operators.Arithmetic;
import church.lang.operators.Arithmetic.$$neg;
import church.lang.operators.Arithmetic.$$prd;
import church.lang.operators.Arithmetic.$$sub;
import church.lang.operators.Arithmetic.$$sum;
import church.lang.operators.Relational.$$equal;
import church.lang.operators.Streams.$$encode;
import church.math.Complex;
import church.primitives.Integers;
import church.primitives.Objects;

import static church.lang.operators.Streams.output;
import static church.math.Complex.complex;

@SuppressWarnings("unchecked")
public class ComplexIntegerTest {
    private static final $$neg<Integer>                            $S0  = Integers::$neg;
    private static final $$neg<Complex<Integer>>                   $S1  = Complex.$neg($S0);
    private static final $$sum<Integer>                            $S2  = Integers::$sum;
    private static final $$sum<Complex<Integer>>                   $S3  = Complex.$sum($S2);
    private static final $$sub<Complex<Integer>>                   $S4  = Arithmetic.$sub($S3, $S1);
    private static final $$sub<Integer>                            $S5  = Integers::$sub;
    private static final $$prd<Integer, Integer>                   $S6  = Integers::$prd;
    private static final $$prd<Complex<Integer>, Complex<Integer>> $S7  = Complex.$prd($S5, $S6, $S2);
    private static final $$encode<ByteStream, String>              $S8  = Objects::$encode;
    private static final $$encode<ByteStream, Integer>             $S9  = Integers::$encode;
    private static final $$encode<ByteStream, Complex<Integer>>    $S10 = Complex.$encode($S8, $S9);
    private static final $$equal<Integer>                          $S11 = Integers::$equal;
    private static final $$equal<Complex<Integer>>                 $S12 = Complex.$equal($S11);

    public static void main(String[] args) {
        Complex<Integer> c1 = complex(1, 2);
        Complex<Integer> c2 = complex(3, 4);
        Complex<Integer> c3 = $S1.$neg(c1);
        Complex<Integer> c4 = $S4.$sub($S3.$sum(c1, $S7.$prd(c2, c3)), c3);
        $S8.$encode($S10.$encode(output, c4), "\n");
        assert $S12.$equal($S7.$prd(c1, c2), complex(-5, 10));
    }

}