<commit_before>#pragma once

#include <boost/variant.hpp>
#include <atomic>
#include <vector>

namespace grml
{
    enum class BasicType
    {
        INT,
        BOOL,
        REAL
    };

    struct TypeVariable
    {
        int64_t id;

        TypeVariable() : id(counter++) {}
        TypeVariable(int64_t i) : id(i) {}

        friend bool operator==(const TypeVariable& lhs, const TypeVariable& rhs)
        {
            return lhs.id == rhs.id;
        }
    private:
        static std::atomic_int64_t counter;
    };

    struct FunctionType;

    using Type = boost::variant<
        BasicType,
        TypeVariable,
        boost::recursive_wrapper<FunctionType>
    >;

    struct FunctionType
    {
        using Parameters = std::vector<Type>;

        Type result;
        Parameters parameters;

        FunctionType(Type r, Parameters ps) : result(std::move(r)), parameters(std::move(ps)) {}

        friend bool operator==(const FunctionType& lhs, const FunctionType& rhs)
        {
            return lhs.result == rhs.result && lhs.parameters == rhs.parameters;
        }
    };
}<commit_msg>Add unify combine substitute stubs<commit_after>#pragma once

#include <boost/variant.hpp>
#include <atomic>
#include <vector>
#include <unordered_map>

namespace grml
{
    enum class BasicType
    {
        INT,
        BOOL,
        REAL
    };

    struct TypeVariable
    {
        int64_t id;

        TypeVariable() : id(counter++) {}
        TypeVariable(int64_t i) : id(i) {}

        friend bool operator==(const TypeVariable& lhs, const TypeVariable& rhs)
        {
            return lhs.id == rhs.id;
        }
    private:
        static std::atomic_int64_t counter;
    };

    struct FunctionType;

    using Type = boost::variant<
        BasicType,
        TypeVariable,
        boost::recursive_wrapper<FunctionType>
    >;

    struct FunctionType
    {
        using Parameters = std::vector<Type>;

        Type result;
        Parameters parameters;

        FunctionType(Type r, Parameters ps) : result(std::move(r)), parameters(std::move(ps)) {}

        friend bool operator==(const FunctionType& lhs, const FunctionType& rhs)
        {
            return lhs.result == rhs.result && lhs.parameters == rhs.parameters;
        }
    };

    struct TypeVariableHasher
    {
        std::size_t operator()(const TypeVariable& tv) const
        {
            return tv.id;
        }
    };

    using Substitution = std::unordered_map<TypeVariable, Type, TypeVariableHasher>;

    Substitution unify(const Type& lhs, const Type& rhs);
    Substitution combine(const Substitution& lhs, const Substitution& rhs);
    Type substitute(const Type& type, const Substitution& substitution);
}
{'fraction_non_alphanumeric': 0.10613294160852002, 'fraction_numerical': 0.0044069041498347415, 'mean_word_length': 2.3018181818181818, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3247163', 'n_tokens_mistral': 809, 'n_tokens_neox': 767, 'n_words': 193}