fundeps for extended Monad definition
Simon Peyton-Jones
simonpj@microsoft.com
Tue, 4 Mar 2003 09:22:37 -0000
| I believe something along the lines of the following would work:
|=20
| > class C a b | a -> b where { foo :: b -> String }
| > instance C Int Int where { foo x =3D show (x+1) }
| > x :: forall b. C Int b =3D> b
| > x =3D 5
|=20
| (Supposing that the above definition were valid; i.e., we didn't get
the
| type signature error, this reads that x has type "b" for all types
| "b" such that C Int b -- the fact that there is only one such type
(due to
| the fun dep) is for us to know.)
|=20
| Then, we should be able to say:
|=20
| > foo x
|=20
| and get "6".
I understand that is what you would like, but I do not know how to
achieve it in a reasonable way. (By "reasonable" I mean both in terms
of a reasonably simple type inference algorithm, and in terms of a
reasonable translation into a typed intermediate language. The latter
is, in a sense, just an implementation matter, but I have found it to be
an excellent sanity check.)
Simon
|=20