I want to derive a Show
instance for a data structure which is very simple:
data MySQLConnectInfo = MySQLConnectInfo
{ mysqlHost :: String
, mysqlUser :: String
, mysqlPassword :: String
, mysqlDatabase :: String
, mysqlPort :: Int
, mysqlUnixSocket :: String
, mysqlGroup :: Maybe String
}
I do not wish to modify the library's code manually. Is it possible to automatically derive a Show
instance well after the definition (in another module) as one would create it when adding a deriving
clause after the data
definition?
I tried to leave a instance Show MySQLConnectInfo
but the compiler complains that there is no definition of show
or showPrec
. It is a pain to manually write an instance of Show
, is there a better, automagical way (possibly using GHC extensions)?