On 27-Mar-2000, Jan Brosius <[EMAIL PROTECTED]> wrote:
> 1.  In Haskell there are 2 sorts of variables : variables that range over values of 
>a specific type and "type variables".
> 
> e.g.in   fact n = n * fact (n - 1)  (the factorial function n ranges over the values 
>of type Int.
> 
> and  in   the  type    ST s a   where  s  and  a  are variables that only range over 
>types
> 
> Am I correct?

Yes.

> 2.  I would first like to come back to the type signature
> 
>                            f :: a -> b
> 
> I can say the type of   f  is  a -> b  , isn't it?

Well, people often do say that, but it is a little sloppy; if you want
to be precise, it is more correct to say that the type of `f' is
`forall a,b .  a -> b'.

> But a and b are both variables. Question
> 
> can I replace the General type b  by  the type c -> d  ?

In general that transformation does not preserve type-correctness.
Changing `b' to `c -> d' in the type signature might
change a type-correct program into an ill-typed one.

For example, if the program contains

        foo :: Int -> Int
        foo x = f x

then changing the type signature of `f' to `f :: a -> c -> d'
would mean that the previously type-correct call to `f' here
would now become a type error.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to