
10 Jan
2007
10 Jan
'07
3:56 p.m.
Misha Aizatulin wrote:
The question I'd like to ask is whether there is some trickery to circumvent this problem. In the f function I'd like to be able to hint to the compiler that I want Show to be derived from cxt which is attached to the Box, but I see no way of doing that.
An explicit way of pointing at the dictionary is possible using GADT: data ShowCxt a where Sh :: Show a => ShowCxt a f :: forall cxt . (Contains cxt ShowCxt) => Box cxt -> String f (Box (x :: a)) = case subDict (dict :: cxt a) of Sh -> show x The above compiles in GHC HEAD (6.6 is unfortunately not enough). Regards, Zun.