{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE UndecidableInstances #-}
module Darcs.Patch.Viewing
( showContextHunk
) where
import Darcs.Prelude
import qualified Data.ByteString as B ( null )
import Darcs.Patch.Apply ( Apply(..), ObjectIdOfPatch )
import Darcs.Patch.ApplyMonad ( ApplyMonad(..) )
import Darcs.Patch.FileHunk ( FileHunk(..), IsHunk(..), showContextFileHunk )
import Darcs.Patch.Format ( FileNameFormat(..), ListFormat(..), PatchListFormat(..) )
import Darcs.Patch.Object ( ObjectId(..), ObjectIdOf )
import Darcs.Patch.Show
( ShowContextPatch(..)
, ShowPatch(..)
, ShowPatchBasic(..)
, ShowPatchFor(..)
)
import Darcs.Patch.Witnesses.Ordered
( FL(..)
, RL(..)
, concatFL
, mapFL
, mapFL_FL
, reverseRL
)
import Darcs.Util.ByteString ( linesPS )
import Darcs.Util.Printer ( Doc, blueText, empty, vcat, ($$) )
showContextSeries
:: forall p m wX wY
. ( Apply p
, ShowContextPatch p
, IsHunk p
, ApplyMonad (ApplyState p) m
, ObjectId (ObjectIdOfPatch p)
)
=> ShowPatchFor
-> FileNameFormat
-> FL p wX wY
-> m Doc
showContextSeries :: forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ShowContextPatch p, IsHunk p,
ApplyMonad (ApplyState p) m, ObjectId (ObjectIdOfPatch p)) =>
ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
showContextSeries ShowPatchFor
use FileNameFormat
fmt = Maybe (FileHunk (ObjectIdOfPatch p) Any wX) -> FL p wX wY -> m Doc
forall wA wB wC.
Maybe (FileHunk (ObjectIdOfPatch p) wA wB) -> FL p wB wC -> m Doc
scs Maybe (FileHunk (ObjectIdOfPatch p) Any wX)
forall a. Maybe a
Nothing
where
scs :: Maybe (FileHunk (ObjectIdOfPatch p) wA wB) -> FL p wB wC -> m Doc
scs :: forall wA wB wC.
Maybe (FileHunk (ObjectIdOfPatch p) wA wB) -> FL p wB wC -> m Doc
scs Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
pold (p wB wY
p :>: FL p wY wC
ps) = do
case p wB wY -> Maybe (FileHunk (ObjectIdOfPatch p) wB wY)
forall wX wY. p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)
forall (p :: * -> * -> *) wX wY.
IsHunk p =>
p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)
isHunk p wB wY
p of
Maybe (FileHunk (ObjectIdOfPatch p) wB wY)
Nothing -> do
Doc
a <- ShowPatchFor -> p wB wY -> m Doc
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState p) m =>
ShowPatchFor -> p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(ShowContextPatch p, ApplyMonad (ApplyState p) m) =>
ShowPatchFor -> p wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
use p wB wY
p
Doc
b <- Maybe (FileHunk (ObjectIdOfPatch p) Any wY) -> FL p wY wC -> m Doc
forall wA wB wC.
Maybe (FileHunk (ObjectIdOfPatch p) wA wB) -> FL p wB wC -> m Doc
scs Maybe (FileHunk (ObjectIdOfPatch p) Any wY)
forall a. Maybe a
Nothing FL p wY wC
ps
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ Doc
a Doc -> Doc -> Doc
$$ Doc
b
Just FileHunk (ObjectIdOfPatch p) wB wY
fh -> case FL p wY wC
ps of
FL p wY wC
NilFL -> do
Doc
r <- FileNameFormat
-> Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
-> FileHunk (ObjectIdOfPatch p) wB wY
-> Maybe (FileHunk (ObjectIdOfPatch p) wY Any)
-> m Doc
forall (state :: (* -> *) -> *) (m :: * -> *) oid wA wB wC wD.
(ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) =>
FileNameFormat
-> Maybe (FileHunk oid wA wB)
-> FileHunk oid wB wC
-> Maybe (FileHunk oid wC wD)
-> m Doc
coolContextHunk FileNameFormat
fmt Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
pold FileHunk (ObjectIdOfPatch p) wB wY
fh Maybe (FileHunk (ObjectIdOfPatch p) wY Any)
forall a. Maybe a
Nothing
p wB wY -> m ()
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState p) m =>
p wX wY -> m ()
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ApplyMonad (ApplyState p) m) =>
p wX wY -> m ()
apply p wB wY
p
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Doc
r
(p wY wY
p2 :>: FL p wY wC
_) -> do
Doc
a <- FileNameFormat
-> Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
-> FileHunk (ObjectIdOfPatch p) wB wY
-> Maybe (FileHunk (ObjectIdOfPatch p) wY wY)
-> m Doc
forall (state :: (* -> *) -> *) (m :: * -> *) oid wA wB wC wD.
(ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) =>
FileNameFormat
-> Maybe (FileHunk oid wA wB)
-> FileHunk oid wB wC
-> Maybe (FileHunk oid wC wD)
-> m Doc
coolContextHunk FileNameFormat
fmt Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
pold FileHunk (ObjectIdOfPatch p) wB wY
fh (p wY wY -> Maybe (FileHunk (ObjectIdOfPatch p) wY wY)
forall wX wY. p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)
forall (p :: * -> * -> *) wX wY.
IsHunk p =>
p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)
isHunk p wY wY
p2)
p wB wY -> m ()
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState p) m =>
p wX wY -> m ()
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ApplyMonad (ApplyState p) m) =>
p wX wY -> m ()
apply p wB wY
p
Doc
b <- Maybe (FileHunk (ObjectIdOfPatch p) wB wY) -> FL p wY wC -> m Doc
forall wA wB wC.
Maybe (FileHunk (ObjectIdOfPatch p) wA wB) -> FL p wB wC -> m Doc
scs (FileHunk (ObjectIdOfPatch p) wB wY
-> Maybe (FileHunk (ObjectIdOfPatch p) wB wY)
forall a. a -> Maybe a
Just FileHunk (ObjectIdOfPatch p) wB wY
fh) FL p wY wC
ps
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ Doc
a Doc -> Doc -> Doc
$$ Doc
b
scs Maybe (FileHunk (ObjectIdOfPatch p) wA wB)
_ FL p wB wC
NilFL = Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Doc
empty
showContextHunk
:: (ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid)
=> FileNameFormat
-> FileHunk oid wX wY
-> m Doc
showContextHunk :: forall (state :: (* -> *) -> *) (m :: * -> *) oid wX wY.
(ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) =>
FileNameFormat -> FileHunk oid wX wY -> m Doc
showContextHunk FileNameFormat
fmt FileHunk oid wX wY
h = FileNameFormat
-> Maybe (FileHunk oid Any wX)
-> FileHunk oid wX wY
-> Maybe (FileHunk oid wY Any)
-> m Doc
forall (state :: (* -> *) -> *) (m :: * -> *) oid wA wB wC wD.
(ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) =>
FileNameFormat
-> Maybe (FileHunk oid wA wB)
-> FileHunk oid wB wC
-> Maybe (FileHunk oid wC wD)
-> m Doc
coolContextHunk FileNameFormat
fmt Maybe (FileHunk oid Any wX)
forall a. Maybe a
Nothing FileHunk oid wX wY
h Maybe (FileHunk oid wY Any)
forall a. Maybe a
Nothing
coolContextHunk :: (ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid)
=> FileNameFormat
-> Maybe (FileHunk oid wA wB) -> FileHunk oid wB wC
-> Maybe (FileHunk oid wC wD) -> m Doc
coolContextHunk :: forall (state :: (* -> *) -> *) (m :: * -> *) oid wA wB wC wD.
(ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) =>
FileNameFormat
-> Maybe (FileHunk oid wA wB)
-> FileHunk oid wB wC
-> Maybe (FileHunk oid wC wD)
-> m Doc
coolContextHunk FileNameFormat
fmt Maybe (FileHunk oid wA wB)
prev fh :: FileHunk oid wB wC
fh@(FileHunk oid
f Int
l [ByteString]
o [ByteString]
n) Maybe (FileHunk oid wC wD)
next = do
[ByteString]
ls <- ByteString -> [ByteString]
linesPS (ByteString -> [ByteString]) -> m ByteString -> m [ByteString]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ObjectIdOf state -> m ByteString
forall (state :: (* -> *) -> *) (m :: * -> *).
ApplyMonad state m =>
ObjectIdOf state -> m ByteString
readFilePS oid
ObjectIdOf state
f
let pre :: [ByteString]
pre = Int -> [ByteString] -> [ByteString]
forall a. Int -> [a] -> [a]
take Int
numpre ([ByteString] -> [ByteString]) -> [ByteString] -> [ByteString]
forall a b. (a -> b) -> a -> b
$ Int -> [ByteString] -> [ByteString]
forall a. Int -> [a] -> [a]
drop (Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
numpre Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [ByteString]
ls
cleanedls :: [ByteString]
cleanedls = case [ByteString] -> [ByteString]
forall a. [a] -> [a]
reverse [ByteString]
ls of
(ByteString
x : [ByteString]
xs)
| ByteString -> Bool
B.null ByteString
x -> [ByteString] -> [ByteString]
forall a. [a] -> [a]
reverse [ByteString]
xs
[ByteString]
_ -> [ByteString]
ls
post :: [ByteString]
post = Int -> [ByteString] -> [ByteString]
forall a. Int -> [a] -> [a]
take Int
numpost ([ByteString] -> [ByteString]) -> [ByteString] -> [ByteString]
forall a b. (a -> b) -> a -> b
$ Int -> [ByteString] -> [ByteString]
forall a. Int -> [a] -> [a]
drop (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
o Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [ByteString]
cleanedls
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ FileNameFormat
-> [ByteString] -> FileHunk oid wB wC -> [ByteString] -> Doc
forall oid wB wC.
ObjectId oid =>
FileNameFormat
-> [ByteString] -> FileHunk oid wB wC -> [ByteString] -> Doc
showContextFileHunk FileNameFormat
fmt [ByteString]
pre FileHunk oid wB wC
fh [ByteString]
post
where
numpre :: Int
numpre = case Maybe (FileHunk oid wA wB)
prev of
Just (FileHunk oid
f' Int
lprev [ByteString]
_ [ByteString]
nprev)
| oid
f' oid -> oid -> Bool
forall a. Eq a => a -> a -> Bool
== oid
f Bool -> Bool -> Bool
&& Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- (Int
lprev Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
nprev Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
3 Bool -> Bool -> Bool
&& Int
lprev Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
l
-> Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- (Int
lprev Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
nprev Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3)
Maybe (FileHunk oid wA wB)
_ -> if Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
4 then Int
3 else Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
numpost :: Int
numpost = case Maybe (FileHunk oid wC wD)
next of
Just (FileHunk oid
f' Int
lnext [ByteString]
_ [ByteString]
_)
| oid
f' oid -> oid -> Bool
forall a. Eq a => a -> a -> Bool
== oid
f Bool -> Bool -> Bool
&& Int
lnext Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
4 Bool -> Bool -> Bool
&& Int
lnext Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
l
-> Int
lnext Int -> Int -> Int
forall a. Num a => a -> a -> a
- (Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
n)
Maybe (FileHunk oid wC wD)
_ -> Int
3
instance (PatchListFormat p, ShowPatchBasic p) => ShowPatchBasic (FL p) where
showPatch :: forall wX wY. ShowPatchFor -> FL p wX wY -> Doc
showPatch ShowPatchFor
ForDisplay = [Doc] -> Doc
vcat ([Doc] -> Doc) -> (FL p wX wY -> [Doc]) -> FL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL (ShowPatchFor -> p wW wZ -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForDisplay)
showPatch ShowPatchFor
ForStorage = ListFormat p -> FL p wX wY -> Doc
forall wX wY. ListFormat p -> FL p wX wY -> Doc
showPatchInternal ListFormat p
forall (p :: * -> * -> *). PatchListFormat p => ListFormat p
patchListFormat
where
showPatchInternal :: ListFormat p -> FL p wX wY -> Doc
showPatchInternal :: forall wX wY. ListFormat p -> FL p wX wY -> Doc
showPatchInternal ListFormat p
ListFormatV1 (p wX wY
p :>: FL p wY wY
NilFL) = (ShowPatchFor -> p wX wY -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage) p wX wY
p
showPatchInternal ListFormat p
ListFormatV1 FL p wX wY
NilFL = String -> Doc
blueText String
"{" Doc -> Doc -> Doc
$$ String -> Doc
blueText String
"}"
showPatchInternal ListFormat p
ListFormatV1 FL p wX wY
ps = String -> Doc
blueText String
"{"
Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat ((forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL (ShowPatchFor -> p wW wZ -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage) FL p wX wY
ps)
Doc -> Doc -> Doc
$$ String -> Doc
blueText String
"}"
showPatchInternal ListFormat p
ListFormatV2 FL p wX wY
ps = [Doc] -> Doc
vcat ((forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL (ShowPatchFor -> p wW wZ -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage) FL p wX wY
ps)
showPatchInternal ListFormat p
ListFormatDefault FL p wX wY
ps = [Doc] -> Doc
vcat ((forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL (ShowPatchFor -> p wW wZ -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage) FL p wX wY
ps)
showPatchInternal ListFormat p
ListFormatV3 FL p wX wY
ps = [Doc] -> Doc
vcat ((forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL (ShowPatchFor -> p wW wZ -> Doc
forall wX wY. ShowPatchFor -> p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage) FL p wX wY
ps)
instance ( Apply p
, IsHunk p
, PatchListFormat p
, ShowContextPatch p
, ObjectId (ObjectIdOfPatch p)
) =>
ShowContextPatch (FL p) where
showPatchWithContextAndApply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState (FL p)) m =>
ShowPatchFor -> FL p wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
ForDisplay = ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ShowContextPatch p, IsHunk p,
ApplyMonad (ApplyState p) m, ObjectId (ObjectIdOfPatch p)) =>
ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
showContextSeries ShowPatchFor
ForDisplay FileNameFormat
FileNameFormatDisplay
showPatchWithContextAndApply ShowPatchFor
ForStorage = ListFormat p -> FL p wX wY -> m Doc
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState (FL p)) m =>
ListFormat p -> FL p wX wY -> m Doc
showContextPatchInternal ListFormat p
forall (p :: * -> * -> *). PatchListFormat p => ListFormat p
patchListFormat
where
showContextPatchInternal :: (ApplyMonad (ApplyState (FL p)) m)
=> ListFormat p -> FL p wX wY -> m Doc
showContextPatchInternal :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState (FL p)) m =>
ListFormat p -> FL p wX wY -> m Doc
showContextPatchInternal ListFormat p
ListFormatV1 (p wX wY
p :>: FL p wY wY
NilFL) =
ShowPatchFor -> p wX wY -> m Doc
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState p) m =>
ShowPatchFor -> p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(ShowContextPatch p, ApplyMonad (ApplyState p) m) =>
ShowPatchFor -> p wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
ForStorage p wX wY
p
showContextPatchInternal ListFormat p
ListFormatV1 FL p wX wY
NilFL =
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ String -> Doc
blueText String
"{" Doc -> Doc -> Doc
$$ String -> Doc
blueText String
"}"
showContextPatchInternal ListFormat p
ListFormatV1 FL p wX wY
ps = do
Doc
x <- ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ShowContextPatch p, IsHunk p,
ApplyMonad (ApplyState p) m, ObjectId (ObjectIdOfPatch p)) =>
ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
showContextSeries ShowPatchFor
ForStorage FileNameFormat
FileNameFormatV1 FL p wX wY
ps
Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ String -> Doc
blueText String
"{" Doc -> Doc -> Doc
$$ Doc
x Doc -> Doc -> Doc
$$ String -> Doc
blueText String
"}"
showContextPatchInternal ListFormat p
ListFormatV2 FL p wX wY
ps = ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ShowContextPatch p, IsHunk p,
ApplyMonad (ApplyState p) m, ObjectId (ObjectIdOfPatch p)) =>
ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
showContextSeries ShowPatchFor
ForStorage FileNameFormat
FileNameFormatV2 FL p wX wY
ps
showContextPatchInternal ListFormat p
ListFormatDefault FL p wX wY
ps = ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, ShowContextPatch p, IsHunk p,
ApplyMonad (ApplyState p) m, ObjectId (ObjectIdOfPatch p)) =>
ShowPatchFor -> FileNameFormat -> FL p wX wY -> m Doc
showContextSeries ShowPatchFor
ForStorage FileNameFormat
FileNameFormatV2 FL p wX wY
ps
showContextPatchInternal ListFormat p
ListFormatV3 FL p wX wY
ps = Doc -> m Doc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ ShowPatchFor -> FL p wX wY -> Doc
forall wX wY. ShowPatchFor -> FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
ForStorage FL p wX wY
ps
instance (PatchListFormat p, ShowPatch p) => ShowPatch (FL p) where
content :: forall wX wY. FL p wX wY -> Doc
content = [Doc] -> Doc
vcat ([Doc] -> Doc) -> (FL p wX wY -> [Doc]) -> FL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL p wW wZ -> Doc
forall wW wZ. p wW wZ -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
content
description :: forall wX wY. FL p wX wY -> Doc
description = [Doc] -> Doc
vcat ([Doc] -> Doc) -> (FL p wX wY -> [Doc]) -> FL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall wW wZ. p wW wZ -> Doc) -> FL p wX wY -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapFL p wW wZ -> Doc
forall wW wZ. p wW wZ -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
description
summary :: forall wX wY. FL p wX wY -> Doc
summary = FL p wX wY -> Doc
forall wX wY. FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => FL p wX wY -> Doc
summaryFL
summaryFL :: forall wX wY. FL (FL p) wX wY -> Doc
summaryFL = FL p wX wY -> Doc
forall wX wY. FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => FL p wX wY -> Doc
summaryFL (FL p wX wY -> Doc)
-> (FL (FL p) wX wY -> FL p wX wY) -> FL (FL p) wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FL (FL p) wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. FL (FL a) wX wZ -> FL a wX wZ
concatFL
thing :: forall wX wY. FL p wX wY -> String
thing FL p wX wY
x = p wX wY -> String
forall wX wY. p wX wY -> String
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> String
thing (FL p wX wY -> p wX wY
forall (a :: * -> * -> *) wX wY. FL a wX wY -> a wX wY
helperx FL p wX wY
x) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"s"
where
helperx :: FL a wX wY -> a wX wY
helperx :: forall (a :: * -> * -> *) wX wY. FL a wX wY -> a wX wY
helperx FL a wX wY
_ = a wX wY
forall a. HasCallStack => a
undefined
things :: forall wX wY. FL p wX wY -> String
things = FL p wX wY -> String
forall wX wY. FL p wX wY -> String
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> String
thing
instance (PatchListFormat p, ShowPatchBasic p) => ShowPatchBasic (RL p) where
showPatch :: forall wX wY. ShowPatchFor -> RL p wX wY -> Doc
showPatch ShowPatchFor
f = ShowPatchFor -> FL p wX wY -> Doc
forall wX wY. ShowPatchFor -> FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY.
ShowPatchBasic p =>
ShowPatchFor -> p wX wY -> Doc
showPatch ShowPatchFor
f (FL p wX wY -> Doc)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
instance (ShowContextPatch p, Apply p, IsHunk p, PatchListFormat p, ObjectId (ObjectIdOfPatch p))
=> ShowContextPatch (RL p) where
showPatchWithContextAndApply :: forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState (RL p)) m =>
ShowPatchFor -> RL p wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
use = ShowPatchFor -> FL p wX wY -> m Doc
forall (m :: * -> *) wX wY.
ApplyMonad (ApplyState (FL p)) m =>
ShowPatchFor -> FL p wX wY -> m Doc
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(ShowContextPatch p, ApplyMonad (ApplyState p) m) =>
ShowPatchFor -> p wX wY -> m Doc
showPatchWithContextAndApply ShowPatchFor
use (FL p wX wY -> m Doc)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> m Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
instance (PatchListFormat p, ShowPatch p) => ShowPatch (RL p) where
content :: forall wX wY. RL p wX wY -> Doc
content = FL p wX wY -> Doc
forall wX wY. FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
content (FL p wX wY -> Doc)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
description :: forall wX wY. RL p wX wY -> Doc
description = FL p wX wY -> Doc
forall wX wY. FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
description (FL p wX wY -> Doc)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
summary :: forall wX wY. RL p wX wY -> Doc
summary = FL p wX wY -> Doc
forall wX wY. FL p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
summary (FL p wX wY -> Doc)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
summaryFL :: forall wX wY. FL (RL p) wX wY -> Doc
summaryFL = FL (FL p) wX wY -> Doc
forall wX wY. FL (FL p) wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => FL p wX wY -> Doc
summaryFL (FL (FL p) wX wY -> Doc)
-> (FL (RL p) wX wY -> FL (FL p) wX wY) -> FL (RL p) wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall wW wY. RL p wW wY -> FL p wW wY)
-> FL (RL p) wX wY -> FL (FL p) wX wY
forall (a :: * -> * -> *) (b :: * -> * -> *) wX wZ.
(forall wW wY. a wW wY -> b wW wY) -> FL a wX wZ -> FL b wX wZ
mapFL_FL RL p wW wY -> FL p wW wY
forall wW wY. RL p wW wY -> FL p wW wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
thing :: forall wX wY. RL p wX wY -> String
thing = FL p wX wY -> String
forall wX wY. FL p wX wY -> String
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> String
thing (FL p wX wY -> String)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL
things :: forall wX wY. RL p wX wY -> String
things = FL p wX wY -> String
forall wX wY. FL p wX wY -> String
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> String
things (FL p wX wY -> String)
-> (RL p wX wY -> FL p wX wY) -> RL p wX wY -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RL p wX wY -> FL p wX wY
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL