-module(fsharp_collections).
-compile(nowarn_unused_vars).
-compile(nowarn_unused_function).
-export([hash_identity_from_functions/2, hash_identity_structural/0, hash_identity_reference/0, comparison_identity_from_function/1, comparison_identity_structural/0]).

hash_identity_from_functions(Hasher, Equals) ->
    #{get_hash_code => fun(X) ->
        Hasher(X)
end, equals => fun(X_1, Y) ->
        case fable_comparison:equals(X_1, undefined) of
            true ->
                case fable_comparison:equals(Y, undefined) of
                    true ->
                        true
                    ;
                    false ->
                        false
                end
            ;
            false ->
                case fable_comparison:equals(Y, undefined) of
                    true ->
                        false
                    ;
                    false ->
                        Equals(X_1, Y)
                end
        end
end}
.

hash_identity_structural() ->
    #{get_hash_code => fun(X) ->
        fable_comparison:hash(X)
end, equals => fun(X_1, Y) ->
        fable_comparison:equals(X_1, Y)
end}
.

hash_identity_reference() ->
    #{get_hash_code => fun(X) ->
        fable_comparison:hash(X)
end, equals => fun(X_1, Y) ->
        X_1 =:= Y
end}
.

comparison_identity_from_function(Comparer) ->
    #{compare => fun(X, Y) ->
        case fable_comparison:equals(X, undefined) of
            true ->
                case fable_comparison:equals(Y, undefined) of
                    true ->
                        0
                    ;
                    false ->
                        -1
                end
            ;
            false ->
                case fable_comparison:equals(Y, undefined) of
                    true ->
                        1
                    ;
                    false ->
                        Comparer(X, Y)
                end
        end
end}
.

comparison_identity_structural() ->
    #{compare => fun(X, Y) ->
        fable_comparison:compare(X, Y)
end}
.
