module Darcs.Patch.Bracketed.Instances () where
import Darcs.Patch.Bracketed ( Bracketed(..) )
import Darcs.Patch.Effect ( Effect(..) )
import Darcs.Patch.Prim ( FromPrim(..), PrimPatchBase(..) )
import Darcs.Patch.Show ( ShowPatchBasic(..) )
import Darcs.Patch.Witnesses.Ordered ( FL(NilFL), mapFL )
import Darcs.Util.Printer ( vcat, blueText, ($$) )
instance PrimPatchBase p => PrimPatchBase (Bracketed p) where
type PrimOf (Bracketed p) = PrimOf p
instance Effect p => Effect (Bracketed p) where
effect (Singleton p) = effect p
effect (Braced ps) = effect ps
effect (Parens ps) = effect ps
effectRL (Singleton p) = effectRL p
effectRL (Braced ps) = effectRL ps
effectRL (Parens ps) = effectRL ps
instance FromPrim p => FromPrim (Bracketed p) where
fromPrim p = Singleton (fromPrim p)
instance ShowPatchBasic p => ShowPatchBasic (Bracketed p) where
showPatch (Singleton p) = showPatch p
showPatch (Braced NilFL) = blueText "{" $$ blueText "}"
showPatch (Braced ps) = blueText "{" $$ vcat (mapFL showPatch ps) $$ blueText "}"
showPatch (Parens ps) = blueText "(" $$ vcat (mapFL showPatch ps) $$ blueText ")"