:- op(1199, fx, [(subtype), (suptype), (type), (pred)]).
:- op(1198, xfy, (-->)).		% loaded from file typeops normaly

% reverse a list

 
%+++++++++++++++++++++++++++++ type definitions +++++++++++++++++++++++ 

:- type    int.
:- type    nat.
:- subtype negint < int.
:- subtype nat    < int.
:- subtype posint < nat.
:- subtype zero   < nat.
:- type    zero   --> 0.
:- type    posint --> {X^(integer(X),X>0)}.
:- type    negint --> {X^(integer(X),X<0)}.

:- type    list(T) --> [] ; [ T | list(T) ].

 
%+++++++++++++++++++++++++++++ predicates  +++++++++++++++++++++++ 

:- pred append(list(T),list(T),list(@T)).
append([],L,L).
append([X|Xs],Y,[X|XYs]) :- append(Xs,Y,XYs).

:- pred reverse(list(@T),list(@T)).
reverse([],[]).
reverse([H|T],R) :- reverse(T,RT),append(RT,[H],R).
reverse([H|T],R) :- reverse(T,RT),append(RT,H,R).  	% ill-typed


:- pred q(list(@T),list(@T)).
q(L1,L2) :- reverse(L1,L2).
q(L1,L2) :- reverse([L1],L2).      			% ill-typed
