This works fine:
data Possibly a = LolNope | Yeppers a deriving (Eq, Show)
instance Functor Possibly where
fmap f (Yeppers a) = Yeppers (f a)
fmap _ LolNope = LolNope
Repeating the LolNope in the last line doesn't look elegant. Replacing the last line with the following doesn't work:
fmap _ z = z -- error: Couldn't match type ‘a’ with ‘b’ ...
This doesn't work either:
fmap _ z@(_) = z -- error: Couldn't match type ‘a’ with ‘b’ ...
Why don't they work, and are there alternatives that work?