Hi Anthony
Perhaps I've misunderstood, but there's a few issues with the approaches you suggest:
Firstly, you refer to
https://wiki.haskell.org/GHC/AdvancedOverlap. Unfortunately (unless I've missed something) these involve listing all the instances of parent classes. I'm trying to avoid that. Indeed if I have to explicitly list all the instances I might as well write them the normal way so I'm not sure what the point of any trickery is.
I also tried the associated types approach you suggested towards the end of your email previously. This works perfectly fine if you can edit the base class, but I can't edit say, "Applicative" or "Num". I did something like the following, but I ran into a problem:
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
data Satisfied
class Num t => MyNum t where
type IsNum t
instance Num t => MyNum t where
type IsNum t = Satisfied
data D = D
f :: IsNum t ~ Satisfied => t -> ()
f _ = ()
main = print $ f D
Ideally this should not compile, but unfortunately it happily compiles, showing that GHC generates an "IsNum" type family instance for "D", despite the fact that "Num D" is not satisfied.
Any suggestions going forward from here?