
Brent Yorgey
writes: On Tue, Sep 03, 2013 at 11:33:46AM +0000, AntC wrote:
I want an instance and type improvement constraint of the form
instance (f ~ (-> Bool)) => C Foo (f b) where ...
There is no operator section syntax for types. Moreover, this is not just an issue of syntax: it is impossible to partially apply a type constructor to anything other than its first argument, because there is no type-level lambda.
Thank you Brent, so I'm not being entirely dumb ;-).
data FlipFun b -- abstract instance (f ~ FlipFun) => C Foo (f b) where ...
And a type function inside the class to generate the type. But then I'd have to apply the type function for all instances, and in most places it'd be id.
That's the only way to do it that I know of.
OK, I've got that working. My class is a helper doing type discrimination. So the constraints have 'infected' the caller and the caller's caller, etc ... Elegant it ain't. AntC