mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +03:00
Add a function to construct Maybe These from two Maybes.
This commit is contained in:
parent
84d49ed4e2
commit
2da930ae53
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user