GHC does not know how to show Type a.
data FunctorExample a = FunctorExample { val1 :: a,
val2 :: String
} deriving (Show)
instance Functor FunctorExample where
fmap f (FunctorExample x y) = FunctorExample (f x) (y ++ " " ++ show x)
I've tried a number of things, including: setting a type constraint in data (now deprecated), and using {-# LANGUAGE InstanceSigs #-} to add a constraint for fmap and adding the type signature suggested below, with no success (though it's possible my type signature was flawed...).
* No instance for (Show a) arising from a use of `show'
Possible fix:
add (Show a) to the context of
the type signature for:
fmap :: forall a b.
(a -> b) -> FunctorExample a -> FunctorExample b
Is there no standard way of constraining a to be a Show instance? It happens to always be an Int in my usage.