[Haskell-cafe] Status of TypeDirectedNameResolution proposal?
simonpj at microsoft.com
Wed Nov 18 09:43:08 EST 2009
| > Each 'foo' gives a type instance for TDNR_foo, mapping the type of the first
| argument to the type of that foo.
| Hmm... GHC doesn't allow this:
| type instance TDNR_foo () = forall a. () -> a -> a
| IIUC this restriction is necessary to guarantee termination. Given your analogy,
| wouldn't this proposal run into similar problems?
Maybe so. Of course I don't propose to *really* make a type function; just a new form of constraint. I am not sure of the details. But I'm disinclined to work it through unless there's a solid consensus in favour of doing something, and I do not yet sense such a consensus. My nose tells me that the typing questions will not be a blocker.
| > Of course that's already true of type classes:
| > data T a where
| > T1 :: Show a => T a
| > T2 :: Show a => T a
| > bar :: a -> T a -> String
| > bar x y = case y of
| > T1 -> show x
| > T2 -> show x
| > Then I get different show's.
| How so? Surely you'll get the same Show instance in both cases unless you have
| conflicting instances in your program?
T1 and T2 both bind a local (Show a) dictionary. I suppose you could argue that they must be the same, yes.
But anyway, the original TDNR thing is perfectly well defined. It might occasionally be surprising. But that doesn't stop the OO folk from loving it.
More information about the Haskell-Cafe