mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
🔥 Both.unzip.
This commit is contained in:
parent
df4247d0c9
commit
d2beafdc84
@ -23,7 +23,7 @@ import Data.Bifunctor.These
|
||||
import Data.Coalescent
|
||||
import Data.Copointed
|
||||
import Data.Foldable
|
||||
import Data.Functor.Both as Both hiding (unzip)
|
||||
import Data.Functor.Both as Both
|
||||
import Data.Functor.Identity
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
|
@ -42,10 +42,6 @@ fst = Prelude.fst . runBoth
|
||||
snd :: Both a -> a
|
||||
snd = Prelude.snd . runBoth
|
||||
|
||||
unzip :: [Both a] -> Both [a]
|
||||
unzip = foldr pair (pure [])
|
||||
where pair head tail = (:) <$> head <*> tail
|
||||
|
||||
instance Monoid a => Monoid (Join (,) a) where
|
||||
mempty = pure mempty
|
||||
mappend a b = mappend <$> a <*> b
|
||||
|
@ -65,7 +65,7 @@ showHunk blobs hunk = maybeOffsetHeader ++
|
||||
-- | Given the before and after sources, render a change to a string.
|
||||
showChange :: Both (Source Char) -> Change (SplitDiff a Info) -> String
|
||||
showChange sources change = showLines (snd sources) ' ' (snd <$> context change) ++ deleted ++ inserted
|
||||
where (deleted, inserted) = runBoth $ pure showLines <*> sources <*> both '-' '+' <*> Both.unzip (contents change)
|
||||
where (deleted, inserted) = runBoth $ pure showLines <*> sources <*> both '-' '+' <*> Join (unzip (runJoin <$> contents change))
|
||||
|
||||
-- | Given a source, render a set of lines to a string with a prefix.
|
||||
showLines :: Source Char -> Char -> [Line (SplitDiff leaf Info)] -> String
|
||||
|
Loading…
Reference in New Issue
Block a user