On Mon, 14 Jun 1999, Jose Bernardo Barros wrote:

> 
> According to the definition of the class Bounded, minBound and maxBound
> have types
> 
>   minBound :: Bounded a => a
>   maxBound :: Bounded a => a
>            
> Suppose I define the function 
> 
> f (minBound, maxBound) = (maxBound, minBound)
> 
> shouldn't its type be 
> 
>   f :: (Bounded a, Bounded b, Bounded c, Bounded d) => (a,b) -> (c,d)  ?
> 
> hugs gives me the following answer
> 
> Main> :t f
> f :: (a,b) -> (b,a)   
> 
> jbb
> 

f (minBound, maxBound) = (maxBound, minBound)

is equal to 

f (a,b) = (b,a)

and its type is indeed the inferred one. The name you choose for the free
variables (minBound or a) does not matter, and has no connection at all
with the functions minBound and maxBound.

You can give the function the following type:

f :: (Bounded a, Bounded b) => (a,b) -> (b,a)


/Lars L




Reply via email to