[mercury-users] float__min
Tyson Dowd
trd at cs.mu.OZ.AU
Thu Jan 7 14:11:37 AEDT 1999
On 07-Jan-1999, Mark NG <markn at students.cs.mu.oz.au> wrote:
>
> G'day !
>
> I am rather new to mercury and having troubling using float__min (func/0).
>
> I tried to compile this program :-
>
> :- module float_test.
> :- import_module io.
> :- interface.
> :- pred main(io__state::di, io__state::uo) is det.
> %--------------------------------------------------------------------%
> :- implementation.
> :- import_module float.
> main -->
> { F = float__min },
> io__print(F).
>
> %------------------------------------------------------------
> and got...
>
> float_test.m:015: In clause for predicate `float_test:main/2':
> float_test.m:015: error: ambiguous overloading causes type ambiguity.
> float_test.m:015: Possible type assignments include:
> float_test.m:015: F :: float or (func(float, float) = float)
>
>
> How do I get it to work ??
There are two functions called `float__min' -- you need to make
sure the compiler can figure out which one you mean.
The only thing you do with F is print it.
io__print is pretty generic -- it doesn't provide any extra type information.
If you add a goal such as
{ _X = F + 0.0 }
this will clearly mark F as being of type `float' (unless you define
a `+' that works on things of type `func(float, float) = float').
But it's a bit ugly.
You could use a print statement such as io__write_float instead of
io__print -- this will make it clear that F is of type `float'
Or you can write a predicate is_float(float::in) which is always
true, and use it on F to make sure it is a float.
--
Tyson.
More information about the users
mailing list