Exercise solution: These identity test


At this point, you should write tests for a Bifunctor for These. Rather than adding a dependency on the these package, we encourage you to add the type to your Lib module along with Functor and Bifunctor instances for that type, without importing it from the package.

data These a b = This a | That b | These a b
    deriving (Eq, Show)

instance Functor (These a) where
  fmap = _

instance Bifunctor These where
  bimap = _

You may have these instances left over from a previous lesson; feel free to reuse them. Add the these_id test to your Bifunctor Identity Tests group.


Sign up for access to the full page, plus the complete archive and all the latest content.