
9 Nov
2013
9 Nov
'13
9:18 p.m.
On Sat, Nov 9, 2013 at 7:53 PM, Ignas Vyšniauskas
I guess this is simply not type-able in System F?
There are System F types that can accomplish some cases of this; just not Hindley-Milner types. For instance: twicePair :: (forall a. a -> (a, a)) -> (forall a. a -> ((a,a),(a,a))) twicePair f = f . f That is, of course, very specific to your example. Doing significantly better is harder, and I don't think you'll ever get to the real type you want, which is: twice : ((a -> b) ∩ (b -> c)) -> a -> c I.E. look up interstection types if you're into this stuff. They tend to be less popular than quantifier-based polymorphism, though.