[Haskell] GHC Error question
Ross Paterson
ross at soi.city.ac.uk
Mon Dec 11 07:41:09 EST 2006
On Mon, Dec 11, 2006 at 12:16:06PM +0000, Simon Peyton-Jones wrote:
> [...] Just to summarise, the difficulty is this:
> I have a dictionary of type (C a b1)
> I need a dictionary of type (C a b2)
> There is no functional dependency between C's parameters
>
> PS: the complete program is this:
> class C a b where
> op :: a -> a
>
> f :: C a b => a -> a
> f x = op x
That raises a point I'd wondered about. GHC requires only that each
type variable in the context be reachable from the type via a chain
of assertions:
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#type-restrictions
What's the rationale for that, rather than calling types like the above
type of f ambiguous?
The examples given in the User's Guide involve functional dependencies,
albeit obscured by superclasses
More information about the Glasgow-haskell-users
mailing list