From 8b51fe7771908d739648001796cfd7b3f612b3f7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Mar 2016 16:49:29 -0500 Subject: [PATCH] MaybeBoth is Coalescent. --- src/Data/Functor/Both.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/Functor/Both.hs b/src/Data/Functor/Both.hs index ee1ebbb0b..6d4d2dba5 100644 --- a/src/Data/Functor/Both.hs +++ b/src/Data/Functor/Both.hs @@ -2,6 +2,7 @@ module Data.Functor.Both where import Data.Align +import Data.Coalescent import Data.Bifunctor import Data.Bifunctor.These import Prelude hiding (zipWith, fst, snd) @@ -57,3 +58,6 @@ instance Applicative MaybeBoth where instance Crosswalk MaybeBoth where crosswalk f (MaybeBoth ab) = runBothWith (alignWith (MaybeBoth . maybeBothOfThese)) (maybe nil f <$> ab) + +instance Coalescent a => Coalescent (MaybeBoth a) where + coalesce as bs = sequenceL (coalesce <$> as <*> bs)