On Tue, Dec 13, 2005 at 09:46:31AM +0100, Emil Axelsson wrote:
Is this just a limitation of the current GATDs, or is it unreasonable of me to expect this to work?
AFAIK it is a current limitation of GADTs, which will be removed in GHC 6.6.
Is there any workaround, such as coercing the type of the value function?
I've had the same problem myself. The workaround is to replace some of type-class constraints with "witness" GADTs. The code I attached shows how you can do it. I chose to make HasX a GADT, and introduce the HasX' type-class, but the latter is only for convenience. Note the subtle change in Val's definition: data Val a where ... X :: HasX a -> Val a -- Unconstrained ^^ Best regards Tomasz -- I am searching for a programmer who is good at least in some of [Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland