:- module table_tc. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. main(!IO) :- p(4, X), io.write(X, !IO), io.nl(!IO). :- pred p(T::in, int::out) <= tc(T). :- pragma memo(p/2, []). p(X, integer(X)). :- typeclass tc(T) where [ func integer(T) = int ]. :- instance tc(int) where [ integer(X) = X ].