I'm experimenting with Data.Functor.Compose
and wanted to write a Show instance for it when trying things out in ghci. What I have (which is working) is:
{-# LANGUAGE FlexibleContexts #-}
instance (Show (f (g a))) => Show (Compose f g a) where
show = show . getCompose
What I was wondering is: is there a way to write this Show instance without FlexibleContexts?
I don’t think it is possible. To quote the GHC documentation for FlexibleContexts:
In Haskell 98, the assertions in the context of the instance declaration must be of the form C a where a is a type variable that occurs in the head.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With