<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">I've modified a hit detection system to change the status of objects instead of collecting ids, but when I try to compile now, for this type class definition:<div><br></div><div><div><font face="CascadiaMono-Regular">:- typeclass hittable(T) where</font></div><div><font face="CascadiaMono-Regular">[</font></div><div><font face="CascadiaMono-Regular"> func id(T) = int,</font></div><div><font face="CascadiaMono-Regular"> func as_point(T) = pointf,</font></div><div><font face="CascadiaMono-Regular"> func as_circle(T) = vector3f,</font></div><div><font face="CascadiaMono-Regular"> func as_rect(T) = rectangle,</font></div><div><font face="CascadiaMono-Regular"> func is_hit(T) = bool,</font></div><div><font face="CascadiaMono-Regular"> pred set_hit(T::in, T::out) is det</font></div><div><font face="CascadiaMono-Regular">].</font></div></div><div><br></div><div><span style="font-family: CascadiaMono-Regular;"> % Falling object: something to be avoided!</span></div><div><div><font face="CascadiaMono-Regular"> %</font></div><div><font face="CascadiaMono-Regular">:- instance hittable(fobject) where</font></div><div><font face="CascadiaMono-Regular">[</font></div><div><font face="CascadiaMono-Regular"> id(T) = T ^fid,</font></div><div><font face="CascadiaMono-Regular"> as_point(T) = fp_float_pt(T ^xy),</font></div><div><font face="CascadiaMono-Regular"> as_circle(T) = fp_float_v3(T ^xy, 1.0),</font></div><div><font face="CascadiaMono-Regular"> func(as_rect/1) is fo_bounds_rect,</font></div><div><font face="CascadiaMono-Regular"> is_hit(T) = T ^hit,</font></div><div><font face="CascadiaMono-Regular"> (set_hit(!T) :- !T ^hit := yes)</font></div><div><font face="CascadiaMono-Regular">].</font></div><div><font face="CascadiaMono-Regular"><br></font></div><div><font face="CascadiaMono-Regular"> % Missile: a point like object.</font></div><div><font face="CascadiaMono-Regular"> %</font></div><div><font face="CascadiaMono-Regular">:- instance hittable(missile) where</font></div><div><font face="CascadiaMono-Regular">[</font></div><div><font face="CascadiaMono-Regular"> id(T) = T ^missile_id,</font></div><div><font face="CascadiaMono-Regular"> as_point(T) = fp_float_pt(T ^mxy),</font></div><div><font face="CascadiaMono-Regular"> as_circle(T) = fp_float_v3(T ^mxy, 1.0),</font></div><div><font face="CascadiaMono-Regular"> func(as_rect/1) is missile_bounds_rect,</font></div><div><font face="CascadiaMono-Regular"> is_hit(T) = T ^hit,</font></div><div><font face="CascadiaMono-Regular"> (set_hit(!T) :- !T ^hit := yes)</font></div><div><font face="CascadiaMono-Regular">].</font></div><div><font face="CascadiaMono-Regular"><br></font></div><div><font face="CascadiaMono-Regular"> % Player. The players rocket ship.</font></div><div><font face="CascadiaMono-Regular"> %</font></div><div><font face="CascadiaMono-Regular">:- instance hittable(player) where</font></div><div><font face="CascadiaMono-Regular">[</font></div><div><font face="CascadiaMono-Regular"> id(_) = -1,</font></div><div><font face="CascadiaMono-Regular"> as_circle(T) = v2_circle(T ^xy, 1.0),</font></div><div><font face="CascadiaMono-Regular"> as_point(T) = v2_pointf(T ^xy),</font></div><div><font face="CascadiaMono-Regular"> is_hit(_) = no, %% SAFE?</font></div><div><font face="CascadiaMono-Regular"> func(as_rect/1) is player_bounds_rect,</font></div><div><font color="#ff2600" face="CascadiaMono-Regular"> (set_hit(!T) :- !T ^hit := yes) <===== COMPILER ERROR</font></div><div><font face="CascadiaMono-Regular">].</font></div></div><div><br></div><div>I get this error:</div><div><div><br></div><div><div><font face="CascadiaMono-Regular">level_ufo.m:767: In clause for type class method implementation:</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: type error in unification of variable `STATE_VARIABLE_T'</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: and functor `hit :='/2.</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: variable `STATE_VARIABLE_T' has type `player.player',</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: functor `hit :='/2 has overloaded type {</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: 'hit :='(ufo.ufo, bool.bool): ufo.ufo,</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: 'hit :='(player.missile, bool.bool): player.missile,</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: 'hit :='(level_ufo.fobject, bool.bool): level_ufo.fobject</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: }.</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: The partial type assignment was:</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: STATE_VARIABLE_T_0_6: player.player</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: STATE_VARIABLE_T_7: player.player</font></div><div><font face="CascadiaMono-Regular">level_ufo.m:767: V_9: bool.bool</font></div></div><div><br></div><div><br></div></div><div>I just can't see why it doesn't like this one but the previous two would appear to be fine, the error message confirms the type T as player.player which is correct but i don't understand why the error is present. Is it because the flags are all called hit in the different discriminated union types ?</div><div><br></div><div>Thanks.</div><div> </div></body></html>