[mercury-users] odd warning..

Rob zharradan at suffering.org
Wed Sep 22 02:08:30 AEST 1999


Hello all.

I am getting a warning from the compiler that I have no idea how to go
about fixing.. so I thought I would share with you to see if anyone can
help :)

in handle_input.err:
handle_input.m:043: In predicate `handle_input:convert_to_float/2':
handle_input.m:043:   warning: unresolved polymorphism.
handle_input.m:043:   The variable with an unbound type was:
handle_input.m:043:       V_7 :: T
handle_input.m:043:   The unbound type variable(s) will be implicitly
handle_input.m:043:   bound to the builtin type `void'.

in handle_input.m, lines 43 & 44:
:- pred convert_to_float(list(char), float).
:- mode convert_to_float(in, out) is det.

I assume the problem is coming from the fact that I use this predicate
as a higher order constant in the following predicate:
:- pred check_io_result(io__result(list(char)), pred(T),
pred(list(char),T), T).
:- mode check_io_result(in, pred(out) is det, pred(in, out) is det, out)
is det.

Here is the code for the relevant predicates:
% This higher order predicate takes an io__result and predicates to
handle the
% eof and ok cases, and performs the correct action. This is to clean up
all
% the io error checking throughout this module - it removes the need to
have
% this code duplicated wherever a word is read in.
check_io_result(Res, EOF_Handler, OK_Handler, Output) :-
	(
	    Res = error(Error),
	    io__error_message(Error, Msg),
	    error(Msg)
	;
	    Res = eof,
	    call(EOF_Handler, Output)
	;
	    Res = ok(OK_Word),
	    call(OK_Handler, OK_Word, Output)
	).

% Display an error message due to invalid input, and terminate execution
% This predicate has an (unused) output so that it can be used as an
EOF_Handler
% in check_io_result/4
display_error(_) :-
	error("Invalid line in scene description").

% Convert a list of characters to a float
convert_to_float(Word, F) :-
	string__from_char_list(Word, S_F),
	(   
	    string__to_float(S_F, F0) ->
	    F = F0
	;
	    % Bind F to something, to keep the compiler happy
	    F = 0.0,
	    display_error(_)
	).


and an example call to check_io_result/4:
	io__read_word(R_Sx),
	{ check_io_result(R_Sx, display_error, convert_to_float, Sx) },



Any help would be greatly appreciated. :)
(The program compiles and runs.. and appears to work fine, but I would
like to know why I am getting the warning and how to fix it, so that I
know in the future. I also don't like having code that generates
warnings..)

Thanks,
Rob
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list