From 2da930ae53e79bfdd1deed75dfb740f2919fa287 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 31 Mar 2016 14:45:04 -0400 Subject: [PATCH] Add a function to construct Maybe These from two Maybes. --- src/Alignment.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Alignment.hs b/src/Alignment.hs index 077ce76a5..6995f38ab 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -165,6 +165,12 @@ group2 ranges child | Just (headRanges, tailRanges) <- unconsThese ranges atRight (Join (These as (b:bs))) = Join (These as bs) atRight (Join (That (b:bs))) = Join (That bs) atRight other = other +maybeThese :: (Maybe a, Maybe b) -> Maybe (These a b) +maybeThese (Just a, Just b) = Just (These a b) +maybeThese (Just a, _) = Just (This a) +maybeThese (_, Just b) = Just (That b) +maybeThese _ = Nothing + unconsThese :: Join These [a] -> Maybe (Join These a, Join These [a]) unconsThese (Join (This (a:as))) = Just (Join (This a), Join (This as)) unconsThese (Join (That (b:bs))) = Just (Join (That b), Join (That bs))