module Darcs.Patch.Bracketed
( Bracketed(..), mapBracketed, unBracketed
, BracketedFL, mapBracketedFLFL, unBracketedFL
) where
import Prelude ()
import Darcs.Prelude
import Darcs.Patch.Format ( PatchListFormat )
import Darcs.Patch.Witnesses.Ordered ( FL(..), mapFL_FL, concatFL )
data Bracketed p wX wY where
Singleton :: p wX wY -> Bracketed p wX wY
Braced :: BracketedFL p wX wY -> Bracketed p wX wY
Parens :: BracketedFL p wX wY -> Bracketed p wX wY
type BracketedFL p wX wY = FL (Bracketed p) wX wY
unBracketed :: Bracketed p wX wY -> FL p wX wY
unBracketed (Singleton p) = p :>: NilFL
unBracketed (Braced ps) = unBracketedFL ps
unBracketed (Parens ps) = unBracketedFL ps
unBracketedFL :: BracketedFL p wX wY -> FL p wX wY
unBracketedFL = concatFL . mapFL_FL unBracketed
mapBracketed :: (forall wA wB . p wA wB -> q wA wB) -> Bracketed p wX wY -> Bracketed q wX wY
mapBracketed f (Singleton p) = Singleton (f p)
mapBracketed f (Braced ps) = Braced (mapBracketedFLFL f ps)
mapBracketed f (Parens ps) = Parens (mapBracketedFLFL f ps)
mapBracketedFLFL :: (forall wA wB . p wA wB -> q wA wB) -> BracketedFL p wX wY -> BracketedFL q wX wY
mapBracketedFLFL f = mapFL_FL (mapBracketed f)
instance PatchListFormat (Bracketed p)