
Hey Oleg, Thanks for the response! Excerpts from oleg's message of Thu Aug 19 03:51:05 -0400 2010:
Granted, we would have to write boilerplate as we have to re-direct specialized methods to the general ones.
Interesting. As far as I can tell, this means that any general method that I want to use in the specialized typeclass needs to be explicitly redirected in the specialized typeclass's definition. What does a user do if they would like to write their own generic function (using the other generic functions) and then specialize it?
Here is the instance of this trick, adopted to use type families rather than functional dependencies (no UndecidableInstances is required now):
The example (concatenated with the previous full code), doesn't typecheck for me: Prelude> :r [1 of 1] Compiling Main ( Test.hs, interpreted ) Test.hs:60:18: No instance for (Apply (NM mg n)) arising from a use of `apply' at Test.hs:60:18-38 Possible fix: add an instance declaration for (Apply (NM mg n)) In the expression: apply (NM :: NM mg n) In the definition of `monadicValue'''': monadicValue''' = apply (NM :: NM mg n) Test.hs:60:18: Couldn't match expected type `m n1 ()' against inferred type `Typ (NM mg n)' NB: `Typ' is a type function, and may not be injective In the expression: apply (NM :: NM mg n) In the definition of `monadicValue'''': monadicValue''' = apply (NM :: NM mg n) Failed, modules loaded: none Cheers, Edward