:- module bug480b. :- interface. :- import_module bool. :- import_module maybe. :- type mystate ---> mystate( visited :: bool, counter :: maybe(int) ). :- pred visit(mystate::in, mystate::out) is det. :- implementation. :- import_module int. visit(!State) :- !State ^ visited := yes, ( !.State ^ counter = yes(N), !State ^ counter := yes(N + 1) ; !.State ^ counter = no ).