Hi, guys, greetings!
This is a very confusing part of typeclass to me.
I can define an instance for "Secret e a", which the "Trap e" is being fixed.
But I can't figure out the way to also define a Functor instance for the first type variable, which is the value "Trap e" of "Secret e a"
For example:
data Secret e a
= Trap e
| Reward a
deriving (Show, Eq)
-- This one for the value "Reward a" works.
-- instance Functor (Secret e) where
-- fmap :: (a -> b) -> Secret e a -> Secret e b
-- fmap _ (Trap a) = Trap a
-- fmap f (Reward a) = Reward (f a)
But how do I possibly have the value "Trap e" also to work for fmap, is it for some reason that such cases are not necessary?