flexible contexts and context reduction

Sittampalam, Ganesh ganesh.sittampalam at credit-suisse.com
Thu Mar 27 05:29:17 EDT 2008

> If you write the instance
>         instance Theta => Foo (T a b) where ...
> where Theta is an arbitrary context, then, given a dictionary for (Foo (T a b)), you can get dictionaries for each constraint in Theta.  Or in logic
>        Theta <=> Foo (T a b)
> In your example, Theta is empty.

>If you'd written
>        instance (Show a, Ix b) => Ord (a,b) then you could get a Show a and Ix b dictionaries from an Ord (a,b) dictionary.  (But not an Ord a or Ord b > one.)

I sort of see, but then what is Tom actually proposing? Replacing the body of the Ord declaration with something like OrdDict, thus forcing any possible instance for Ord (a, b) to provide OrdDict a and OrdDict b because of the definition of Super?

In the current world, the possibility of instances like (Foo, Foo) make it impossible to write the code I originally asked about, so something would have to change, either with Ord or with my code, to be able to do anything like it.


Please access the attached hyperlink for an important electronic communications disclaimer: 


More information about the Glasgow-haskell-users mailing list