%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% A cut-down version of tests/general/higher_order.m for Github issue #103.

:- module gh_103.
:- interface.
:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.
:- import_module list.
:- import_module string.

:- pred map(pred(T1, T2), list(T1), list(T2)).
:- mode map(pred(in, in) is semidet, in, in) is semidet.

map(_Pred, [], []).
map(Pred, [X | Xs], [Y | Ys]) :-
    call(Pred, X, Y),
    gh_103.map(Pred, Xs, Ys).

:- pred double(string::in, string::out) is det.

double(X, Y) :-
    string.append(X, X, Y).

main(!IO) :-
    ( if
        gh_103.map(
            ( pred(X::in, Y::in) is semidet :-
                double(X, Y)
            ), ["ab"], ["abab"])
    then
        io.write_string("Yes\n", !IO)
    else
        io.write_string("Oops\n", !IO)
    ).
