:- module bug271. :- interface. :- import_module string. :- typeclass stringable(X) where [ func to_string(X) = string ]. :- type a_or_b ---> a ; b. :- some [Y] pred p(a_or_b::in, Y::out) is det => stringable(Y). :- implementation. :- import_module int. :- import_module list. :- import_module io. :- import_module string. p(a, 13). p(b, 14). :- instance stringable(int) where [ (to_string(Int) = format("int %d", [i(Int)])) ].