[mercury-users] Some more Queries

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 9 21:44:58 AEDT 2002


On 09-Nov-2002, Noel  Pinto <cool4life at rediffmail.com> wrote:
> main -->
> 	io__open_binary_input("blah.txt", Res),
> 	(
> 		{ Res = ok(Str)}
> 	->
> 		io__read_binary(Str, ResStr),
> 		(
> 			{ResStr = ok(Binr)}
> 		->
> 			io__write_string(" Binary representation of a term 
> 			is : "),
> 			io__write_binary(Binr), nl
> 		;
> 			{ ResStr = eof }
> 		->
> 			io__write_string(" End of File.\n")
> 		;
> 			io__write_string(" Error occured.\n")
> 		)
> 	;
> 		{ Res = error(Err)}
> 	->
> 		{ io__error_message(Err, ErrMsg)},
> 		io__write_string("Error occured: "),
> 		io__write_string(ErrMsg)
> 	;
> 		[]
> 	).
> I really cannot figure how to get around the following error shown 
> below...
> test3.m:005: In predicate `test3:main/2':
> test3.m:005:   warning: unresolved polymorphism.
> test3.m:005:   The variables with unbound types were:
> test3.m:005:       Binr :: T
> test3.m:005:       ResStr :: (io:result(T))
> test3.m:005:   The unbound type variable(s) will be implicitly
> test3.m:005:   bound to the builtin type `void'.

You need to add an explicit type qualifier to specify the type for `Binr'.
For example, if you want this code to read an int, change

 	io__read_binary(Str, ResStr),

to

 	io__read_binary(Str, ResStr `with_type` io__result(int)),

If you want it to read a float, use

 	io__read_binary(Str, ResStr `with_type` io__result(float)),

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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