1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Rewrite getRange to not be in Either.

This commit is contained in:
Rob Rix 2016-03-03 08:30:55 -05:00
parent 4023f6b285
commit d2c26ad37d

View File

@ -94,11 +94,10 @@ splitAnnotatedByLines sources ranges categories syntax = case syntax of
wrap :: Copointed f => ([f (SplitDiff leaf Info)] -> Syntax leaf (SplitDiff leaf Info)) -> Set.Set Category -> [(Range, Maybe (f (SplitDiff leaf Info)))] -> SplitDiff leaf Info
wrap constructor categories children = Free . Annotated (Info (unionRanges $ Prelude.fst <$> children) categories) . constructor . catMaybes $ Prelude.snd <$> children
getRange :: Copointed f => Either Range (f (SplitDiff leaf Info)) -> Range
getRange (Right diff) = case copoint diff of
getRange :: Copointed f => f (SplitDiff leaf Info) -> Range
getRange diff = case copoint diff of
(Pure patch) -> let Info range _ :< _ = getSplitTerm patch in range
(Free (Annotated (Info range _) _)) -> range
getRange (Left range) = range
childRows :: (Copointed f, Functor f) => ([Row (Range, Maybe (f (SplitDiff leaf Info)))], Both Int) -> f (Diff leaf Info) -> ([Row (Range, Maybe (f (SplitDiff leaf Info)))], Both Int)
childRows (rows, previous) child = let (childRows, childRanges) = splitDiffByLines (copoint child) previous sources in