mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Add a maybeUnionRanges function.
This commit is contained in:
parent
7cb85f6571
commit
34e798cb09
@ -72,6 +72,9 @@ unionRanges = unionRangesFrom (Range 0 0)
|
||||
unionRangesFrom :: (Functor f, Foldable f) => Range -> f Range -> Range
|
||||
unionRangesFrom range ranges = option range id . foldl mappend mempty $ Option . Just <$> ranges
|
||||
|
||||
maybeUnionRanges :: (Functor f, Foldable f) => f Range -> Maybe Range
|
||||
maybeUnionRanges ranges = getOption $ foldl mappend mempty $ Option . Just <$> ranges
|
||||
|
||||
instance Monoid (Option Range) where
|
||||
mempty = Option Nothing
|
||||
mappend (Option (Just a)) (Option (Just b)) = Option (Just (unionRange a b))
|
||||
|
Loading…
Reference in New Issue
Block a user