I'm trying to define my own Show class named MyShow, and want to 'steal' instances from TextShow and Prelude.Show, and prefer the former one if both exists.
I tried following (showbPrec things is simplified to be focused):
{-# LANGUAGE UndecidableInstances #-}
import Data.Text (Text, pack, unpack)
import qualified Prelude as P
import qualified TextShow as T
class MyShow a where
showText :: a -> Text
instance {-# OVERLAPPING #-} TextShow a => MyShow a where
showText x = T.showt x
instance {-# OVERLAPPABLE #-} P.Show a => MyShow a where
showText x = pack (P.show x)
But I'm telled that Duplicate instance declarations is not allowed, so is there any way to define my own Show and reuse instances from others?