cvs commit: fptools/ghc/compiler/typecheck TcMonad.lhs TcSimplify.lhs fptools/ghc/compiler/types FunDeps.lhs Unify.lhs
Mark P Jones
mpj@cse.ogi.edu
Tue, 30 Jan 2001 12:37:24 -0800
| I'm really not sure how to solve this. Consider
|=20
| class C a b | a -> b { op :: a -> b -> Int }
| instance C Char Bool=20
|=20
| Now is this ok?
|=20
| f :: forall b. C Char b =3D> Char -> b -> Int
| f x y =3D op x y
|=20
| Mark J says yes, that's a principal type for f.
I'd like to clarify. Yes, the type is valid, at least as far
as the theory is concerned. But I have strong personal doubts
about it as good language design ... as I said before, "from a
practical perspective, one can argue that the polymorphic type
is misleading, obfuscating, and cumbersome." It might be better
to consider a notation that allows partial type specifications.
(e.g., allow ".." in any part of a type where the user doesn't
want to go into more detail.)
That said, I agree with Mark's comments. I think it is possible
to code up the test you are looking for to determine validity of
declared versus inferred types, and I don't think you should worry
about the impact on calling convention as a result of a declared
type. As things already stands, if a user writes:
foo :: Eq a =3D> a -> String
foo x =3D "I don't need equality"
then you still have to pass in a dictionary at each call, not because
it's really necessary, but because the user asked for it.
All the best,
Mark