left' ≡ dimap swapE swapE . right' where swapE :: Either a b -> Either b a swapE = either Right Left rmap Left ≡ lmap Left . left' lmap (right f) . left' ≡ rmap (right f) . left' left' . left' ≡ dimap assocE unassocE . left' where assocE :: Either (Either a b) c -> Either a (Either b c) assocE (Left (Left a)) = Left a assocE (Left (Right b)) = Right (Left b) assocE (Right c) = Right (Right c) unassocE :: Either a (Either b c) -> Either (Either a b) c unassocE (Left a) = Left (Left a) unassocE (Right (Left b)) = Left (Right b) unassocE (Right (Right c)) = Right c
unleft ≡ unright . dimap swapE swapE where swapE :: Either a b -> Either b a swapE = either Right Left rmap (either id absurd) ≡ unleft . lmap (either id absurd) unfirst . rmap (second f) ≡ unfirst . lmap (second f) unleft . unleft ≡ unleft . dimap assocE unassocE where assocE :: Either (Either a b) c -> Either a (Either b c) assocE (Left (Left a)) = Left a assocE (Left (Right b)) = Right (Left b) assocE (Right c) = Right (Right c) unassocE :: Either a (Either b c) -> Either (Either a b) c unassocE (Left a) = Left (Left a) unassocE (Right (Left b)) = Left (Right b) unassocE (Right (Right c)) = Right c