ychr-0.1.0.0: test/golden/overload_basic/overload_basic.chr
:- module(overload_basic, [result/2, type(tags/0)]).
:- use_module(library(prelude)).
:- use_module(library(strings)).
:- chr_constraint result(any, any).
:- chr_type tags ---> test1 ; test2.
% Overloaded function: works on both int and string
:- class
(size(int) -> int),
(size(string) -> int).
size(N) | integer(N) -> N.
size(S) | string(S) -> string_length(S).
result(test1, R) <=> R is size(42).
result(test2, R) <=> R is size("hello").