module Darcs.Patch.Show
( ShowPatchBasic(..)
, displayPatch
, ShowPatchFor(..)
, ShowPatch(..)
, ShowContextPatch(..)
, showPatchWithContext
, formatFileName
) where
import Darcs.Prelude
import Darcs.Patch.Apply ( ApplyState )
import Darcs.Patch.ApplyMonad ( ApplyMonad, ApplyMonadTrans, evalApplyMonad )
import Darcs.Patch.Object ( formatFileName )
import Darcs.Patch.Witnesses.Ordered ( FL, mapFL )
import Darcs.Util.English ( plural, Noun(Noun) )
import Darcs.Util.Printer ( Doc, vcat )
data ShowPatchFor = ForDisplay | ForStorage
displayPatch :: ShowPatchBasic p => p wX wY -> Doc
displayPatch :: forall (p :: * -> * -> *) wX wY. ShowPatchBasic p => p wX wY -> Doc
displayPatch p wX wY
p = 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
ForDisplay p wX wY
p
class ShowPatchBasic p where
showPatch :: ShowPatchFor -> p wX wY -> Doc
showPatchWithContext
:: (ApplyMonadTrans (ApplyState p) m, ShowContextPatch p)
=> ShowPatchFor
-> ApplyState p m
-> p wX wY
-> m Doc
showPatchWithContext :: forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(ApplyMonadTrans (ApplyState p) m, ShowContextPatch p) =>
ShowPatchFor -> ApplyState p m -> p wX wY -> m Doc
showPatchWithContext ShowPatchFor
f ApplyState p m
st p wX wY
p =
ApplyMonadOver (ApplyState p) m Doc -> ApplyState p m -> m Doc
forall (state :: (* -> *) -> *) (m :: * -> *) a.
ApplyMonadTrans state m =>
ApplyMonadOver state m a -> state m -> m a
evalApplyMonad (ShowPatchFor -> p wX wY -> ApplyMonadOver (ApplyState p) 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
f p wX wY
p) ApplyState p m
st
class ShowPatchBasic p => ShowContextPatch p where
showPatchWithContextAndApply
:: (ApplyMonad (ApplyState p) m)
=> ShowPatchFor -> p wX wY -> m Doc
class ShowPatchBasic p => ShowPatch p where
content :: p wX wY -> Doc
content = p wX wY -> Doc
forall a. Monoid a => a
mempty
description :: p wX wY -> Doc
description = p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatchBasic p => p wX wY -> Doc
displayPatch
summary :: p wX wY -> Doc
summaryFL :: FL p wX wY -> Doc
summaryFL = [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 wX wY. p wX wY -> 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 wX wY. p wX wY -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
summary
thing :: p wX wY -> String
thing p wX wY
_ = String
"patch"
things :: p wX wY -> String
things p wX wY
x = Noun -> ShowS
forall a. Countable a => a -> ShowS
plural (String -> Noun
Noun (String -> Noun) -> String -> Noun
forall a b. (a -> b) -> a -> b
$ p wX wY -> String
forall wX wY. p wX wY -> String
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> String
thing p wX wY
x) String
""