// Path: src/main/java/inference/Substitution.java
// public class Substitution extends Substitutable<Substitution> {
//     private HashMap<TVariable, Type> subs = new HashMap<>();
// 
//     public Substitution() {}
// 
//     public Substitution(TVariable variable, Type type) {
//         subs.put(variable, type);
//     }
// 
//     private Substitution(Substitution previous) {
//         subs.putAll(previous.subs);
//     }
// 
//     public Substitution(List<TVariable> vars, List<Type> substitute) {
//         if(vars.size() != substitute.size())
//             throw new IllegalArgumentException("Number of variables have to match number of types");
// 
//         for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i));
//     }
// 
//     public List<TVariable> variables() {
//         return new LinkedList<>(subs.keySet());
//     }
// 
//     public Type substituteOf(TVariable var) {
//         return subs.get(var);
//     }
// 
//     public Substitution composeWith(Substitution sub) {
//         Substitution substituted = new Substitution(sub);
//         substituted.apply(this);
//         subs.putAll(substituted.subs);
//         return this;
//     }
// 
//     @Override
//     public HashSet<TVariable> ftv() {
//         HashSet<TVariable> freeVars = new HashSet<>();
//         for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv());
//         return freeVars;
//     }
// 
//     @Override
//     public Substitution substitute(TVariable var, Type t) {
//         for (TVariable variable : variables())
//             subs.replace(variable, substituteOf(variable).substitute(var, t));
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return subs.toString();
//     }
// 
//     @Override
//     public Substitution identity() {
//         return this;
//     }
// }


import inference.Substitution;
import java.util.HashMap;
import java.util.HashSet;
        return result;
    }

    // Substitutable - Begin
    @Override
    public Type substitute(TVariable var, Type type) {
        TFunction result;
        String before = this.toString();
        //*
        left = left.substitute(var, type);
        right = right.substitute(var, type);
        result = this;
        /*/
        result = function(left.substitute(var, type), right.substitute(var, type));
        //*/

        System.out.println(var + " => " + type + " \n\t" + before + " => " + result + "\n");
        return result;
    }

    @Override
    public HashSet<TVariable> ftv() {
        HashSet<TVariable> set = new HashSet<>(left.ftv());
        set.addAll(right.ftv());
        return set;
    }
    //Substitutable - End


    @Override
// Path: src/main/java/inference/Substitution.java
// public class Substitution extends Substitutable<Substitution> {
//     private HashMap<TVariable, Type> subs = new HashMap<>();
// 
//     public Substitution() {}
// 
//     public Substitution(TVariable variable, Type type) {
//         subs.put(variable, type);
//     }
// 
//     private Substitution(Substitution previous) {
//         subs.putAll(previous.subs);
//     }
// 
//     public Substitution(List<TVariable> vars, List<Type> substitute) {
//         if(vars.size() != substitute.size())
//             throw new IllegalArgumentException("Number of variables have to match number of types");
// 
//         for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i));
//     }
// 
//     public List<TVariable> variables() {
//         return new LinkedList<>(subs.keySet());
//     }
// 
//     public Type substituteOf(TVariable var) {
//         return subs.get(var);
//     }
// 
//     public Substitution composeWith(Substitution sub) {
//         Substitution substituted = new Substitution(sub);
//         substituted.apply(this);
//         subs.putAll(substituted.subs);
//         return this;
//     }
// 
//     @Override
//     public HashSet<TVariable> ftv() {
//         HashSet<TVariable> freeVars = new HashSet<>();
//         for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv());
//         return freeVars;
//     }
// 
//     @Override
//     public Substitution substitute(TVariable var, Type t) {
//         for (TVariable variable : variables())
//             subs.replace(variable, substituteOf(variable).substitute(var, t));
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return subs.toString();
//     }
// 
//     @Override
//     public Substitution identity() {
//         return this;
//     }
// }


// Path: src/main/java/types/TFunction.java
import inference.Substitution;
import java.util.HashMap;
import java.util.HashSet;

        return result;
    }

    // Substitutable - Begin
    @Override
    public Type substitute(TVariable var, Type type) {
        TFunction result;
        String before = this.toString();
        //*
        left = left.substitute(var, type);
        right = right.substitute(var, type);
        result = this;
        /*/
        result = function(left.substitute(var, type), right.substitute(var, type));
        //*/

        System.out.println(var + " => " + type + " \n\t" + before + " => " + result + "\n");
        return result;
    }

    @Override
    public HashSet<TVariable> ftv() {
        HashSet<TVariable> set = new HashSet<>(left.ftv());
        set.addAll(right.ftv());
        return set;
    }
    //Substitutable - End


    @Override
    protected Substitution unifyWith(TFunction fun) {