As far as I know, Prolog does not have any built-in mechanisms for generic programming. It's possible to simulate generics using unification, but this requires type-checking at runtime:
:- initialization(main).
:- set_prolog_flag(double_quotes, chars).
% this is a "generic" predicate, where A and B have the same type
add(A,B,C) :-
generic_types([A:Type,B:Type]),
(Type = number,
C is A + B;Type=var,C = A+B).
main :-
add(A,B,C),
add(3,4,D),
writeln(C),
writeln(D).
generic_types([]).
generic_types([A:B|C]) :-
member(B,[var,nonvar,float,rational,number,atom,atomic,compound,callable,ground,acyclic_term]),
call(B,A),
generic_types(C).
has_type(Type,A) :-
call(Type,A).
Is it possible to write "generic" predicates without checking the type of each variable at runtime?