-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | a distributed, interactive, smart revision control system
--   
--   Darcs is a free, open source revision control system. It is:
--   
--   <ul>
--   <li>Distributed: Darcs was one of the first revision control systems
--   in which every user has access to the full command set, removing
--   boundaries between server and client or committer and
--   non-committers.</li>
--   <li>Interactive: Darcs is easy to learn and efficient to use because
--   it asks you questions in response to simple commands, giving you
--   choices in your work flow. You can choose to record one change in a
--   file, while ignoring another. As you update from upstream, you can
--   review each patch, picking and choosing which patches are
--   appropriate.</li>
--   <li>Smart: Darcs is different from most revision control systems in
--   that it is based on the notion of change (or patch), rather than
--   version. An underlying algebra of patches determines whether changes
--   can be re-ordered. The laws of this algebra guarantee that the result
--   of merging depends only on the final set of patches applied in a
--   repository and not on their order.</li>
--   <li>Simple: As a consequence, Darcs offers a conceptually simpler view
--   of the state of a repository: it is given by the set of patches it
--   contains. Pulling and pushing patches merely transfers them from one
--   set to another. So called "cherry-picking" is the default mode of
--   operation, and it fully preserves the identity of patches.</li>
--   </ul>
@package darcs
@version 2.18.2

module Darcs.Patch.Witnesses.Unsafe
unsafeCoerceP :: a wX wY -> a wB wC
unsafeCoercePStart :: a wX1 wY -> a wX2 wY
unsafeCoercePEnd :: a wX wY1 -> a wX wY2
unsafeCoerceP1 :: a wX -> a wY

module Darcs.Prelude
data () => Bool
False :: Bool
True :: Bool
data () => Char
data () => Double
data () => Float
data () => Int
data () => Word
data () => Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering
data () => Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a
class a ~# b => (a :: k) ~ (b :: k)
data () => Integer
data () => IO a
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a
class () => Eq a
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool
class () => Functor (f :: Type -> Type)
fmap :: Functor f => (a -> b) -> f a -> f b
(<$) :: Functor f => a -> f b -> f a
class Applicative m => Monad (m :: Type -> Type)
(>>=) :: Monad m => m a -> (a -> m b) -> m b
(>>) :: Monad m => m a -> m b -> m b
return :: Monad m => a -> m a
type String = [Char]
class () => Foldable (t :: Type -> Type)
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
null :: Foldable t => t a -> Bool
length :: Foldable t => t a -> Int
elem :: (Foldable t, Eq a) => a -> t a -> Bool
maximum :: (Foldable t, Ord a) => t a -> a
minimum :: (Foldable t, Ord a) => t a -> a
sum :: (Foldable t, Num a) => t a -> a
product :: (Foldable t, Num a) => t a -> a
class () => Read a
readsPrec :: Read a => Int -> ReadS a
readList :: Read a => ReadS [a]
class () => Show a
showsPrec :: Show a => Int -> a -> ShowS
show :: Show a => a -> String
showList :: Show a => [a] -> ShowS
type FilePath = String
class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
data () => Either a b
Left :: a -> Either a b
Right :: b -> Either a b
class (Real a, Enum a) => Integral a
quot :: Integral a => a -> a -> a
rem :: Integral a => a -> a -> a
div :: Integral a => a -> a -> a
mod :: Integral a => a -> a -> a
quotRem :: Integral a => a -> a -> (a, a)
divMod :: Integral a => a -> a -> (a, a)
toInteger :: Integral a => a -> Integer
class Monad m => MonadFail (m :: Type -> Type)
fail :: MonadFail m => String -> m a
class () => Bounded a
minBound :: Bounded a => a
maxBound :: Bounded a => a
class () => Enum a
succ :: Enum a => a -> a
toEnum :: Enum a => Int -> a
fromEnum :: Enum a => a -> Int
enumFrom :: Enum a => a -> [a]
enumFromThen :: Enum a => a -> a -> [a]
enumFromTo :: Enum a => a -> a -> [a]
enumFromThenTo :: Enum a => a -> a -> a -> [a]
class Fractional a => Floating a
exp :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a
class (RealFrac a, Floating a) => RealFloat a
floatRadix :: RealFloat a => a -> Integer
floatDigits :: RealFloat a => a -> Int
floatRange :: RealFloat a => a -> (Int, Int)
decodeFloat :: RealFloat a => a -> (Integer, Int)
encodeFloat :: RealFloat a => Integer -> Int -> a
exponent :: RealFloat a => a -> Int
significand :: RealFloat a => a -> a
scaleFloat :: RealFloat a => Int -> a -> a
isNaN :: RealFloat a => a -> Bool
isInfinite :: RealFloat a => a -> Bool
isDenormalized :: RealFloat a => a -> Bool
isNegativeZero :: RealFloat a => a -> Bool
isIEEE :: RealFloat a => a -> Bool
atan2 :: RealFloat a => a -> a -> a
type IOError = IOException
class () => Num a
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a
negate :: Num a => a -> a
abs :: Num a => a -> a
signum :: Num a => a -> a
fromInteger :: Num a => Integer -> a
class Num a => Fractional a
(/) :: Fractional a => a -> a -> a
recip :: Fractional a => a -> a
fromRational :: Fractional a => Rational -> a
type Rational = Ratio Integer
class (Num a, Ord a) => Real a
toRational :: Real a => a -> Rational
class (Real a, Fractional a) => RealFrac a
properFraction :: (RealFrac a, Integral b) => a -> (b, a)
truncate :: (RealFrac a, Integral b) => a -> b
round :: (RealFrac a, Integral b) => a -> b
ceiling :: (RealFrac a, Integral b) => a -> b
floor :: (RealFrac a, Integral b) => a -> b
type ShowS = String -> String
type ReadS a = String -> [(a, String)]
(.) :: (b -> c) -> (a -> b) -> a -> c
map :: (a -> b) -> [a] -> [b]
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
otherwise :: Bool
(++) :: [a] -> [a] -> [a]
concat :: Foldable t => t [a] -> [a]
drop :: Int -> [a] -> [a]
splitAt :: Int -> [a] -> ([a], [a])
break :: (a -> Bool) -> [a] -> ([a], [a])
dropWhile :: (a -> Bool) -> [a] -> [a]
take :: Int -> [a] -> [a]
tail :: HasCallStack => [a] -> [a]
head :: HasCallStack => [a] -> a
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
all :: Foldable t => (a -> Bool) -> t a -> Bool
unlines :: [String] -> String
last :: HasCallStack => [a] -> a
init :: HasCallStack => [a] -> [a]
readFile :: FilePath -> IO String
lex :: ReadS String
filter :: (a -> Bool) -> [a] -> [a]
writeFile :: FilePath -> String -> IO ()
any :: Foldable t => (a -> Bool) -> t a -> Bool
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
(=<<) :: Monad m => (a -> m b) -> m a -> m b
asTypeOf :: a -> a -> a
const :: a -> b -> a
flip :: (a -> b -> c) -> b -> a -> c
id :: a -> a
until :: (a -> Bool) -> (a -> a) -> a -> a
(&&) :: Bool -> Bool -> Bool
not :: Bool -> Bool
(||) :: Bool -> Bool -> Bool
either :: (a -> c) -> (b -> c) -> Either a b -> c
and :: Foldable t => t Bool -> Bool
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
or :: Foldable t => t Bool -> Bool
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
maybe :: b -> (a -> b) -> Maybe a -> b
lines :: String -> [String]
unwords :: [String] -> String
words :: String -> [String]
curry :: ((a, b) -> c) -> a -> b -> c
fst :: (a, b) -> a
snd :: (a, b) -> b
uncurry :: (a -> b -> c) -> (a, b) -> c
ioError :: IOError -> IO a
userError :: String -> IOError
(!!) :: HasCallStack => [a] -> Int -> a
cycle :: HasCallStack => [a] -> [a]
iterate :: (a -> a) -> a -> [a]
repeat :: a -> [a]
replicate :: Int -> a -> [a]
reverse :: [a] -> [a]
scanl :: (b -> a -> b) -> b -> [a] -> [b]
scanl1 :: (a -> a -> a) -> [a] -> [a]
scanr :: (a -> b -> b) -> b -> [a] -> [b]
scanr1 :: (a -> a -> a) -> [a] -> [a]
span :: (a -> Bool) -> [a] -> ([a], [a])
takeWhile :: (a -> Bool) -> [a] -> [a]
unzip :: [(a, b)] -> ([a], [b])
unzip3 :: [(a, b, c)] -> ([a], [b], [c])
zip :: [a] -> [b] -> [(a, b)]
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
subtract :: Num a => a -> a -> a
readParen :: Bool -> ReadS a -> ReadS a
(^^) :: (Fractional a, Integral b) => a -> b -> a
even :: Integral a => a -> Bool
fromIntegral :: (Integral a, Num b) => a -> b
gcd :: Integral a => a -> a -> a
lcm :: Integral a => a -> a -> a
odd :: Integral a => a -> Bool
realToFrac :: (Real a, Fractional b) => a -> b
showChar :: Char -> ShowS
showParen :: Bool -> ShowS -> ShowS
showString :: String -> ShowS
shows :: Show a => a -> ShowS
appendFile :: FilePath -> String -> IO ()
getChar :: IO Char
getContents :: IO String
getLine :: IO String
interact :: (String -> String) -> IO ()
print :: Show a => a -> IO ()
putChar :: Char -> IO ()
putStr :: String -> IO ()
putStrLn :: String -> IO ()
readIO :: Read a => String -> IO a
readLn :: Read a => IO a
read :: Read a => String -> a
reads :: Read a => ReadS a
seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
class Functor f => Applicative (f :: Type -> Type)
pure :: Applicative f => a -> f a
(<*>) :: Applicative f => f (a -> b) -> f a -> f b
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
(*>) :: Applicative f => f a -> f b -> f b
(<*) :: Applicative f => f a -> f b -> f a
(<$>) :: Functor f => (a -> b) -> f a -> f b
class Semigroup a => Monoid a
mempty :: Monoid a => a
mappend :: Monoid a => a -> a -> a
mconcat :: Monoid a => [a] -> a
class () => Semigroup a
(<>) :: Semigroup a => a -> a -> a
sconcat :: Semigroup a => NonEmpty a -> a
stimes :: (Semigroup a, Integral b) => b -> a -> a
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

module Darcs.Patch.Witnesses.Eq

-- | <a>EqCheck</a> is used to pass around evidence (or lack thereof) of
--   two witness types being equal.
data EqCheck wA wB
[IsEq] :: EqCheck wA wA
[NotEq] :: EqCheck wA wB

-- | An witness aware equality class. A minimal definition defines any one
--   of <a>unsafeCompare</a>, <a>=\/=</a> and <a>=/\=</a>.
class Eq2 p

-- | It is unsafe to define a class instance via this method, because if it
--   returns True then the default implementations of <a>=\/=</a> and
--   <a>=/\=</a> will coerce the equality of two witnesses.
--   
--   Calling this method is safe, although <a>=\/=</a> or <a>=/\=</a> would
--   be better choices as it is not usually meaningul to compare two
--   patches that don't share either a starting or an ending context
unsafeCompare :: Eq2 p => p wA wB -> p wC wD -> Bool

-- | Compare two things with the same starting witness. If the things
--   compare equal, evidence of the ending witnesses being equal will be
--   returned.
(=\/=) :: Eq2 p => p wA wB -> p wA wC -> EqCheck wB wC

-- | Compare two things with the same ending witness. If the things compare
--   equal, evidence of the starting witnesses being equal will be
--   returned.
(=/\=) :: Eq2 p => p wA wC -> p wB wC -> EqCheck wA wB
infix 4 =\/=
infix 4 =/\=
isIsEq :: EqCheck wA wB -> Bool
instance GHC.Classes.Eq (Darcs.Patch.Witnesses.Eq.EqCheck wA wB)
instance GHC.Show.Show (Darcs.Patch.Witnesses.Eq.EqCheck wA wB)

module Darcs.Patch.RegChars

-- | <a>regChars</a> returns a filter function that tells if a char is a
--   member of the regChar expression or not. The regChar expression is
--   basically a set of chars, but it can contain ranges with use of the
--   <a>-</a> (dash), and it can also be specified as a complement set by
--   prefixing with <tt>^</tt> (caret). The dash and caret, as well as the
--   backslash, can all be escaped with a backslash to suppress their
--   special meaning.
--   
--   NOTE: The <a>.</a> (dot) is allowed to be escaped. It has no special
--   meaning if it is not escaped, but the default <tt>filename_toks</tt>
--   in Darcs.Commands.Replace uses an escaped dot (WHY?).
regChars :: String -> Char -> Bool

module Darcs.Patch.TokenReplace

-- | <tt>tryTokReplace tokChars old new input</tt> tries to find the token
--   <tt>old</tt> and replace it with the token <tt>new</tt> everywhere in
--   the <tt>input</tt>, returning <a>Just</a> the modified <tt>input</tt>,
--   unless the token <tt>new</tt> is already in the <tt>input</tt> in
--   which case <a>Nothing</a> is returned. A token is a sequence of bytes
--   that match the class defined by <tt>tokChars</tt>. This function is
--   supposed to work efficiently with large <tt>input</tt>s i.e. whole
--   files.
tryTokReplace :: String -> ByteString -> ByteString -> ByteString -> Maybe ByteString

-- | <tt>forceTokReplace tokChars old new input</tt> replaces all
--   occurrences of the <tt>old</tt> token with the <tt>new</tt> one,
--   throughout the <tt>input</tt>.
forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString

-- | Check if a token replace operation touches the given line.
annotateReplace :: String -> ByteString -> ByteString -> ByteString -> Bool

-- | Break a <tt>Bytestring</tt> into tokens, according to
--   <a>defaultToks</a>, discarding non-tokens.
breakToTokens :: ByteString -> [ByteString]
defaultToks :: String

module Darcs.Patch.Format

-- | Showing and reading lists of patches. This class allows us to control
--   how lists of patches are formatted on disk. For legacy reasons V1
--   patches have their own special treatment (see <a>ListFormat</a>).
--   Other patch types use the default format which just puts them in a
--   sequence without separators or any prelude/epilogue.
--   
--   This means that 'FL (FL p)' etc would be ambiguous, so there are no
--   instances for 'FL p' or other list types.
class PatchListFormat p
patchListFormat :: PatchListFormat p => ListFormat p

-- | This type is used to tweak the way that lists of <tt>p</tt> are shown
--   for a given <tt>Patch</tt> type <tt>p</tt>. It is needed to maintain
--   backwards compatibility for V1 and V2 patches.
data ListFormat (p :: (* -> * -> *))

-- | Show and read lists without braces.
ListFormatDefault :: ListFormat (p :: * -> * -> *)

-- | Show lists with a single layer of braces around the outside, except
--   for singletons which have no braces. Read with arbitrary nested braces
--   and parens and flatten them out.
ListFormatV1 :: ListFormat (p :: * -> * -> *)

-- | Show lists without braces. Read with arbitrary nested parens and
--   flatten them out.
ListFormatV2 :: ListFormat (p :: * -> * -> *)

-- | Temporary hack to disable use of showContextSeries for darcs-3
--   patches, until I find out how to fix this.
ListFormatV3 :: ListFormat (p :: * -> * -> *)
data FileNameFormat

-- | on-disk format for V1 patches
FileNameFormatV1 :: FileNameFormat

-- | on-disk format for V2 patches
FileNameFormatV2 :: FileNameFormat

-- | display format
FileNameFormatDisplay :: FileNameFormat
instance GHC.Show.Show Darcs.Patch.Format.FileNameFormat
instance GHC.Classes.Eq Darcs.Patch.Format.FileNameFormat

module Darcs.Test.TestOnly

-- | This nullary type class flags code that should only be used for the
--   tests. No instance of it should be defined in either the darcs library
--   or the main darcs executable.
class TestOnly

module Darcs.UI.Options.Iso

-- | Lightweight type ismomorphisms (a.k.a. invertible functions). If
--   
--   <pre>
--   Iso fw bw :: Iso a b
--   </pre>
--   
--   then <tt>fw</tt> and <tt>bw</tt> are supposed to satisfy
--   
--   <pre>
--   fw . bw = id = bw . fw
--   </pre>
data Iso a b
Iso :: (a -> b) -> (b -> a) -> Iso a b

-- | Lift an isomorphism between <tt>a</tt> and <tt>b</tt> to one between
--   <tt>f a</tt> and <tt>f b</tt>. Like <a>Functor</a>, except we can only
--   map invertible functions (i.e. an Isomorphisms).
class IsoFunctor f
imap :: IsoFunctor f => Iso a b -> f a -> f b

-- | Apply an iso under a functor.
under :: Functor f => Iso a b -> Iso (f a) (f b)

-- | Apply an iso under cps (which is a cofunctor).
cps :: Iso a b -> Iso (a -> c) (b -> c)


-- | Option specifications using continuations with a changing answer type.
--   
--   Based on
--   
--   <pre>
--   <a>www.is.ocha.ac.jp/~asai/papers/tr08-2.pdf</a>
--   </pre>
--   
--   with additional inspiration provided by
--   
--   <pre>
--   <a>http://okmij.org/ftp/typed-formatting/FPrintScan.html#DSL-FIn</a>
--   </pre>
--   
--   which shows how the same format specifiers can be used for both
--   <tt>sprintf</tt> and <tt>sscanf</tt>.
--   
--   The <a>OptSpec</a> type corresponds to the format specifiers for the
--   sprintf and sscanf functions, which I called <a>ounparse</a> and
--   <a>oparse</a> here; they no longer work on <a>String</a>s but instead
--   on any list (the intention is, of course, that this is a list of
--   flags).
--   
--   As explained in the original paper by Kenichi Asai, we cannot use
--   <a>Cont</a>, even with the recent additions of the <tt>shift</tt> and
--   <tt>reset</tt> combinators, since <a>Cont</a> requires that the answer
--   type remains the same over the whole computation, while the trick used
--   here requires that the answer type can change.
--   
--   Besides parsing and unparsing, the <a>OptSpec</a> type contains two
--   more members: <a>odesc</a> is the list of <tt>OptDescr</tt> that
--   <a>getOpt</a> needs as input for parsing the command line and for
--   generating the usage help, while <a>ocheck</a> takes a list of flags
--   and returns a list of error messages, which can be used to check for
--   conflicting options.
module Darcs.UI.Options.Core
data OptMsg
OptWarning :: String -> OptMsg
OptError :: String -> OptMsg

-- | A type for option specifications.
--   
--   It consists of four components: a parser, an unparser, a checker, and
--   a list of descriptions.
--   
--   The parser converts a flag list to some result value. This can never
--   fail: we demand that primitive parsers are written so that there is
--   always a default value (use <a>Maybe</a> with default <a>Nothing</a>
--   as a last resort).
--   
--   The unparser does the opposite of the parser: a value is converted
--   back to a flag list.
--   
--   The checker returns a list of error messages (which should be empty if
--   there are no problems found). This can be used to e.g. check whether
--   there are conflicting flags in the list.
--   
--   Separating the checker and parser is unusual. The reason for this is
--   that we want to support flags coming from multiple sources, such as
--   the command line or a defaults file. Prioritising these sources is
--   done by concatenating the flag lists in the order of precedence, so
--   that earlier flags win over later ones. That means that when parsing
--   the (final) flag list, conflicting flags are resolved by picking the
--   first flag that matches an option. The checker, on the other hand, can
--   be called for each source separately.
--   
--   The last component is a list of descriptors for each single
--   switch/flag that the option is made of.
--   
--   The <a>OptSpec</a> type is heavily parameterized. The type arguments
--   are:
--   
--   <ul>
--   <li><i><tt>f</tt></i> The flag type, such as <a>DarcsFlag</a>.</li>
--   <li><i><tt>d</tt></i> A type that describes an single flag, such as
--   <a>OptDescr</a> or <a>DarcsOptDescr</a>. It should be a
--   <a>Functor</a>.</li>
--   </ul>
--   
--   Abstracting over these types is not technically necessary: for the
--   intended application in Darcs, we could as well fix them as
--   <tt>d=<a>DarcsOptDescr</a></tt>, and <tt>f=<a>DarcsFlag</a></tt>,
--   saving two type parameters. However, doing that here would only
--   obscure what's going on, making the code harder to understand, not
--   easier. Besides, the resulting more general type signatures give us
--   additional guarantees, known as "free theorems" (free as in beer, not
--   in speak).
--   
--   In contrast, the type parameters
--   
--   <ul>
--   <li><i><tt>a</tt>, <tt>b</tt></i> are necessary to make chaining of
--   options a la typed printf/scanf possible. In a nutshell, <tt>a</tt> is
--   the result type of a function that consumes the result of parsing or
--   unparsing an option, while <tt>b</tt> is the complete type of such a
--   function.</li>
--   </ul>
--   
--   The <a>ounparse</a> and <a>oparse</a> members use continuation passing
--   style, which is the reason for their apparently "inverted" type
--   signature. To understand them, it helps to look at the type of
--   "primitive" (not yet combined) options (see <a>PrimOptSpec</a> below).
--   For a primitive option, <tt>b</tt> gets instantiated to <tt>v -&gt;
--   a</tt>, where <tt>v</tt> is the type of values associated with the
--   option. The whole option spec then has type
--   
--   <pre>
--   o :: 'OptSpec' d f a (v -&gt; a)
--   </pre>
--   
--   so that the <a>oparse</a> and <a>ounparse</a> members are instantiated
--   to
--   
--   <pre>
--   ounparse :: forall a. ([f] -&gt; a) -&gt; (x -&gt; a)
--   oparse   :: forall a. (x -&gt; a) -&gt; ([f] -&gt; a)
--   </pre>
--   
--   which can be easily seen to be equivalent to
--   
--   <pre>
--   ounparse :: x -&gt; [f]
--   oparse   :: [f] -&gt; x
--   </pre>
--   
--   Chaining such options results in a combined option of type
--   
--   <pre>
--   o1 ^ o2 ^ ... :: OptSpec d f a (v1 -&gt; v2 -&gt; ... -&gt; a)
--   </pre>
--   
--   that is, <tt>b</tt> gets instantiated to
--   
--   <pre>
--   v1 -&gt; v2 -&gt; ... -&gt; a
--   </pre>
--   
--   To use such an option (primitive or combined), you pass in the
--   consumer. A typical consumer of option values is a command
--   implementation. Given
--   
--   <pre>
--   cmd :: v1 -&gt; v2 -&gt; ... -&gt; [String] -&gt; IO ()
--   </pre>
--   
--   we can parse the flags and pass the results to <tt>cmd</tt>:
--   
--   <pre>
--   oparse (o1 ^ o2 ^ ...) cmd flags
--   </pre>
data OptSpec d f a b
OptSpec :: (([f] -> a) -> b) -> (b -> [f] -> a) -> ([f] -> [OptMsg]) -> [d f] -> OptSpec d f a b

-- | Convert option value (back) to flag list, in CPS.
[ounparse] :: OptSpec d f a b -> ([f] -> a) -> b

-- | Convert flag list to option value, in CPS. Note: as a pure function,
--   it is not supposed to fail.
[oparse] :: OptSpec d f a b -> b -> [f] -> a

-- | Check for erros in a flag list, returns error messages.
[ocheck] :: OptSpec d f a b -> [f] -> [OptMsg]

-- | Descriptions, one for each flag that makes up the option.
[odesc] :: OptSpec d f a b -> [d f]

-- | Identity <a>OptSpec</a>, unit for <a>^</a>
oid :: OptSpec d f a a

-- | <a>OptSpec</a> composition, associative
(^) :: OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c

-- | Normalise a flag list by parsing and then unparsing it. This adds all
--   implicit (default) flags to the list.
--   
--   <pre>
--   onormalise opts = (oparse opts . ounparse opts) id
--   </pre>
onormalise :: OptSpec d f [f] b -> [f] -> [f]

-- | The list of default flags for an <a>OptSpec</a>.
--   
--   <pre>
--   defaultFlags opts = onormalise opts []
--   </pre>
defaultFlags :: OptSpec d f [f] b -> [f]

-- | Lift an isomorphism between <tt>b</tt> and <tt>c</tt> to one between
--   <tt><a>OptSpec</a> d f a b</tt> and <tt><a>OptSpec</a> d f a c</tt>.
--   
--   The forward component of the <a>Iso</a> is needed for <a>ounparse</a>,
--   the backward component for <a>oparse</a>. For the other two components
--   this is the identity.
oimap :: Iso b c -> OptSpec d f a b -> OptSpec d f a c

-- | Type of primitive (not yet combined) options. The type parameter
--   <tt>b</tt> gets instantiated to <tt>(v -&gt; a)</tt>, adding one
--   argument of type <tt>v</tt> to the answer type of the continuation.
type PrimOptSpec d f a v = OptSpec d f a (v -> a)

-- | Combine two list valued options of the same type "in parellel". This
--   is done by concatenating the resulting option values (<a>oparse</a>),
--   flags (<a>ounparse</a>), errors (<a>ocheck</a>), and descriptors
--   (<a>odesc</a>), respectively, of the input options.
oappend :: PrimOptSpec d f a [v] -> PrimOptSpec d f a [v] -> PrimOptSpec d f a [v]

-- | Unit for <a>oappend</a>.
oempty :: PrimOptSpec d f a [v]

-- | Parse a list of flags against a primitive option spec, returning the
--   value associated with the option. As noted above, this cannot fail
--   because options always have a default value.
--   
--   <pre>
--   parseFlags o fs = oparse o id fs
--   </pre>
parseFlags :: (forall a. PrimOptSpec d f a v) -> [f] -> v

-- | Unparse a primitive option spec and append it to a list of flags.
unparseOpt :: (forall a. PrimOptSpec d f a v) -> v -> [f] -> [f]

-- | Operator version of <a>parseFlags</a>
--   
--   <pre>
--   opt ? flags = parseFlags opt flags
--   </pre>
(?) :: (forall a. PrimOptSpec d f a v) -> [f] -> v
infix 5 ?
instance GHC.Base.Semigroup (Darcs.UI.Options.Core.PrimOptSpec d f a [v])
instance GHC.Base.Monoid (Darcs.UI.Options.Core.PrimOptSpec d f a [v])
instance Darcs.UI.Options.Iso.IsoFunctor (Darcs.UI.Options.Core.OptSpec d f a)


-- | This was originally Tomasz Zielonka's AtExit module, slightly
--   generalised to include global variables. Here, we attempt to cover
--   broad, global features, such as exit handlers. These features slightly
--   break the Haskellian purity of darcs, in favour of programming
--   convenience.
module Darcs.Util.AtExit

-- | Registers an IO action to run just before darcs exits. Useful for
--   removing temporary files and directories, for example. Referenced in
--   Issue1914.
atexit :: IO () -> IO ()
withAtexit :: IO a -> IO a


-- | |A parser for commandlines, returns an arg list and expands format
--   strings given in a translation table. Additionally the commandline can
--   end with "%&lt;" specifying that the command expects input on stdin.
--   
--   See Darcs.Test.Misc.CommandLine for tests.
module Darcs.Util.CommandLine

-- | parse a commandline returning a list of strings (intended to be used
--   as argv) and a bool value which specifies if the command expects input
--   on stdin format specifiers with a mapping in ftable are accepted and
--   replaced by the given strings. E.g. if the ftable is
--   [(<tt>s</tt>,"Some subject")], then "%s" is replaced by "Some subject"
parseCmd :: FTable -> String -> Either ParseError ([String], Bool)

-- | for every mapping (c,s), add a mapping with uppercase c and the
--   urlencoded string s
addUrlencoded :: FTable -> FTable

module Darcs.Util.DateTime
getCurrentTime :: IO UTCTime
toSeconds :: UTCTime -> Integer
formatDateTime :: String -> UTCTime -> String
fromClockTime :: ClockTime -> UTCTime
parseDateTime :: String -> String -> Maybe UTCTime
startOfTime :: UTCTime

module Darcs.Util.Encoding

-- | Encode a <a>String</a> into a <a>ByteString</a> according to the
--   user's locale with the ghc specific //ROUNDTRIP feature added. This
--   means the argument is allowed to contain non-Unicode <a>Char</a>s as
--   produced by <a>decode</a>.
encode :: String -> IO ByteString

-- | Decode a <a>ByteString</a> into a <a>String</a> according to the
--   user's locale with the ghc specific //ROUNDTRIP feature added. This
--   means the result may contain <a>Char</a>s that are not valid Unicode
--   in case decoding with the user's locale fails.
decode :: ByteString -> IO String
encodeUtf8 :: String -> IO ByteString
decodeUtf8 :: ByteString -> IO String


-- | This was originally Tomasz Zielonka's AtExit module, slightly
--   generalised to include global variables. Here, we attempt to cover
--   broad, global features, such as exit handlers. These features slightly
--   break the Haskellian purity of darcs, in favour of programming
--   convenience.
module Darcs.Util.Global
setTimingsMode :: IO ()
whenDebugMode :: IO () -> IO ()
withDebugMode :: (Bool -> IO a) -> IO a
setDebugMode :: IO ()
debugMessage :: String -> IO ()
addCRCWarning :: FilePath -> IO ()
getCRCWarnings :: IO [FilePath]
resetCRCWarnings :: IO ()
darcsdir :: String
darcsLastMessage :: String
darcsSendMessage :: String
darcsSendMessageFinal :: String
defaultRemoteDarcsCmd :: String


-- | GZIp and MMap IO for ByteStrings, encoding utilities, and
--   miscellaneous functions for Data.ByteString
module Darcs.Util.ByteString

-- | Read an entire file, which may or may not be gzip compressed, directly
--   into a <a>ByteString</a>.
gzReadFilePS :: FilePath -> IO ByteString

-- | Like readFilePS, this reads an entire file directly into a
--   <a>ByteString</a>, but it is even more efficient. It involves directly
--   mapping the file to memory. This has the advantage that the contents
--   of the file never need to be copied. Also, under memory pressure the
--   page may simply be discarded, wile in the case of readFilePS it would
--   need to be written to swap. If you read many small files, mmapFilePS
--   will be less memory-efficient than readFilePS, since each mmapFilePS
--   takes up a separate page of memory. Also, you can run into bus errors
--   if the file is modified.
mmapFilePS :: FilePath -> IO ByteString
gzWriteFilePS :: FilePath -> ByteString -> IO ()
gzWriteFilePSs :: FilePath -> [ByteString] -> IO ()

-- | Read standard input, which may or may not be gzip compressed, directly
--   into a <a>ByteString</a>.
gzReadStdin :: IO ByteString
gzWriteHandle :: Handle -> [ByteString] -> IO ()

-- | Pointer to a filesystem, possibly with start/end offsets. Supposed to
--   be fed to (uncurry mmapFileByteString) or similar.
type FileSegment = (FilePath, Maybe (Int64, Int))

-- | Read in a FileSegment into a Lazy ByteString. Implemented using mmap.
readSegment :: FileSegment -> IO ByteString
isGZFile :: FilePath -> IO (Maybe Int)

-- | Decompress the given bytestring into a lazy list of chunks, along with
--   a boolean flag indicating (if True) that the CRC was corrupted.
--   Inspecting the flag will cause the entire list of chunks to be
--   evaluated (but if you throw away the list immediately this should run
--   in constant space).
gzDecompress :: Maybe Int -> ByteString -> ([ByteString], Bool)

-- | Drop leading white space, where white space is defined as consisting
--   of ' ', 't', 'n', or 'r'.
dropSpace :: ByteString -> ByteString

-- | Split the input into lines, that is, sections separated by 'n' bytes,
--   unless it is empty, in which case the result has one empty line.
linesPS :: ByteString -> [ByteString]

-- | Concatenate the inputs with 'n' bytes in interspersed.
unlinesPS :: [ByteString] -> ByteString
hashPS :: ByteString -> Int32
breakFirstPS :: Char -> ByteString -> Maybe (ByteString, ByteString)
breakLastPS :: Char -> ByteString -> Maybe (ByteString, ByteString)
substrPS :: ByteString -> ByteString -> Maybe Int
isFunky :: ByteString -> Bool
fromHex2PS :: ByteString -> Either String ByteString
fromPS2Hex :: ByteString -> ByteString

-- | Return the B.ByteString between the two lines given, or Nothing if
--   either of them does not appear.
--   
--   Precondition: the first two arguments (start and end line) must be
--   non-empty and contain no newline bytes.
betweenLinesPS :: ByteString -> ByteString -> ByteString -> Maybe ByteString
intercalate :: ByteString -> [ByteString] -> ByteString

-- | Test if a ByteString is made of ascii characters
isAscii :: ByteString -> Bool

-- | Decode a <tt>ByteString</tt> to a <a>String</a> according to the
--   current locale, using lone surrogates for un-decodable bytes.
decodeLocale :: ByteString -> String

-- | Encode a <a>String</a> to a <tt>ByteString</tt> according to the
--   current locale, converting lone surrogates back to the original byte.
--   If that fails (because the locale does not support the full unicode
--   range) then encode using utf-8, assuming that the un-ecodable
--   characters come from patch meta data.
--   
--   See also <a>setEnvCautiously</a>.
encodeLocale :: String -> ByteString

-- | Decode a <tt>ByteString</tt> containing UTF-8 to a <a>String</a>.
--   Decoding errors are flagged with the U+FFFD character.
unpackPSFromUTF8 :: ByteString -> String

-- | Encode a <a>String</a> to a <tt>ByteString</tt> using UTF-8.
packStringToUTF8 :: String -> ByteString
prop_unlinesPS_linesPS_left_inverse :: ByteString -> Bool
prop_linesPS_length :: ByteString -> Bool
prop_unlinesPS_length :: [ByteString] -> Bool
propHexConversion :: ByteString -> Bool

-- | Simpler but less efficient variant of <a>betweenLinesPS</a>. Note that
--   this is only equivalent under the stated preconditions.
spec_betweenLinesPS :: ByteString -> ByteString -> ByteString -> Maybe ByteString


-- | LCS stands for Longest Common Subsequence, and it is a relatively
--   challenging problem to find an LCS efficiently. This module implements
--   the algorithm described in:
--   
--   "An O(ND) Difference Algorithm and its Variations", Eugene Myers,
--   Algorithmica Vol. 1 No. 2, 1986, pp. 251-266; especially the variation
--   described in section 4.2 and most refinements implemented in GNU diff
--   (D is the edit-distance).
--   
--   There is currently no heuristic to reduce the running time and produce
--   suboptimal output for large inputs with many differences. It behaves
--   like GNU diff with the -d option in this regard.
--   
--   In the first step, a hash value for every line is calculated and
--   collisions are marked with a special value. This reduces a string
--   comparison to an int comparison for line tuples where at least one of
--   the hash values is not equal to the special value. After that, lines
--   which only exists in one of the files are removed and marked as
--   changed which reduces the running time of the following difference
--   algorithm. GNU diff additionally removes lines that appear very often
--   in the other file in some cases. The last step tries to create longer
--   changed regions and line up deletions in the first file to insertions
--   in the second by shifting changed lines forward and backward.
module Darcs.Util.Diff.Myers

-- | create a list of changes between a and b, each change has the form
--   (starta, lima, startb, limb) which means that a[starta, lima) has to
--   be replaced by b[startb, limb)
getChanges :: [ByteString] -> [ByteString] -> [(Int, [ByteString], [ByteString])]

-- | try to create nicer diffs by shifting around regions of changed lines
shiftBoundaries :: BSTArray s -> BSTArray s -> PArray -> Int -> Int -> ST s ()
initP :: [ByteString] -> PArray
aLen :: IArray a e => a Int e -> Int
type PArray = Array Int ByteString
getSlice :: PArray -> Int -> Int -> [ByteString]

module Darcs.Util.Diff.Patience
getChanges :: [ByteString] -> [ByteString] -> [(Int, [ByteString], [ByteString])]

module Darcs.Util.Diff
getChanges :: DiffAlgorithm -> [ByteString] -> [ByteString] -> [(Int, [ByteString], [ByteString])]
data DiffAlgorithm
PatienceDiff :: DiffAlgorithm
MyersDiff :: DiffAlgorithm
instance GHC.Show.Show Darcs.Util.Diff.DiffAlgorithm
instance GHC.Classes.Eq Darcs.Util.Diff.DiffAlgorithm

module Darcs.Repository.Flags
data RemoteDarcs
RemoteDarcs :: String -> RemoteDarcs
DefaultRemoteDarcs :: RemoteDarcs
remoteDarcs :: RemoteDarcs -> String
data Reorder
NoReorder :: Reorder
Reorder :: Reorder
data Verbosity
Quiet :: Verbosity
NormalVerbosity :: Verbosity
Verbose :: Verbosity
data UpdatePending
YesUpdatePending :: UpdatePending
NoUpdatePending :: UpdatePending
data UseCache
YesUseCache :: UseCache
NoUseCache :: UseCache
data DryRun
YesDryRun :: DryRun
NoDryRun :: DryRun
data UMask
YesUMask :: String -> UMask
NoUMask :: UMask
data LookForAdds
NoLookForAdds :: LookForAdds
YesLookForAdds :: LookForAdds
EvenLookForBoring :: LookForAdds
data LookForReplaces
YesLookForReplaces :: LookForReplaces
NoLookForReplaces :: LookForReplaces
data DiffAlgorithm
PatienceDiff :: DiffAlgorithm
MyersDiff :: DiffAlgorithm
data LookForMoves
YesLookForMoves :: LookForMoves
NoLookForMoves :: LookForMoves
data DiffOpts
DiffOpts :: UseIndex -> LookForAdds -> LookForReplaces -> LookForMoves -> DiffAlgorithm -> DiffOpts
[withIndex] :: DiffOpts -> UseIndex
[lookForAdds] :: DiffOpts -> LookForAdds
[lookForReplaces] :: DiffOpts -> LookForReplaces
[lookForMoves] :: DiffOpts -> LookForMoves
[diffAlg] :: DiffOpts -> DiffAlgorithm
data RunTest
YesRunTest :: RunTest
NoRunTest :: RunTest
data SetScriptsExecutable
YesSetScriptsExecutable :: SetScriptsExecutable
NoSetScriptsExecutable :: SetScriptsExecutable
data LeaveTestDir
YesLeaveTestDir :: LeaveTestDir
NoLeaveTestDir :: LeaveTestDir
data SetDefault
YesSetDefault :: Bool -> SetDefault
NoSetDefault :: Bool -> SetDefault
data InheritDefault
YesInheritDefault :: InheritDefault
NoInheritDefault :: InheritDefault
data UseIndex
UseIndex :: UseIndex
IgnoreIndex :: UseIndex
data CloneKind

-- | Just copy pristine and inventories
LazyClone :: CloneKind

-- | First do a lazy clone then copy everything
NormalClone :: CloneKind

-- | Same as Normal but omit telling user they can interrumpt
CompleteClone :: CloneKind
data AllowConflicts
NoAllowConflicts :: AllowConflicts
YesAllowConflicts :: ResolveConflicts -> AllowConflicts
data ResolveConflicts
NoResolveConflicts :: ResolveConflicts
MarkConflicts :: ResolveConflicts
ExternalMerge :: String -> ResolveConflicts
data WorkRepo
WorkRepoDir :: String -> WorkRepo
WorkRepoPossibleURL :: String -> WorkRepo
WorkRepoCurrentDir :: WorkRepo
data WantGuiPause
YesWantGuiPause :: WantGuiPause
NoWantGuiPause :: WantGuiPause
data WithPatchIndex
YesPatchIndex :: WithPatchIndex
NoPatchIndex :: WithPatchIndex
data WithWorkingDir
WithWorkingDir :: WithWorkingDir
NoWorkingDir :: WithWorkingDir
data ForgetParent
YesForgetParent :: ForgetParent
NoForgetParent :: ForgetParent
data PatchFormat
PatchFormat1 :: PatchFormat
PatchFormat2 :: PatchFormat
PatchFormat3 :: PatchFormat
data WithPrefsTemplates
WithPrefsTemplates :: WithPrefsTemplates
NoPrefsTemplates :: WithPrefsTemplates
data OptimizeDeep
OptimizeShallow :: OptimizeDeep
OptimizeDeep :: OptimizeDeep
instance GHC.Show.Show Darcs.Repository.Flags.Verbosity
instance GHC.Classes.Eq Darcs.Repository.Flags.Verbosity
instance GHC.Show.Show Darcs.Repository.Flags.WithPatchIndex
instance GHC.Classes.Eq Darcs.Repository.Flags.WithPatchIndex
instance GHC.Show.Show Darcs.Repository.Flags.RemoteDarcs
instance GHC.Classes.Eq Darcs.Repository.Flags.RemoteDarcs
instance GHC.Classes.Eq Darcs.Repository.Flags.Reorder
instance GHC.Show.Show Darcs.Repository.Flags.UpdatePending
instance GHC.Classes.Eq Darcs.Repository.Flags.UpdatePending
instance GHC.Show.Show Darcs.Repository.Flags.UseCache
instance GHC.Classes.Eq Darcs.Repository.Flags.UseCache
instance GHC.Show.Show Darcs.Repository.Flags.DryRun
instance GHC.Classes.Eq Darcs.Repository.Flags.DryRun
instance GHC.Show.Show Darcs.Repository.Flags.UMask
instance GHC.Classes.Eq Darcs.Repository.Flags.UMask
instance GHC.Show.Show Darcs.Repository.Flags.LookForAdds
instance GHC.Classes.Eq Darcs.Repository.Flags.LookForAdds
instance GHC.Show.Show Darcs.Repository.Flags.LookForReplaces
instance GHC.Classes.Eq Darcs.Repository.Flags.LookForReplaces
instance GHC.Show.Show Darcs.Repository.Flags.LookForMoves
instance GHC.Classes.Eq Darcs.Repository.Flags.LookForMoves
instance GHC.Show.Show Darcs.Repository.Flags.RunTest
instance GHC.Classes.Eq Darcs.Repository.Flags.RunTest
instance GHC.Show.Show Darcs.Repository.Flags.SetScriptsExecutable
instance GHC.Classes.Eq Darcs.Repository.Flags.SetScriptsExecutable
instance GHC.Show.Show Darcs.Repository.Flags.LeaveTestDir
instance GHC.Classes.Eq Darcs.Repository.Flags.LeaveTestDir
instance GHC.Show.Show Darcs.Repository.Flags.SetDefault
instance GHC.Classes.Eq Darcs.Repository.Flags.SetDefault
instance GHC.Show.Show Darcs.Repository.Flags.InheritDefault
instance GHC.Classes.Eq Darcs.Repository.Flags.InheritDefault
instance GHC.Show.Show Darcs.Repository.Flags.UseIndex
instance GHC.Classes.Eq Darcs.Repository.Flags.UseIndex
instance GHC.Show.Show Darcs.Repository.Flags.DiffOpts
instance GHC.Show.Show Darcs.Repository.Flags.CloneKind
instance GHC.Classes.Eq Darcs.Repository.Flags.CloneKind
instance GHC.Show.Show Darcs.Repository.Flags.ResolveConflicts
instance GHC.Classes.Eq Darcs.Repository.Flags.ResolveConflicts
instance GHC.Show.Show Darcs.Repository.Flags.AllowConflicts
instance GHC.Classes.Eq Darcs.Repository.Flags.AllowConflicts
instance GHC.Show.Show Darcs.Repository.Flags.WorkRepo
instance GHC.Classes.Eq Darcs.Repository.Flags.WorkRepo
instance GHC.Show.Show Darcs.Repository.Flags.WantGuiPause
instance GHC.Classes.Eq Darcs.Repository.Flags.WantGuiPause
instance GHC.Show.Show Darcs.Repository.Flags.WithWorkingDir
instance GHC.Classes.Eq Darcs.Repository.Flags.WithWorkingDir
instance GHC.Show.Show Darcs.Repository.Flags.ForgetParent
instance GHC.Classes.Eq Darcs.Repository.Flags.ForgetParent
instance GHC.Show.Show Darcs.Repository.Flags.PatchFormat
instance GHC.Classes.Eq Darcs.Repository.Flags.PatchFormat
instance GHC.Show.Show Darcs.Repository.Flags.WithPrefsTemplates
instance GHC.Classes.Eq Darcs.Repository.Flags.WithPrefsTemplates
instance GHC.Show.Show Darcs.Repository.Flags.OptimizeDeep
instance GHC.Classes.Eq Darcs.Repository.Flags.OptimizeDeep

module Darcs.Util.Graph

-- | Undirected graph represented as a <a>Vector</a> of adjacency
--   <a>VertexSet</a>s.
type Graph = Vector VertexSet

-- | Vertices are represented as <a>Int</a>.
type Vertex = Int

-- | Set of vertices, represented as a list for efficiency (yes, indeed).
type VertexSet = [Vertex]
data Component
Component :: Graph -> VertexSet -> Component

-- | Determine the maximal independent sets in a <a>Component</a> of a
--   <a>Graph</a>.
ltmis :: (Bool, Bool) -> Component -> [VertexSet]

-- | The classic Bron-Kerbosch algorithm for determining the maximal
--   independent sets in a <a>Graph</a>.
bkmis :: Graph -> [VertexSet]

-- | Split a <a>Graph</a> into connected components. For efficiency we
--   don't represent the result as a list of Graphs, but rather of
--   <a>VertexSet</a>s.
components :: Graph -> [Component]

-- | Enumerate all (simple) graphs of a given size (number of vertices).
genGraphs :: Int -> [Graph]
genComponents :: Int -> [Component]

-- | Whether <a>ltmis</a> is equivalent to <a>bkmis</a>.
prop_ltmis_eq_bkmis :: Graph -> Bool

-- | Whether <a>ltmis</a> generates only maximal independent sets.
prop_ltmis_maximal_independent_sets :: Component -> Bool

-- | Whether <a>ltmis</a> generates <i>all</i> maximal independent sets.
prop_ltmis_all_maximal_independent_sets :: Component -> Bool

-- | Complete specification of the <a>components</a> function.
prop_components :: Graph -> Bool
instance GHC.Show.Show Darcs.Util.Graph.Component

module Darcs.Util.HTTP
data Cachable
Cachable :: Cachable
Uncachable :: Cachable
MaxAge :: !CInt -> Cachable
copyRemote :: String -> FilePath -> Cachable -> IO ()
copyRemoteLazy :: String -> Cachable -> IO ByteString
speculateRemote :: String -> FilePath -> IO ()
postUrl :: String -> ByteString -> String -> IO ()
instance GHC.Classes.Eq Darcs.Util.HTTP.Cachable
instance GHC.Show.Show Darcs.Util.HTTP.Cachable

module Darcs.Util.Hash
newtype Hash
SHA256 :: ShortByteString -> Hash

-- | Produce a base16 (ascii-hex) encoded string from a hash. This can be
--   turned back into a Hash (see "decodeBase16". This is a loss-less
--   process.
encodeBase16 :: Hash -> ByteString

-- | Take a base16-encoded string and decode it as a <a>Hash</a>. If the
--   string is malformed, yields Nothing.
decodeBase16 :: ByteString -> Maybe Hash

-- | Compute a sha256 of a (lazy) ByteString.
sha256 :: ByteString -> Hash
sha256strict :: ByteString -> Hash

-- | Same as previous but general purpose.
sha256sum :: ByteString -> String
rawHash :: Hash -> ByteString
mkHash :: ByteString -> Hash
match :: Maybe Hash -> Maybe Hash -> Bool
encodeHash :: Hash -> String
decodeHash :: String -> Maybe Hash
showHash :: Maybe Hash -> String
sha1PS :: ByteString -> SHA1
data SHA1
SHA1 :: !Word32 -> !Word32 -> !Word32 -> !Word32 -> !Word32 -> SHA1
showAsHex :: Word32 -> String
sha1Xor :: SHA1 -> SHA1 -> SHA1
sha1zero :: SHA1
sha1short :: SHA1 -> Word32
sha1Show :: SHA1 -> ByteString

-- | Parse a <a>SHA1</a> directly from its B16 encoding, given as a
--   <a>ByteString</a>, or return <a>Nothing</a>. The implementation is
--   quite low-level and optimized because the current implementation of
--   RepoPatchV3 has to read lots of <a>SHA1</a> hashes, and profiling
--   showed that this is a bottleneck.
sha1Read :: ByteString -> Maybe SHA1
instance GHC.Read.Read Darcs.Util.Hash.Hash
instance GHC.Classes.Ord Darcs.Util.Hash.Hash
instance GHC.Classes.Eq Darcs.Util.Hash.Hash
instance GHC.Show.Show Darcs.Util.Hash.Hash
instance GHC.Classes.Ord Darcs.Util.Hash.SHA1
instance GHC.Classes.Eq Darcs.Util.Hash.SHA1
instance GHC.Show.Show Darcs.Util.Hash.SHA1
instance Data.Binary.Class.Binary Darcs.Util.Hash.SHA1

module Darcs.Util.IndexedMonad

-- | An alternative monad class, indexed by a "from" and "to" state.
class Monad m
return :: Monad m => a -> m i i a
(>>=) :: Monad m => m i j a -> (a -> m j k b) -> m i k b
(>>) :: Monad m => m i j a -> m j k b -> m i k b

-- | A class for indexed monad transformers, going from normal Haskell
--   monads into our indexed monads.
class LiftIx t
liftIx :: LiftIx t => m a -> t m i i a
when :: Monad m => Bool -> m i i () -> m i i ()
ifThenElse :: Bool -> a -> a -> a

-- | An indexed version of the standard <a>MonadReader</a> class
class Monad m => MonadReader r m | m -> r
ask :: MonadReader r m => m i i r
local :: MonadReader r m => (r -> r) -> m i i a -> m i i a

-- | An indexed version of the standard <a>ReaderT</a> transformer
newtype ReaderT r m i j a
ReaderT :: (r -> m i j a) -> ReaderT r m i j a
[runReaderT] :: ReaderT r m i j a -> r -> m i j a
asks :: MonadReader r m => (r -> a) -> m i i a
instance Darcs.Util.IndexedMonad.Monad m => Darcs.Util.IndexedMonad.Monad (Darcs.Util.IndexedMonad.ReaderT r m)
instance Darcs.Util.IndexedMonad.Monad m => Darcs.Util.IndexedMonad.MonadReader r (Darcs.Util.IndexedMonad.ReaderT r m)


module Darcs.Util.IsoDate

-- | The current time in the format returned by <a>showIsoDateTime</a>
getIsoDateTime :: IO String

-- | Read/interpret a date string, assuming UTC if timezone is not
--   specified in the string (see <a>readDate</a>) Warning! This errors out
--   if we fail to interpret the date
readUTCDate :: String -> CalendarTime

-- | Similar to <a>readUTCDate</a>, except we <i>ignore</i> timezone info
--   in the input string. This is incorrect and ugly. The only reason it
--   still exists is so we can generate file names for old-fashioned
--   repositories in the same way that old darcs versions expected them.
--   You should not use this function except for the above stated purpose.
readUTCDateOldFashioned :: String -> CalendarTime

-- | Parse a date string, assuming a default timezone if the date string
--   does not specify one. The date formats understood are those of
--   <a>showIsoDateTime</a> and <a>dateTime</a>
parseDate :: Int -> String -> Either ParseError MCalendarTime

-- | Return the local timezone offset from UTC in seconds
getLocalTz :: IO Int

-- | In English, either a date followed by a time, or vice-versa, e.g,
--   
--   <ul>
--   <li>yesterday at noon</li>
--   <li>yesterday tea time</li>
--   <li>12:00 yesterday</li>
--   </ul>
--   
--   See <a>englishDate</a> and <a>englishTime</a> Uses its first argument
--   as "now", i.e. the time relative to which "yesterday", "today" etc are
--   to be interpreted
englishDateTime :: CalendarTime -> CharParser a CalendarTime

-- | English expressions for intervals of time,
--   
--   <ul>
--   <li>before tea time (i.e. from the beginning of time)</li>
--   <li>after 14:00 last month (i.e. till now)</li>
--   <li>between last year and last month</li>
--   <li>in the last three months (i.e. from then till now)</li>
--   <li>4 months ago (i.e. till now; see <a>englishAgo</a>)</li>
--   </ul>
englishInterval :: CalendarTime -> CharParser a TimeInterval

-- | Durations in English that begin with the word "last", E.g. "last 4
--   months" is treated as the duration between 4 months ago and now
englishLast :: CalendarTime -> CharParser a (CalendarTime, CalendarTime)

-- | Intervals in ISO 8601, e.g.,
--   
--   <ul>
--   <li>2008-09/2012-08-17T16:30</li>
--   <li>2008-09/P2Y11MT16H30M</li>
--   <li>P2Y11MT16H30M/2012-08-17T16:30</li>
--   </ul>
--   
--   See <a>iso8601Duration</a>
iso8601Interval :: Int -> CharParser a (Either TimeDiff (MCalendarTime, MCalendarTime))

-- | Durations in ISO 8601, e.g.,
--   
--   <ul>
--   <li>P4Y (four years)</li>
--   <li>P5M (five months)</li>
--   <li>P4Y5M (four years and five months)</li>
--   <li>P4YT3H6S (four years, three hours and six seconds)</li>
--   </ul>
iso8601Duration :: CharParser a TimeDiff

-- | Convert a date string into ISO 8601 format (yyyymmdd variant) assuming
--   local timezone if not specified in the string Warning! This errors out
--   if we fail to interpret the date
cleanLocalDate :: String -> IO String

-- | Set a calendar to UTC time any eliminate any inconsistencies within
--   (for example, where the weekday is given as <tt>Thursday</tt>, but
--   this does not match what the numerical date would lead one to expect)
resetCalendar :: CalendarTime -> CalendarTime

-- | An <tt>MCalenderTime</tt> is an underspecified <a>CalendarTime</a> It
--   is used for parsing dates. For example, if you want to parse the date
--   '4 January', it may be useful to underspecify the year by setting it
--   to <a>Nothing</a>. This uses almost the same fields as
--   <a>CalendarTime</a>, a notable exception being that we introduce
--   <a>mctWeek</a> to indicate if a weekday was specified or not
data MCalendarTime
MCalendarTime :: Maybe Int -> Maybe Month -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Integer -> Maybe Day -> Maybe Int -> Maybe String -> Maybe Int -> Maybe Bool -> Bool -> MCalendarTime
[mctYear] :: MCalendarTime -> Maybe Int
[mctMonth] :: MCalendarTime -> Maybe Month
[mctDay] :: MCalendarTime -> Maybe Int
[mctHour] :: MCalendarTime -> Maybe Int
[mctMin] :: MCalendarTime -> Maybe Int
[mctSec] :: MCalendarTime -> Maybe Int
[mctPicosec] :: MCalendarTime -> Maybe Integer
[mctWDay] :: MCalendarTime -> Maybe Day
[mctYDay] :: MCalendarTime -> Maybe Int
[mctTZName] :: MCalendarTime -> Maybe String
[mctTZ] :: MCalendarTime -> Maybe Int
[mctIsDST] :: MCalendarTime -> Maybe Bool
[mctWeek] :: MCalendarTime -> Bool
subtractFromMCal :: TimeDiff -> MCalendarTime -> MCalendarTime
addToMCal :: TimeDiff -> MCalendarTime -> MCalendarTime

-- | Trivially convert a <a>CalendarTime</a> to a fully specified
--   <a>MCalendarTime</a> (note that this sets the <a>mctWeek</a> flag to
--   <tt>False</tt>
toMCalendarTime :: CalendarTime -> MCalendarTime

-- | Returns the first <a>CalendarTime</a> that falls within a
--   <a>MCalendarTime</a> This is only unsafe in the sense that it plugs in
--   default values for fields that have not been set, e.g.
--   <tt>January</tt> for the month or <tt>0</tt> for the seconds field.
--   Maybe we should rename it something happier. See also
--   <a>resetCalendar</a>
unsafeToCalendarTime :: MCalendarTime -> CalendarTime

-- | Zero the time fields of a <a>CalendarTime</a>
unsetTime :: CalendarTime -> CalendarTime
type TimeInterval = (Maybe CalendarTime, Maybe CalendarTime)

-- | Display a <a>CalendarTime</a> in the ISO 8601 format without any
--   separators, e.g. 20080825142503
showIsoDateTime :: CalendarTime -> String

-- | The very beginning of time, i.e. 1970-01-01
theBeginning :: CalendarTime
instance GHC.Show.Show Darcs.Util.IsoDate.MCalendarTime


module Darcs.Util.DateMatcher

-- | <a>parseDateMatcher</a> <tt>s</tt> return the first matcher in
--   <a>getMatchers</a> that can parse <tt>s</tt>
parseDateMatcher :: String -> IO (CalendarTime -> Bool)

-- | A <a>DateMatcher</a> combines a potential parse for a date string with
--   a "matcher" function that operates on a given date. We use an
--   existential type on the matcher to allow the date string to either be
--   interpreted as a point in time or as an interval.
data DateMatcher
DM :: String -> Either ParseError d -> (d -> CalendarTime -> Bool) -> DateMatcher

-- | <a>getMatchers</a> <tt>d</tt> returns the list of matchers that will
--   be applied on <tt>d</tt>. If you wish to extend the date parsing code,
--   this will likely be the function that you modify to do so.
getMatchers :: String -> IO [DateMatcher]

-- | <a>testDate</a> <tt>d</tt> shows the possible interpretations for the
--   date string <tt>d</tt> and how they match against the current date
testDate :: String -> IO ()

-- | <a>testDate</a> <tt>iso d</tt> shows the possible interpretations for
--   the date string <tt>d</tt> and how they match against the date
--   represented by the ISO 8601 string <tt>iso</tt>
testDateAt :: String -> String -> IO ()

module Darcs.Util.Parser
type Parser = Parser ByteString
anyChar :: Parser Char
char :: Char -> Parser ()
checkConsumes :: Parser a -> Parser a
choice :: Alternative f => [f a] -> f a
endOfInput :: Chunk t => Parser t ()
int :: Parser Int
lexChar :: Char -> Parser ()
lexString :: ByteString -> Parser ()
linesStartingWith :: Char -> Parser [ByteString]
linesStartingWithEndingWith :: Char -> Char -> Parser [ByteString]
lexWord :: Parser ByteString
lookAhead :: Parser i a -> Parser i a
many :: Alternative f => f a -> f [a]
option :: Alternative f => a -> f a -> f a
optional :: Alternative f => f a -> f (Maybe a)
parse :: Parser a -> ByteString -> Either String (a, ByteString)
parseAll :: Parser a -> ByteString -> Either String a
skipSpace :: Parser ()
skipWhile :: (Char -> Bool) -> Parser ()
string :: ByteString -> Parser ()
take :: Int -> Parser ByteString
takeTill :: (Char -> Bool) -> Parser ByteString
takeTillChar :: Char -> Parser ByteString
unsigned :: Integral a => Parser a
withPath :: FilePath -> Either String a -> Either String a
(<|>) :: Alternative f => f a -> f a -> f a


-- | Darcs pretty printing library
--   
--   The combinator names are taken from <a>HughesPJ</a>, although the
--   behaviour of the two libraries is slightly different.
--   
--   This code was made generic in the element type by Juliusz Chroboczek.
module Darcs.Util.Printer

-- | A <a>Doc</a> is a bit of enriched text. <a>Doc</a>s are concatenated
--   using <a>&lt;&gt;</a> from class <a>Monoid</a>, which is
--   right-associative.
newtype Doc
Doc :: (St -> Document) -> Doc
[unDoc] :: Doc -> St -> Document

-- | The empty <a>Doc</a>
empty :: Doc
(<>) :: Semigroup a => a -> a -> a

-- | <tt>a <a>&lt;?&gt;</a> b</tt> is <tt>a <a>&lt;&gt;</a> b</tt> if
--   <tt>a</tt> is not empty, else empty
(<?>) :: Doc -> Doc -> Doc

-- | <tt>a <a>&lt;+&gt;</a> b</tt> is <tt>a</tt> followed by <tt>b</tt>
--   with a space in between if both are non-empty
(<+>) :: Doc -> Doc -> Doc
infixr 6 <+>

-- | <tt>a <a>$$</a> b</tt> is <tt>a</tt> above <tt>b</tt>
($$) :: Doc -> Doc -> Doc
infixr 5 $$

-- | <tt>a <a>$+$</a> b</tt> is <tt>a</tt> above <tt>b</tt> with an empty
--   line in between if both are non-empty
($+$) :: Doc -> Doc -> Doc
infixr 5 $+$

-- | Pile <a>Doc</a>s vertically
vcat :: [Doc] -> Doc

-- | Pile <a>Doc</a>s vertically, with a blank line in between
vsep :: [Doc] -> Doc

-- | Concatenate <a>Doc</a>s horizontally
hcat :: [Doc] -> Doc

-- | Concatenate <a>Doc</a>s horizontally with a space as separator
hsep :: [Doc] -> Doc

-- | A <a>Doc</a> representing a "-"
minus :: Doc

-- | A <a>Doc</a> representing a newline
newline :: Doc

-- | A <a>Doc</a> representing a "+"
plus :: Doc

-- | A <a>Doc</a> representing a space (" ")
space :: Doc

-- | A <a>Doc</a> representing a "\"
backslash :: Doc

-- | A <a>Doc</a> that represents <tt>"("</tt>
lparen :: Doc

-- | A <a>Doc</a> that represents <tt>")"</tt>
rparen :: Doc

-- | <pre>
--   parens d = lparen &lt;&gt; d &lt;&gt; rparen
--   </pre>
parens :: Doc -> Doc

-- | Turn a <a>Doc</a> into a sentence. This appends a ".".
sentence :: Doc -> Doc

-- | <a>text</a> creates a <a>Doc</a> from a <tt>String</tt>, using
--   <a>printable</a>.
text :: String -> Doc

-- | <a>hiddenText</a> creates a <a>Doc</a> containing hidden text from a
--   <tt>String</tt>
hiddenText :: String -> Doc

-- | <a>invisibleText</a> creates a <a>Doc</a> containing invisible text
--   from a <tt>String</tt>
invisibleText :: String -> Doc

-- | <tt><a>wrapText</a> n s</tt> is a <a>Doc</a> representing <tt>s</tt>
--   line-wrapped at <tt>n</tt> characters
wrapText :: Int -> String -> Doc

-- | Quote a string for screen output
quoted :: String -> Doc

-- | Given a list of <a>String</a>s representing the words of a paragraph,
--   format the paragraphs using <a>wrapText</a> and separate them with an
--   empty line.
formatText :: Int -> [String] -> Doc

-- | A variant of <a>wrapText</a> that takes a list of strings as input.
--   Useful when <tt>{-# LANGUAGE CPP #-}</tt> makes it impossible to use
--   multiline string literals.
formatWords :: [String] -> Doc

-- | Format a list of <a>FilePath</a>s as quoted text. It deliberately
--   refuses to use English.andClauses but rather separates the quoted
--   strings only with a space, because this makes it usable for copy and
--   paste e.g. as arguments to another shell command.
pathlist :: [FilePath] -> Doc

-- | Create a <a>Doc</a> containing a userchunk from a <tt>String</tt>.
--   
--   Userchunks are used for printing arbitrary bytes stored in prim
--   patches:
--   
--   <ul>
--   <li>old and new preference values in ChangePref prims</li>
--   <li>tokenChars, old token and new token in TokReplace prims</li>
--   <li>old and new content lines in Hunk prims</li>
--   </ul>
--   
--   In colored mode they are printed such that trailing whitespace before
--   the end of a line is made visible by marking the actual line ending
--   with a red <a>$</a> char (unless DARCS_DONT_ESCAPE_TRAILING_SPACES or
--   even DARCS_DONT_ESCAPE_ANYTHING are set in the environment).
userchunk :: String -> Doc

-- | <a>packedString</a> builds a <a>Doc</a> from a <a>ByteString</a> using
--   <a>printable</a>
packedString :: ByteString -> Doc
prefix :: String -> Doc -> Doc
hiddenPrefix :: String -> Doc -> Doc
insertBeforeLastline :: Doc -> Doc -> Doc
prefixLines :: Doc -> Doc -> Doc

-- | <a>invisiblePS</a> creates a <a>Doc</a> with invisible text from a
--   <a>ByteString</a>
invisiblePS :: ByteString -> Doc

-- | Create a <a>Doc</a> representing a user chunk from a
--   <a>ByteString</a>; see <a>userchunk</a> for details.
userchunkPS :: ByteString -> Doc

-- | renders a <a>Doc</a> into a <a>String</a> with control codes for the
--   special features of the <a>Doc</a>.
renderString :: Doc -> String

-- | renders a <a>Doc</a> into a <a>String</a> using a given set of
--   printers. If content is only available as <tt>ByteString</tt>, decode
--   according to the current locale.
renderStringWith :: Printers' -> Doc -> String

-- | renders a <a>Doc</a> into <a>ByteString</a> with control codes for the
--   special features of the Doc. See also <tt>readerString</tt>.
renderPS :: Doc -> ByteString

-- | renders a <a>Doc</a> into a <a>ByteString</a> using a given set of
--   printers.
renderPSWith :: Printers' -> Doc -> ByteString

-- | renders a <a>Doc</a> into a list of <tt>PackedStrings</tt>, one for
--   each line.
renderPSs :: Doc -> [ByteString]

-- | renders a <a>Doc</a> into a list of <tt>PackedStrings</tt>, one for
--   each chunk of text that was added to the <a>Doc</a>, using the given
--   set of printers.
renderPSsWith :: Printers' -> Doc -> [ByteString]
type Printers = Handle -> IO Printers'

-- | A set of printers to print different types of text to a handle.
data Printers'
Printers :: !Color -> Printer -> !Printer -> !Printer -> !Printer -> !Printer -> !Color -> Doc -> Doc -> ![Printable] -> [Printable] -> Printers'
[colorP] :: Printers' -> !Color -> Printer
[invisibleP] :: Printers' -> !Printer
[hiddenP] :: Printers' -> !Printer
[userchunkP] :: Printers' -> !Printer
[defP] :: Printers' -> !Printer
[lineColorT] :: Printers' -> !Color -> Doc -> Doc
[lineColorS] :: Printers' -> ![Printable] -> [Printable]
type Printer = Printable -> St -> Document

-- | <a>simplePrinters</a> is a <a>Printers</a> which uses the set
--   'simplePriners'' on any handle.
simplePrinters :: Printers

-- | <a>invisiblePrinter</a> is the <a>Printer</a> for hidden text. It just
--   replaces the document with <a>empty</a>. It's useful to have a printer
--   that doesn't actually do anything because this allows you to have
--   tunable policies, for example, only printing some text if it's to the
--   terminal, but not if it's to a file or vice-versa.
invisiblePrinter :: Printer

-- | <a>simplePrinter</a> is the simplest <a>Printer</a>: it just
--   concatenates together the pieces of the <a>Doc</a>
simplePrinter :: Printer

-- | A <a>Printable</a> is either a String, a packed string, or a chunk of
--   text with both representations.
data Printable
S :: !String -> Printable
PS :: !ByteString -> Printable
Both :: !String -> !ByteString -> Printable
doc :: ([Printable] -> [Printable]) -> Doc

-- | Creates a <a>Doc</a> from any <a>Printable</a>.
printable :: Printable -> Doc

-- | Creates an invisible <a>Doc</a> from any <a>Printable</a>.
invisiblePrintable :: Printable -> Doc

-- | Creates a hidden <a>Doc</a> from any <a>Printable</a>.
hiddenPrintable :: Printable -> Doc

-- | Creates a userchunk from any <a>Printable</a>; see <a>userchunk</a>
--   for details.
userchunkPrintable :: Printable -> Doc
data Color
Blue :: Color
Red :: Color
Green :: Color
Cyan :: Color
Magenta :: Color
blueText :: String -> Doc
redText :: String -> Doc
greenText :: String -> Doc
magentaText :: String -> Doc
cyanText :: String -> Doc

-- | <a>colorText</a> creates a <a>Doc</a> containing colored text from a
--   <tt>String</tt>
colorText :: Color -> String -> Doc
lineColor :: Color -> Doc -> Doc

-- | <tt>hputDoc</tt> puts a <a>Doc</a> on the given handle using
--   <a>simplePrinters</a>
hPutDoc :: Handle -> Doc -> IO ()

-- | <tt>hputDocLn</tt> puts a <a>Doc</a>, followed by a newline on the
--   given handle using <a>simplePrinters</a>.
hPutDocLn :: Handle -> Doc -> IO ()

-- | <a>putDoc</a> puts a <a>Doc</a> on stdout using the simple printer
--   <a>simplePrinters</a>.
putDoc :: Doc -> IO ()

-- | <a>putDocLn</a> puts a <a>Doc</a>, followed by a newline on stdout
--   using <a>simplePrinters</a>
putDocLn :: Doc -> IO ()

-- | <tt>hputDocWith</tt> puts a <a>Doc</a> on the given handle using the
--   given printer.
hPutDocWith :: Printers -> Handle -> Doc -> IO ()

-- | <tt>hputDocLnWith</tt> puts a <a>Doc</a>, followed by a newline on the
--   given handle using the given printer.
hPutDocLnWith :: Printers -> Handle -> Doc -> IO ()

-- | <a>putDocWith</a> puts a <a>Doc</a> on stdout using the given printer.
putDocWith :: Printers -> Doc -> IO ()

-- | <a>putDocLnWith</a> puts a <a>Doc</a>, followed by a newline on stdout
--   using the given printer.
putDocLnWith :: Printers -> Doc -> IO ()

-- | like <a>hPutDoc</a> but with compress data before writing
hPutDocCompr :: Handle -> Doc -> IO ()

-- | Write a <a>Doc</a> to stderr if debugging is turned on.
debugDocLn :: Doc -> IO ()

-- | <a>unsafeText</a> creates a <a>Doc</a> from a <a>String</a>, using
--   <a>simplePrinter</a> directly
unsafeText :: String -> Doc

-- | <a>unsafeBoth</a> builds a Doc from a <a>String</a> and a
--   <a>ByteString</a> representing the same text, but does not check that
--   they do.
unsafeBoth :: String -> ByteString -> Doc

-- | <a>unsafeBothText</a> builds a <a>Doc</a> from a <a>String</a>. The
--   string is stored in the Doc as both a String and a <a>ByteString</a>.
unsafeBothText :: String -> Doc

-- | <a>unsafeChar</a> creates a Doc containing just one character.
unsafeChar :: Char -> Doc

-- | <a>unsafePackedString</a> builds a <a>Doc</a> from a <a>ByteString</a>
--   using <a>simplePrinter</a>
unsafePackedString :: ByteString -> Doc
instance Data.String.IsString Darcs.Util.Printer.Doc
instance GHC.Base.Semigroup Darcs.Util.Printer.Doc
instance GHC.Base.Monoid Darcs.Util.Printer.Doc


-- | This modules provides rudimentary natural language generation (NLG)
--   utilities. That is, generating natural language from a machine
--   representation. Initially, only English is supported at all.
--   Representations are implemented for:
--   
--   <ul>
--   <li>countable nouns (plurality); and</li>
--   <li>lists of clauses (foo, bar and/or baz).</li>
--   </ul>
module Darcs.Util.English

-- | <pre>
--   englishNum 0 (Noun "watch") "" == "watches"
--   englishNum 1 (Noun "watch") "" == "watch"
--   englishNum 2 (Noun "watch") "" == "watches"
--   </pre>
englishNum :: Countable n => Int -> n -> ShowS

-- | Things that have a plural and singular spelling
class Countable a
plural :: Countable a => a -> ShowS
singular :: Countable a => a -> ShowS

-- | This only distinguishes between nouns with a final -ch, and nouns
--   which do not. More irregular nouns will just need to have their own
--   type
--   
--   <pre>
--   plural (Noun "batch") "" == "batches"
--   plural (Noun "bat")   "" == "bats"
--   plural (Noun "mouse") "" == "mouses" -- :-(
--   </pre>
newtype Noun
Noun :: String -> Noun
data Pronoun
It :: Pronoun

-- | <pre>
--   singular This (Noun "batch") "" == "this batch"
--   plural   This (Noun "batch") "" == "these batches"
--   </pre>
data This
This :: Noun -> This

-- | Given a list of things, combine them thusly:
--   
--   <pre>
--   orClauses ["foo", "bar", "baz"] == "foo, bar or baz"
--   </pre>
andClauses :: [String] -> String

-- | Given a list of things, combine them thusly:
--   
--   <pre>
--   orClauses ["foo", "bar", "baz"] == "foo, bar or baz"
--   </pre>
orClauses :: [String] -> String
anyOfClause :: [String] -> Doc
itemizeVertical :: Int -> [String] -> Doc
itemize :: String -> [String] -> String
presentParticiple :: String -> String

-- | Capitalize the first letter of a word
capitalize :: String -> String
instance Darcs.Util.English.Countable Darcs.Util.English.This
instance Darcs.Util.English.Countable Darcs.Util.English.Pronoun
instance Darcs.Util.English.Countable Darcs.Util.English.Noun

module Darcs.UI.Email
makeEmail :: String -> [(String, String)] -> Maybe Doc -> Maybe String -> Doc -> Maybe String -> Doc
readEmail :: ByteString -> ByteString

-- | Formats an e-mail header by encoding any non-ascii characters using
--   UTF-8 and Q-encoding, and folding lines at appropriate points. It
--   doesn't do more than that, so the header name and header value should
--   be well-formatted give or take line length and encoding. So no
--   non-ASCII characters within quoted-string, quoted-pair, or atom; no
--   semantically meaningful signs in names; no non-ASCII characters in the
--   header name; etcetera.
formatHeader :: String -> String -> ByteString
prop_qp_roundtrip :: ByteString -> Bool

module Darcs.Util.Printer.Color
unsafeRenderStringColored :: Doc -> String
traceDoc :: Doc -> a -> a

-- | <tt><a>fancyPrinters</a> h</tt> returns a set of printers suitable for
--   outputting to <tt>h</tt>
fancyPrinters :: Printers
environmentHelpColor :: ([String], [String])
environmentHelpEscape :: ([String], [String])
environmentHelpEscapeWhite :: ([String], [String])

-- | <tt>eputDocLn</tt> puts a <a>Doc</a>, followed by a newline to stderr
--   using <a>fancyPrinters</a>. Like putDocLn, it encodes with the user's
--   locale. This function is the recommended way to output messages that
--   should be visible to users on the console, but cannot (or should not)
--   be silenced even when --quiet is in effect.
ePutDocLn :: Doc -> IO ()


-- | Utility functions for tracking progress of long-running actions.
module Darcs.Util.Progress

-- | <tt>beginTedious k</tt> starts a tedious process and registers it in
--   <a>_progressData</a> with the key <tt>k</tt>. A tedious process is one
--   for which we want a progress indicator.
--   
--   Wouldn't it be safer if it had type String -&gt; IO ProgressDataKey,
--   so that we can ensure there is no collision? What happens if you call
--   beginTedious twice with the same string, without calling endTedious in
--   the meantime?
beginTedious :: String -> IO ()

-- | <tt>endTedious k</tt> unregisters the tedious process with key
--   <tt>k</tt>, printing <a>Done</a> if such a tedious process exists.
endTedious :: String -> IO ()
tediousSize :: String -> Int -> IO ()
withProgress :: String -> (String -> IO a) -> IO a
withSizedProgress :: String -> Int -> (String -> IO a) -> IO a
debugMessage :: String -> IO ()
withoutProgress :: IO a -> IO a
progress :: String -> a -> a
progressKeepLatest :: String -> a -> a
finishedOne :: String -> String -> a -> a
finishedOneIO :: String -> String -> IO ()
progressList :: String -> [a] -> [a]

-- | XXX: document this constant
minlist :: Int
setProgressMode :: Bool -> IO ()


module Darcs.Util.Exec
exec :: String -> [String] -> Redirects -> IO ExitCode
execInteractive :: String -> Maybe String -> IO ExitCode
readInteractiveProcess :: FilePath -> [String] -> IO (ExitCode, String)
renderExecException :: ExecException -> String
withoutNonBlock :: IO a -> IO a
type Redirects = (Redirect, Redirect, Redirect)
data Redirect
AsIs :: Redirect
Null :: Redirect
File :: FilePath -> Redirect
Stdout :: Redirect
data ExecException
ExecException :: String -> [String] -> Redirects -> String -> ExecException
instance GHC.Show.Show Darcs.Util.Exec.Redirect
instance GHC.Exception.Type.Exception Darcs.Util.Exec.ExecException
instance GHC.Show.Show Darcs.Util.Exec.ExecException

module Darcs.Util.Prompt

-- | Ask the user to press Enter
askEnter :: String -> IO ()

-- | Ask the user for a line of input.
askUser :: String -> IO String

-- | <tt>askUserListItem prompt xs</tt> enumerates <tt>xs</tt> on the
--   screen, allowing the user to choose one of the items
askUserListItem :: String -> [String] -> IO String
data PromptConfig
PromptConfig :: String -> [Char] -> [Char] -> Maybe Char -> [Char] -> PromptConfig
[pPrompt] :: PromptConfig -> String
[pBasicCharacters] :: PromptConfig -> [Char]

-- | only shown on help
[pAdvancedCharacters] :: PromptConfig -> [Char]
[pDefault] :: PromptConfig -> Maybe Char
[pHelp] :: PromptConfig -> [Char]

-- | Prompt the user for a yes or no
promptYorn :: String -> IO Bool

-- | Prompt the user for a character, among a list of possible ones. Always
--   returns a lowercase character. This is because the default character
--   (ie, the character shown in uppercase, that is automatically selected
--   when the user presses the space bar) is shown as uppercase, hence
--   users may want to enter it as uppercase.
promptChar :: PromptConfig -> IO Char


-- | A more high-level API for what <a>Darcs.Util.Prompt</a> offers
module Darcs.UI.Prompt
data PromptChoice a
PromptChoice :: Char -> Bool -> IO a -> String -> PromptChoice a
[pcKey] :: PromptChoice a -> Char
[pcWhen] :: PromptChoice a -> Bool
[pcAction] :: PromptChoice a -> IO a
[pcHelp] :: PromptChoice a -> String
data PromptConfig a
PromptConfig :: String -> String -> [[PromptChoice a]] -> Maybe Char -> PromptConfig a
[pPrompt] :: PromptConfig a -> String
[pVerb] :: PromptConfig a -> String
[pChoices] :: PromptConfig a -> [[PromptChoice a]]
[pDefault] :: PromptConfig a -> Maybe Char
runPrompt :: PromptConfig a -> IO a


module Darcs.Util.Ratified
readFile :: FilePath -> IO String
hGetContents :: Handle -> IO String


-- | This module is a subset of the defunct regex-compat-tdfa.
module Darcs.Util.Regex
data () => Regex

-- | Makes a regular expression with the default options (multi-line,
--   case-sensitive). The syntax of regular expressions is otherwise that
--   of <tt>egrep</tt> (i.e. POSIX "extended" regular expressions).
mkRegex :: String -> Regex

-- | Makes a regular expression, where the multi-line and case-sensitive
--   options can be changed from the default settings.
mkRegexWithOpts :: String -> Bool -> Bool -> Regex

-- | Match a regular expression against a string
matchRegex :: Regex -> String -> Maybe [String]
instance GHC.Base.Monad Darcs.Util.Regex.RegexFail
instance GHC.Base.Applicative Darcs.Util.Regex.RegexFail
instance GHC.Base.Functor Darcs.Util.Regex.RegexFail
instance Control.Monad.Fail.MonadFail Darcs.Util.Regex.RegexFail

module Darcs.Util.Show
appPrec :: Int

module Darcs.Patch.Witnesses.Show
class Show1 a
showDict1 :: Show1 a => Dict (Show (a wX))
showDict1 :: (Show1 a, Show (a wX)) => ShowDict (a wX)
class Show2 a
showDict2 :: Show2 a => ShowDict (a wX wY)
showDict2 :: (Show2 a, Show (a wX wY)) => ShowDict (a wX wY)
show1 :: Show1 a => a wX -> String
showsPrec1 :: Show1 a => Int -> a wX -> ShowS
show2 :: Show2 a => a wX wY -> String
showsPrec2 :: Show2 a => Int -> a wX wY -> ShowS
showOp2 :: (Show2 a, Show2 b) => Int -> String -> Int -> a wW wX -> b wY wZ -> String -> String
appPrec :: Int

module Darcs.Patch.Witnesses.Sealed

-- | A <a>Sealed</a> type is a way of hide an existentially quantified type
--   parameter, in this case wX, inside the type. Note that the only thing
--   we can currently recover about the existentially quantified type wX is
--   that it exists.
data Sealed a
[Sealed] :: a wX -> Sealed a
seal :: a wX -> Sealed a

-- | The same as <a>Sealed</a> but for two parameters (wX and wY).
data Sealed2 a
[Sealed2] :: !a wX wY -> Sealed2 a
seal2 :: a wX wY -> Sealed2 a
data FlippedSeal a wY
[FlippedSeal] :: !a wX wY -> FlippedSeal a wY
flipSeal :: a wX wY -> FlippedSeal a wY
unseal :: (forall wX. a wX -> b) -> Sealed a -> b
mapSeal :: (forall wX. a wX -> b wX) -> Sealed a -> Sealed b
mapFlipped :: (forall wX. a wX wY -> b wX wZ) -> FlippedSeal a wY -> FlippedSeal b wZ
unseal2 :: (forall wX wY. a wX wY -> b) -> Sealed2 a -> b
mapSeal2 :: (forall wX wY. a wX wY -> b wX wY) -> Sealed2 a -> Sealed2 b
unsealFlipped :: (forall wX wY. a wX wY -> b) -> FlippedSeal a wZ -> b

-- | Duplicate a single witness. This is for situations where a patch-like
--   type is expected, i.e. a type with two witnesses, but we have only a
--   type with one witness. Naturally, any concrete value must have both
--   witnesses agreeing.
--   
--   Note that <tt><a>Sealed</a> (<a>Dup</a> p wX)</tt> is isomorphic to
--   <tt>p wX</tt>.
data Dup p wX wY
[Dup] :: p wX -> Dup p wX wX

-- | <a>FreeLeft</a> p is <tt> forall x . exists y . p x y </tt> In other
--   words the caller is free to specify the left witness, and then the
--   right witness is an existential. Note that the order of the type
--   constructors is important for ensuring that <tt> y </tt> is dependent
--   on the <tt> x </tt> that is supplied. This is why <tt>Stepped</tt> is
--   needed, rather than writing the more obvious <a>Sealed</a>
--   (<a>Poly</a> p) which would notionally have the same quantification of
--   the type witnesses.
data FreeLeft p

-- | <a>FreeRight</a> p is <tt> forall y . exists x . p x y </tt> In other
--   words the caller is free to specify the right witness, and then the
--   left witness is an existential. Note that the order of the type
--   constructors is important for ensuring that <tt> x </tt> is dependent
--   on the <tt> y </tt> that is supplied.
data FreeRight p

-- | Unwrap a <a>FreeLeft</a> value
unFreeLeft :: FreeLeft p -> Sealed (p wX)

-- | Unwrap a <a>FreeRight</a> value
unFreeRight :: FreeRight p -> FlippedSeal p wX

-- | <a>Gap</a> abstracts over <a>FreeLeft</a> and <a>FreeRight</a> for
--   code constructing these values
class Gap w

-- | An empty <a>Gap</a>, e.g. <tt>NilFL</tt> or <tt>NilRL</tt>
emptyGap :: Gap w => (forall wX. p wX wX) -> w p

-- | A <a>Gap</a> constructed from a completely polymorphic value, for
--   example the constructors for primitive patches
freeGap :: Gap w => (forall wX wY. p wX wY) -> w p

-- | Compose two <a>Gap</a> values together in series, e.g. 'joinGap
--   (+&gt;+)' or 'joinGap (:&gt;:)'
joinGap :: Gap w => (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> w p -> w q -> w r
instance Darcs.Patch.Witnesses.Sealed.Gap Darcs.Patch.Witnesses.Sealed.FreeLeft
instance Darcs.Patch.Witnesses.Sealed.Gap Darcs.Patch.Witnesses.Sealed.FreeRight
instance Darcs.Patch.Witnesses.Show.Show2 a => GHC.Show.Show (Darcs.Patch.Witnesses.Sealed.Sealed2 a)
instance Darcs.Patch.Witnesses.Eq.Eq2 a => GHC.Classes.Eq (Darcs.Patch.Witnesses.Sealed.Sealed (a wX))
instance Darcs.Patch.Witnesses.Show.Show1 a => GHC.Show.Show (Darcs.Patch.Witnesses.Sealed.Sealed a)

module Darcs.Patch.Witnesses.Ordered

-- | Directed Forward Pairs
data ( a1 :> a2 ) wX wY
(:>) :: a1 wX wZ -> a2 wZ wY -> (:>) a1 a2 wX wY
infixr 1 :>
infixr 1 :>

-- | Forward lists
data FL a wX wZ
[:>:] :: a wX wY -> FL a wY wZ -> FL a wX wZ
[NilFL] :: FL a wX wX
infixr 5 :>:

-- | Reverse lists
data RL a wX wZ
[:<:] :: RL a wX wY -> a wY wZ -> RL a wX wZ
[NilRL] :: RL a wX wX
infixl 5 :<:

-- | Forking Pairs (Implicit starting context)
data ( a1 :\/: a2 ) wX wY
(:\/:) :: a1 wZ wX -> a2 wZ wY -> (:\/:) a1 a2 wX wY
infix 1 :\/:
infix 1 :\/:

-- | Joining Pairs
data ( a3 :/\: a4 ) wX wY
(:/\:) :: a3 wX wZ -> a4 wY wZ -> (:/\:) a3 a4 wX wY
infix 1 :/\:
infix 1 :/\:

-- | Parallel Pairs
data ( a1 :||: a2 ) wX wY
(:||:) :: a1 wX wY -> a2 wX wY -> (:||:) a1 a2 wX wY
infix 1 :||:
infix 1 :||:

-- | Forking Pair (Explicit starting context)
--   
--   <pre>
--   wX     wY       
--    \     /    
--     \   /
--      \ /     
--       wU
--       |
--       |
--       |
--       wA
--   </pre>
data Fork common left right wA wX wY
Fork :: common wA wU -> left wU wX -> right wU wY -> Fork common left right wA wX wY
nullFL :: FL a wX wZ -> Bool
nullRL :: RL a wX wZ -> Bool
lengthFL :: FL a wX wZ -> Int
lengthRL :: RL a wX wZ -> Int
mapFL :: (forall wW wZ. a wW wZ -> b) -> FL a wX wY -> [b]
mapRL :: (forall wW wZ. a wW wZ -> b) -> RL a wX wY -> [b]
mapFL_FL :: (forall wW wY. a wW wY -> b wW wY) -> FL a wX wZ -> FL b wX wZ
mapRL_RL :: (forall wW wY. a wW wY -> b wW wY) -> RL a wX wZ -> RL b wX wZ

-- | The "natural" fold over an <a>FL</a> i.e. associating to the right.
--   Like <a>foldr</a> only with the more useful order of arguments.
foldrFL :: (forall wA wB. p wA wB -> r -> r) -> FL p wX wY -> r -> r

-- | The "natural" fold over an RL i.e. associating to the left.
foldlRL :: (forall wA wB. r -> p wA wB -> r) -> r -> RL p wX wY -> r

-- | Right associative fold for <a>FL</a>s that transforms a witnessed
--   state in the direction opposite to the <a>FL</a>. This is the
--   "natural" fold for <a>FL</a>s i.e. the one which replaces the
--   <a>:&gt;:</a> with the passed operator.
foldrwFL :: (forall wA wB. p wA wB -> r wB -> r wA) -> FL p wX wY -> r wY -> r wX

-- | The analog of <a>foldrwFL</a> for <a>RL</a>s. This is the "natural"
--   fold for <a>RL</a>s i.e. the one which replaces the <a>:&lt;:</a> with
--   the (flipped) passed operator.
foldlwRL :: (forall wA wB. p wA wB -> r wA -> r wB) -> RL p wX wY -> r wX -> r wY

-- | Strict left associative fold for <a>FL</a>s that transforms a
--   witnessed state in the direction of the patches. This is for
--   apply-like functions that transform the witnesses in forward
--   direction.
foldlwFL :: (forall wA wB. p wA wB -> r wA -> r wB) -> FL p wX wY -> r wX -> r wY

-- | Strict right associative fold for <a>RL</a>s that transforms a
--   witnessed state in the opposite direction of the patches. This is for
--   unapply-like functions that transform the witnesses in backward
--   direction.
foldrwRL :: (forall wA wB. p wA wB -> r wB -> r wA) -> RL p wX wY -> r wY -> r wX
allFL :: (forall wX wY. a wX wY -> Bool) -> FL a wW wZ -> Bool
allRL :: (forall wA wB. a wA wB -> Bool) -> RL a wX wY -> Bool
anyFL :: (forall wX wY. a wX wY -> Bool) -> FL a wW wZ -> Bool
anyRL :: (forall wA wB. a wA wB -> Bool) -> RL a wX wY -> Bool
filterFL :: (forall wX wY. a wX wY -> Bool) -> FL a wW wZ -> [Sealed2 a]
filterRL :: (forall wX wY. p wX wY -> Bool) -> RL p wA wB -> [Sealed2 p]

-- | Monadic fold over an <a>FL</a> associating to the left, sequencing
--   effects from left to right. The order of arguments follows the
--   standard <tt>foldM</tt> from base.
foldFL_M :: Monad m => (forall wA wB. r wA -> p wA wB -> m (r wB)) -> r wX -> FL p wX wY -> m (r wY)

-- | Monadic fold over an <a>FL</a> associating to the right, sequencing
--   effects from right to left. Mostly useful for prepend-like operations
--   with an effect where the order of effects is not relevant.
foldRL_M :: Monad m => (forall wA wB. p wA wB -> r wB -> m (r wA)) -> RL p wX wY -> r wY -> m (r wX)
splitAtFL :: Int -> FL a wX wZ -> (FL a :> FL a) wX wZ
splitAtRL :: Int -> RL a wX wZ -> (RL a :> RL a) wX wZ

-- | <tt>filterOutFLFL p xs</tt> deletes any <tt>x</tt> in <tt>xs</tt> for
--   which <tt>p x == IsEq</tt> (indicating that <tt>x</tt> has no effect
--   as far as we are concerned, and can be safely removed from the chain)
filterOutFLFL :: (forall wX wY. p wX wY -> EqCheck wX wY) -> FL p wW wZ -> FL p wW wZ
filterOutRLRL :: (forall wX wY. p wX wY -> EqCheck wX wY) -> RL p wW wZ -> RL p wW wZ
reverseFL :: FL a wX wZ -> RL a wX wZ
reverseRL :: RL a wX wZ -> FL a wX wZ

-- | Concatenate two <a>FL</a>s. This traverses only the left hand side.
(+>+) :: FL a wX wY -> FL a wY wZ -> FL a wX wZ
infixr 5 +>+

-- | Concatenate two <a>RL</a>s. This traverses only the right hand side.
(+<+) :: RL a wX wY -> RL a wY wZ -> RL a wX wZ
infixl 5 +<+

-- | Prepend an <a>RL</a> to an <a>FL</a>. This traverses only the left
--   hand side.
(+>>+) :: RL p wX wY -> FL p wY wZ -> FL p wX wZ
infixr 5 +>>+

-- | Append an <a>FL</a> to an <a>RL</a>. This traverses only the right
--   hand side.
(+<<+) :: RL p wX wY -> FL p wY wZ -> RL p wX wZ
infixl 5 +<<+
concatFL :: FL (FL a) wX wZ -> FL a wX wZ
concatRL :: RL (RL a) wX wZ -> RL a wX wZ
dropWhileFL :: (forall wX wY. a wX wY -> Bool) -> FL a wR wV -> FlippedSeal (FL a) wV
dropWhileRL :: (forall wX wY. a wX wY -> Bool) -> RL a wR wV -> Sealed (RL a wR)
bunchFL :: Int -> FL a wX wY -> FL (FL a) wX wY
spanFL :: (forall wW wY. a wW wY -> Bool) -> FL a wX wZ -> (FL a :> FL a) wX wZ
spanFL_M :: forall a m wX wZ. Monad m => (forall wW wY. a wW wY -> m Bool) -> FL a wX wZ -> m ((FL a :> FL a) wX wZ)
zipWithFL :: (forall wX wY. a -> p wX wY -> q wX wY) -> [a] -> FL p wW wZ -> FL q wW wZ
consGapFL :: Gap w => (forall wX wY. p wX wY) -> w (FL p) -> w (FL p)
concatGapsFL :: Gap w => [w (FL p)] -> w (FL p)
joinGapsFL :: Gap w => [w p] -> w (FL p)
mapFL_FL_M :: Monad m => (forall wW wY. a wW wY -> m (b wW wY)) -> FL a wX wZ -> m (FL b wX wZ)
sequenceFL_ :: Monad m => (forall wW wZ. a wW wZ -> m b) -> FL a wX wY -> m ()
initsFL :: FL p wX wY -> [Sealed ((p :> FL p) wX)]
isShorterThanRL :: RL a wX wY -> Int -> Bool

-- | Like <a>span</a> only for <a>RL</a>s. This function is supposed to be
--   lazy: elements before the split point should not be touched.
spanRL :: (forall wA wB. p wA wB -> Bool) -> RL p wX wY -> (RL p :> RL p) wX wY

-- | Like <a>break</a> only for <a>RL</a>s. This function is supposed to be
--   lazy: elements before the split point should not be touched.
breakRL :: (forall wA wB. p wA wB -> Bool) -> RL p wX wY -> (RL p :> RL p) wX wY

-- | Like <a>takeWhile</a> only for <a>RL</a>s. This function is supposed
--   to be lazy: elements before the split point should not be touched.
takeWhileRL :: (forall wA wB. a wA wB -> Bool) -> RL a wX wY -> FlippedSeal (RL a) wY
concatRLFL :: RL (FL p) wX wY -> RL p wX wY
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => GHC.Show.Show ((Darcs.Patch.Witnesses.Ordered.:/\:) a b wX wY)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => Darcs.Patch.Witnesses.Show.Show2 (a Darcs.Patch.Witnesses.Ordered.:/\: b)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => GHC.Show.Show ((Darcs.Patch.Witnesses.Ordered.:\/:) a b wX wY)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => Darcs.Patch.Witnesses.Show.Show2 (a Darcs.Patch.Witnesses.Ordered.:\/: b)
instance Darcs.Patch.Witnesses.Show.Show2 a => GHC.Show.Show (Darcs.Patch.Witnesses.Ordered.RL a wX wZ)
instance Darcs.Patch.Witnesses.Show.Show2 a => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Witnesses.Ordered.RL a wX)
instance Darcs.Patch.Witnesses.Show.Show2 a => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Witnesses.Ordered.RL a)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Witnesses.Ordered.RL p)
instance Darcs.Patch.Witnesses.Show.Show2 a => GHC.Show.Show (Darcs.Patch.Witnesses.Ordered.FL a wX wZ)
instance Darcs.Patch.Witnesses.Show.Show2 a => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Witnesses.Ordered.FL a wX)
instance Darcs.Patch.Witnesses.Show.Show2 a => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Witnesses.Ordered.FL a)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Witnesses.Ordered.FL p)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => Darcs.Patch.Witnesses.Show.Show1 ((Darcs.Patch.Witnesses.Ordered.:>) a b wX)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => GHC.Show.Show ((Darcs.Patch.Witnesses.Ordered.:>) a b wX wY)
instance (Darcs.Patch.Witnesses.Eq.Eq2 a, Darcs.Patch.Witnesses.Eq.Eq2 b) => Darcs.Patch.Witnesses.Eq.Eq2 (a Darcs.Patch.Witnesses.Ordered.:> b)
instance (Darcs.Patch.Witnesses.Eq.Eq2 a, Darcs.Patch.Witnesses.Eq.Eq2 b) => GHC.Classes.Eq ((Darcs.Patch.Witnesses.Ordered.:>) a b wX wY)
instance (Darcs.Patch.Witnesses.Show.Show2 a, Darcs.Patch.Witnesses.Show.Show2 b) => Darcs.Patch.Witnesses.Show.Show2 (a Darcs.Patch.Witnesses.Ordered.:> b)

module Darcs.Patch.Witnesses.WZipper
data FZipper a wX wZ
[FZipper] :: RL a wX wY -> FL a wY wZ -> FZipper a wX wZ
focus :: FZipper a wX wY -> Maybe (Sealed2 a)
leftmost :: FZipper p wX wY -> Bool
left :: FZipper p wX wY -> FZipper p wX wY
rightmost :: FZipper p wX wY -> Bool
right :: FZipper p wX wY -> FZipper p wX wY

-- | See <a>clowns</a>
jokers :: FZipper a wX wY -> FlippedSeal (FL a) wY

-- | "Clowns to the left of me, jokers to the right. Here I am, stuck in
--   the middle of you"
--   <a>http://en.wikipedia.org/wiki/Stuck_in_the_Middle</a>
clowns :: FZipper a wX wY -> Sealed (RL a wX)
flToZipper :: FL a wX wY -> FZipper a wX wY
lengthFZ :: FZipper a wX wY -> Int
nullFZ :: FZipper a wX wY -> Bool
toEnd :: FZipper p wX wY -> FZipper p wX wY
toStart :: FZipper p wX wY -> FZipper p wX wY

module Darcs.Patch.Witnesses.Maybe
data Maybe2 p wX wY
[Nothing2] :: Maybe2 p wX wX
[Just2] :: p wX wY -> Maybe2 p wX wY
maybeToFL :: Maybe2 p wX wY -> FL p wX wY
maybeToRL :: Maybe2 p wX wY -> RL p wX wY
mapMB_MB :: (p wX wY -> q wX wY) -> Maybe2 p wX wY -> Maybe2 q wX wY

module Darcs.Patch.Rebase.PushFixup

-- | During a rebase, we use "fixup" patches to maintain the correct
--   context for the real "items" that are being stored in the rebase that
--   the user wants to keep. As the context of the rebase changes, new
--   fixups get added to the beginning that then need to be pushed past as
--   many items as possible.
--   
--   There are multiple fixup types and multiple ways of representing the
--   items being stored in the rebase, so this is polymorphic in both
--   types. Also, the structure of the results varies - in some cases it
--   will be a single value, sometimes an FL, or sometimes zero or one
--   values (Maybe2), so the output types are separate variables. A typical
--   instantiation would be something like PushFixupFn Fixup Item (FL Item)
--   (FL Fixup).
type PushFixupFn fixupIn itemIn itemOut fixupOut = forall wX wY. (fixupIn :> itemIn) wX wY -> (itemOut :> fixupOut) wX wY
dropFixups :: (item :> fixup) wX wY -> Sealed (item wX)
pushFixupFLFL_FLFLFL :: PushFixupFn fixup item (FL item) (FL fixup) -> PushFixupFn fixup (FL item) (FL item) (FL fixup)
pushFixupFLFL_FLFLFLFL :: PushFixupFn fixup item (FL item) (FL fixup) -> PushFixupFn (FL fixup) (FL item) (FL item) (FL fixup)
pushFixupFLMB_FLFLMB :: PushFixupFn fixup item (FL item) (Maybe2 fixup) -> PushFixupFn fixup (FL item) (FL item) (Maybe2 fixup)
pushFixupIdFL_FLFLFL :: PushFixupFn fixup item item (FL fixup) -> PushFixupFn fixup (FL item) (FL item) (FL fixup)
pushFixupIdMB_FLFLMB :: PushFixupFn fixup item item (Maybe2 fixup) -> PushFixupFn fixup (FL item) (FL item) (Maybe2 fixup)
pushFixupIdMB_FLIdFLFL :: PushFixupFn fixup item item (Maybe2 fixup) -> PushFixupFn (FL fixup) item item (FL fixup)

module Darcs.Patch.Invert

-- | The <a>invert</a> operation must be self-inverse, i.e. an involution:
--   
--   <pre>
--   invert . invert = id
--   </pre>
class Invert p
invert :: Invert p => p wX wY -> p wY wX
invertFL :: Invert p => FL p wX wY -> RL p wY wX
invertRL :: Invert p => RL p wX wY -> FL p wY wX
instance Darcs.Patch.Invert.Invert p => Darcs.Patch.Invert.Invert (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Invert.Invert p => Darcs.Patch.Invert.Invert (Darcs.Patch.Witnesses.Ordered.RL p)
instance Darcs.Patch.Invert.Invert p => Darcs.Patch.Invert.Invert (p Darcs.Patch.Witnesses.Ordered.:> p)

module Darcs.Patch.Debug

-- | PatchDebug is a hook class for temporarily adding debug information.
--   To use it, add any methods that are required, implement those methods
--   where needed, and then make it available in the relevant contexts. For
--   example it can be temporarily added as a superclass of
--   <tt>Patchy</tt>. The advantage of having it here already is that
--   everything is (or should be) declared as an instance of it, so you can
--   use defaulting or just leave out declarations of instance methods and
--   code will still compile.
class PatchDebug p

-- | A dummy method so we can export/import PatchDebug(..) without
--   triggering warnings
patchDebugDummy :: PatchDebug p => p wX wY -> ()
instance Darcs.Patch.Debug.PatchDebug p => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Debug.PatchDebug p => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.CommuteFn

-- | CommuteFn is the basis of a general framework for building up
--   commutation operations between different patch types in a generic
--   manner. Unfortunately type classes are not well suited to the problem
--   because of the multiple possible routes by which the commuter for (FL
--   p1, FL p2) can be built out of the commuter for (p1, p2) - and more
--   complicated problems when we start building multiple constructors on
--   top of each other. The type class resolution machinery really can't
--   cope with selecting some route, because it doesn't know that all
--   possible routes should be equivalent.
--   
--   Note that a CommuteFn cannot be lazy i.e. commute patches only when
--   the resulting sequences are demanded. This is because of the
--   possibility of failure (<a>Nothing</a>): all the commutes must be
--   performed before we can know whether the overall commute succeeds.
type CommuteFn p1 p2 = forall wX wY. (p1 :> p2) wX wY -> Maybe ((p2 :> p1) wX wY)
commuterIdFL :: CommuteFn p1 p2 -> CommuteFn p1 (FL p2)
commuterFLId :: CommuteFn p1 p2 -> CommuteFn (FL p1) p2
commuterIdRL :: CommuteFn p1 p2 -> CommuteFn p1 (RL p2)
commuterRLId :: CommuteFn p1 p2 -> CommuteFn (RL p1) p2
commuterRLFL :: forall p1 p2. CommuteFn p1 p2 -> CommuteFn (RL p1) (FL p2)
type MergeFn p1 p2 = forall wX wY. (p1 :\/: p2) wX wY -> (p2 :/\: p1) wX wY
type PartialMergeFn p1 p2 = forall wX wY. (p1 :\/: p2) wX wY -> Maybe ((p2 :/\: p1) wX wY)

-- | TODO document laziness or lack thereof
mergerIdFL :: MergeFn p1 p2 -> MergeFn p1 (FL p2)
type TotalCommuteFn p1 p2 = forall wX wY. (p1 :> p2) wX wY -> (p2 :> p1) wX wY

-- | TODO document laziness or lack thereof
totalCommuterIdFL :: TotalCommuteFn p1 p2 -> TotalCommuteFn p1 (FL p2)

-- | TODO document laziness or lack thereof
totalCommuterFLId :: TotalCommuteFn p1 p2 -> TotalCommuteFn (FL p1) p2

-- | TODO document laziness or lack thereof
totalCommuterFLFL :: TotalCommuteFn p1 p2 -> TotalCommuteFn (FL p1) (FL p2)

-- | Make use of the inverse-commute law to reduce the number of cases when
--   defining commute for complicated patch types.
invertCommuter :: (Invert p, Invert q) => CommuteFn p q -> CommuteFn q p

module Darcs.Patch.Commute

-- | Class of patches that that can be commuted.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li><i>commute-symmetry</i> <pre>commute (p:&gt;q) == Just (q':&gt;p')
--   &lt;=&gt; commute (q':&gt;p') == Just (p':&gt;q)</pre></li>
--   <li><i>invert-commute</i> If patches are invertible, then<pre>commute
--   (p:&gt;q) == Just (q':&gt;p') &lt;=&gt; commute (invert q:&gt;invert
--   p) == Just (invert p':&gt;invert q')</pre></li>
--   </ul>
--   
--   The more general law
--   
--   <ul>
--   <li><i>square-commute</i> <pre>commute (p:&gt;q) == Just (q':&gt;p')
--   =&gt; commute (invert p:&gt;q') == Just (q:&gt;invert p')</pre></li>
--   </ul>
--   
--   is valid in general only provided we know (a priori) that
--   <tt><a>commute</a> (<tt>invert</tt> p<a>:&gt;</a>q')</tt> succeeds, in
--   other words, that p and q are not in conflict with each other. See
--   <a>Darcs.Patch.CommuteNoConflicts</a> for an extended discussion.
class Commute p
commute :: Commute p => (p :> p) wX wY -> Maybe ((p :> p) wX wY)

-- | <a>commuteFL</a> commutes a single element past a FL.
commuteFL :: Commute p => (p :> FL p) wX wY -> Maybe ((FL p :> p) wX wY)

-- | <a>commuteRL</a> commutes a RL past a single element.
commuteRL :: Commute p => (RL p :> p) wX wY -> Maybe ((p :> RL p) wX wY)

-- | <a>commuteRLFL</a> commutes an <a>RL</a> past an <a>FL</a>.
commuteRLFL :: Commute p => (RL p :> FL p) wX wY -> Maybe ((FL p :> RL p) wX wY)

-- | Build a commuter between a patch and itself using the operation from
--   the type class.
selfCommuter :: Commute p => CommuteFn p p
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Witnesses.Ordered.RL p)


module Darcs.Patch.Merge

-- | Class of patches that can, possibly, be merged cleanly, that is,
--   without conflict.
--   
--   Every patch type can be made an instance of <a>CleanMerge</a> in a
--   trivial way by defining <tt><a>cleanMerge</a> _ = <a>Nothing</a></tt>,
--   which vacuously conforms to all required laws.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li><i><i>symmetry</i></i> <pre>cleanMerge (p :\/: q) == Just (q' :/\:
--   p') &lt;=&gt; cleanMerge (q :\/: p) == Just (p' :/\: q')</pre></li>
--   </ul>
--   
--   If an instance <tt><a>Commute</a> p</tt> exists, then we also require
--   
--   <ul>
--   <li><i><i>merge-commute</i></i> <pre>cleanMerge (p :\/: q) == Just (q'
--   :/\: p') ==&gt; commute (p :&gt; q') == Just (q :&gt; p')</pre>that
--   is, the two branches of a clean merge commute to each other.</li>
--   </ul>
--   
--   If an instance <tt><a>Invert</a> p</tt> exists, then we also require
--   
--   <ul>
--   <li><i><i>square-merge</i></i> <pre>cleanMerge (p :\/: q) == Just (q'
--   :/\: p') =&gt; cleanMerge (invert p :\/: q') == Just (q :/\: invert
--   p')</pre>Here is a picture that explains why we call this
--   <i>square-merge</i>:<pre> A---p---&gt;X A&lt;--p^---X | | | | | | | |
--   q q' =&gt; q q' | | | | v v v v Y---p'--&gt;B Y&lt;--p'^--B</pre></li>
--   </ul>
class CleanMerge p
cleanMerge :: CleanMerge p => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)

-- | Patches that can always be merged, even if they conflict.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li><i><i>symmetry</i></i> <pre>merge (p :\/: q) == q' :/\: p'
--   &lt;=&gt; merge (q :\/: p) == p' :/\: q'</pre></li>
--   <li><i><i>merge-commute</i></i> <pre>merge (p :\/: q) == q' :/\: p'
--   ==&gt; commute (p :&gt; q') == Just (q :&gt; p')</pre>that is, the two
--   branches of a merge commute to each other.</li>
--   <li><i><i>extension</i></i> <pre>cleanMerge (p :\/: q) == Just (q'
--   :/\: p') =&gt; merge (p :\/: q) == q' :/\: p'</pre>that is,
--   <a>merge</a> is an extension of <a>cleanMerge</a>.</li>
--   </ul>
class CleanMerge p => Merge p
merge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY

-- | Synonym for <a>merge</a>.
selfMerger :: Merge p => MergeFn p p

-- | Swap the two patches, apply an arbitrary merge function, then swap
--   again.
swapMerger :: MergeFn p q -> MergeFn q p

-- | Lift a merge function over <tt>p :/: q</tt> to a merge function over
--   <tt>p :/: FL q</tt>
mergerIdFL :: MergeFn p q -> MergeFn p (FL q)

-- | Lift a merge function over <tt>p :/: q</tt> to a merge function over
--   <tt>FL p :/: q</tt>
mergerFLId :: MergeFn p q -> MergeFn (FL p) q

-- | Lift a merge function over <tt>p :/: q</tt> to a merge function over
--   <tt>FL p :/: FL q</tt>
mergerFLFL :: MergeFn p q -> MergeFn (FL p) (FL q)

-- | Cleanly merge a single patch with an <a>FL</a> of patches.
cleanMergeFL :: CleanMerge p => PartialMergeFn p (FL p)
mergeFL :: Merge p => (p :\/: FL p) wX wY -> (FL p :/\: p) wX wY

-- | Swap the two patches, <a>merge</a>, then swap again. Used to exploit
--   <a>prop_mergeSymmetric</a> when defining <a>merge</a>.
swapMerge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY

-- | Swap the two patches, <a>cleanMerge</a>, then swap again. Used to
--   exploit <tt>prop_cleanMergeSymmetric</tt> when defining
--   <a>cleanMerge</a>.
swapCleanMerge :: CleanMerge p => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)

-- | Combine a list of patch sequences, all starting at the same state,
--   into a single sequence that also starts at the same state, using
--   cleanMerge. If the merge fails, we return the two sequences that could
--   not be merged so we can issue more detailed error messages.
mergeList :: CleanMerge p => [Sealed (FL p wX)] -> Either (Sealed (FL p wX), Sealed (FL p wX)) (Sealed (FL p wX))

-- | Whether the given pair of patches satisfies the <i>symmetry</i> law.
prop_mergeSymmetric :: (Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool

-- | Whether the given pair of patches satisfies the <i>merge-commute</i>
--   law.
prop_mergeCommute :: (Commute p, Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool
instance Darcs.Patch.Merge.Merge p => Darcs.Patch.Merge.Merge (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Merge.CleanMerge p => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.Witnesses.Ordered.FL p)

module Darcs.Patch.Permutations

-- | <a>removeFL</a> <tt>x xs</tt> removes <tt>x</tt> from <tt>xs</tt> if
--   <tt>x</tt> can be commuted to its head. Otherwise it returns
--   <a>Nothing</a>
removeFL :: (Eq2 p, Commute p) => p wX wY -> FL p wX wZ -> Maybe (FL p wY wZ)

-- | <a>removeRL</a> is like <a>removeFL</a> except with <a>RL</a>
removeRL :: (Eq2 p, Commute p) => p wY wZ -> RL p wX wZ -> Maybe (RL p wX wY)
removeCommon :: (Eq2 p, Commute p) => (FL p :\/: FL p) wX wY -> (FL p :\/: FL p) wX wY
commuteWhatWeCanFL :: Commute p => (p :> FL p) wX wY -> (FL p :> (p :> FL p)) wX wY
commuteWhatWeCanRL :: Commute p => (RL p :> p) wX wY -> (RL p :> (p :> RL p)) wX wY
genCommuteWhatWeCanRL :: Commute p => CommuteFn p q -> (RL p :> q) wX wY -> (RL p :> (q :> RL p)) wX wY
genCommuteWhatWeCanFL :: Commute q => CommuteFn p q -> (p :> FL q) wX wY -> (FL q :> (p :> FL q)) wX wY

-- | Split an <a>FL</a> according to a predicate, using commutation as
--   necessary, into those that satisfy the predicate and can be commuted
--   to the left, and those that do not satisfy it and can be commuted to
--   the right. Whatever remains stays in the middle.
--   
--   Note that the predicate <tt>p</tt> should be invariant under
--   commutation: if <tt>commute(x:&gt;y)==Just(y':&gt;x')</tt> then <tt>p
--   x == p x' &amp;&amp; p y == p y'</tt>.
partitionFL :: Commute p => (forall wU wV. p wU wV -> Bool) -> FL p wX wY -> (FL p :> (FL p :> FL p)) wX wY

-- | Split an <a>RL</a> according to a predicate, using commutation as
--   necessary, into those that satisfy the predicate and can be commuted
--   to the right, and those that don't, i.e. either do not satisfy the
--   predicate or cannot be commuted to the right.
--   
--   Note that the predicate <tt>p</tt> should be invariant under
--   commutation: if <tt>commute(x:&gt;y)==Just(y':&gt;x')</tt> then <tt>p
--   x == p x' &amp;&amp; p y == p y'</tt>.
partitionRL :: forall p wX wY. Commute p => (forall wU wV. p wU wV -> Bool) -> RL p wX wY -> (RL p :> RL p) wX wY
partitionFL' :: Commute p => (forall wU wV. p wU wV -> Bool) -> RL p wA wB -> RL p wB wC -> FL p wC wD -> (FL p :> (RL p :> RL p)) wA wD

-- | Split an <a>RL</a> according to a predicate, using commutation as
--   necessary, into those that satisfy the predicate and can be commuted
--   to the right, and those that do not satisfy it and can be commuted to
--   the left. Whatever remains stays in the middle.
--   
--   Note that the predicate <tt>p</tt> should be invariant under
--   commutation: if <tt>commute(x:&gt;y)==Just(y':&gt;x')</tt> then <tt>p
--   x == p x' &amp;&amp; p y == p y'</tt>.
partitionRL' :: forall p wX wY. Commute p => (forall wU wV. p wU wV -> Bool) -> RL p wX wY -> (FL p :> (FL p :> RL p)) wX wY

-- | This is a minor variant of <a>headPermutationsFL</a> with each
--   permutation is simply returned as a <a>FL</a>
simpleHeadPermutationsFL :: Commute p => FL p wX wY -> [FL p wX wY]

-- | <a>headPermutationsRL</a> is like <a>headPermutationsFL</a>, except
--   that we operate on an <a>RL</a> (in other words, we are pushing things
--   to the end of a patch sequence instead of to the beginning).
headPermutationsRL :: Commute p => RL p wX wY -> [RL p wX wY]

-- | <a>headPermutationsFL</a> <tt>p:&gt;:ps</tt> returns all the
--   permutations of the list in which one element of <tt>ps</tt> is
--   commuted past <tt>p</tt>
--   
--   Suppose we have a sequence of patches
--   
--   <pre>
--   X h a y s-t-c k
--   </pre>
--   
--   Suppose furthermore that the patch <tt>c</tt> depends on <tt>t</tt>,
--   which in turn depends on <tt>s</tt>. This function will return
--   
--   <pre>
--   X :&gt; h a y s t c k
--   h :&gt; X a y s t c k
--   a :&gt; X h y s t c k
--   y :&gt; X h a s t c k
--   s :&gt; X h a y t c k
--   k :&gt; X h a y s t c
--   </pre>
headPermutationsFL :: Commute p => FL p wX wY -> [(p :> FL p) wX wY]

-- | All permutations of an <a>RL</a>.
permutationsRL :: Commute p => RL p wX wY -> [RL p wX wY]

-- | <a>removeSubsequenceFL</a> <tt>ab abc</tt> returns <tt>Just c'</tt>
--   where all the patches in <tt>ab</tt> have been commuted out of it, if
--   possible. If this is not possible for any reason (the set of patches
--   <tt>ab</tt> is not actually a subset of <tt>abc</tt>, or they can't be
--   commuted out) we return <a>Nothing</a>.
removeSubsequenceFL :: (Eq2 p, Commute p) => FL p wA wB -> FL p wA wC -> Maybe (FL p wB wC)

-- | <a>removeSubsequenceRL</a> is like <tt>removeSubsequenceFL</tt> except
--   that it works on <a>RL</a>
removeSubsequenceRL :: (Eq2 p, Commute p) => RL p wAb wAbc -> RL p wA wAbc -> Maybe (RL p wA wAb)

-- | Partition a list into the patches that merge cleanly with the given
--   patch and those that don't (including dependencies)
partitionConflictingFL :: forall p wX wY wZ. (Commute p, CleanMerge p) => FL p wX wY -> FL p wX wZ -> (FL p :> FL p) wX wY

-- | This commutes patches in the RHS to bring them into the same order as
--   the LHS.
(=\~/=) :: forall p wA wB wC. (Commute p, Eq2 p) => FL p wA wB -> FL p wA wC -> EqCheck wB wC

-- | This commutes patches in the RHS to bring them into the same order as
--   the LHS.
(=/~\=) :: forall p wA wB wC. (Commute p, Eq2 p) => RL p wA wC -> RL p wB wC -> EqCheck wA wB

-- | A variant of <tt>nub</tt> that is based on '=~/= i.e. ignores
--   (internal) ordering.
nubFL :: (Commute p, Eq2 p) => [Sealed (FL p wX)] -> [Sealed (FL p wX)]

module Darcs.Patch.CommuteNoConflicts

-- | It is natural to think of conflicting patches <tt>p</tt> and
--   <tt>q</tt> as a parallel pair <tt>(p<a>:\/:</a>q)</tt> because this is
--   how conflicting patches arise. But then Darcs comes along and merges
--   them anyway by converting one of them to a conflictor. Thus, inside a
--   sequence of patches we may see them as a sequential pair <tt>(p
--   <a>:&gt;</a> q')</tt>. In that case, <a>commute</a> will always
--   succeed, as expressed by the merge-commute law.
--   <a>commuteNoConflicts</a> is a restricted version of <a>commute</a>
--   that should fail in this case but otherwise give the same result as
--   <a>commute</a>.
--   
--   Primitive patch types have no conflictors, so for them we have
--   <tt><a>commute</a> == <a>commuteNoConflicts</a></tt>.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li>Symmetry<pre>commuteNoConflicts (p:&gt;q) == Just (q':&gt;p')
--   &lt;=&gt; commuteNoConflicts (q':&gt;p') == Just (p':&gt;q)</pre></li>
--   <li>Square-Commute (if an instance <tt><a>Invert</a> p</tt>
--   exists)<pre>commuteNoConflicts (p:&gt;q) == Just (q':&gt;p') =&gt;
--   commuteNoConflicts (invert p:&gt;q') == Just (q:&gt;invert
--   p')</pre></li>
--   <li><a>commuteNoConflicts</a> is a restriction of
--   <a>commute</a><pre>commuteNoConflicts (p:&gt;q) == Just r =&gt;
--   commute (p:&gt;q) == Just r</pre></li>
--   </ul>
class Commute p => CommuteNoConflicts p

-- | An alternative to <a>commute</a> to be used if correctness of your
--   code depends on the validity of the square-commute law, or to
--   determine whether patches are in conflict. A parallel pair of patches
--   <tt>p<a>:\/:</a>q</tt> is conflicting if and only if
--   <tt><a>commuteNoConflicts</a>(p^<a>:&gt;</a>q)</tt> fails. Its main
--   use is so that we can define <a>mergeNoConflicts</a> cleanly.
commuteNoConflicts :: CommuteNoConflicts p => (p :> p) wX wY -> Maybe ((p :> p) wX wY)

-- | The non-conflicting merge of <tt>(p<a>:\/:</a>q)</tt> tries to commute
--   the inverse <tt>p^</tt> of <tt>p</tt> with <tt>q</tt>. If it succeeds
--   then the part of the result that corresponds to <tt>p^</tt> is
--   re-inverted. This is also known as a "clean merge".
--   
--   Note that to maintain consistency in the presence of conflictors we
--   must use use <a>commuteNoConflicts</a> here and not <a>commute</a>.
--   Otherwise we run into contradictions as explained below.
--   
--   Concretely, suppose we use <a>commute</a> here and that <tt>q</tt> is
--   a conflictor that represents the primitive patch <tt>r</tt> and
--   conflicts (only) with (primitive patch) <tt>p^</tt>. That is,
--   <tt>q</tt> results from the conflicted
--   <tt>merge(r<a>:\/:</a>p^)=(s<a>:/\:</a>q)</tt>, where <tt>s</tt> is
--   another conflictor. Now, according to merge-commute we get
--   <tt>commute(p^<a>:&gt;</a>q)=Just(r<a>:&gt;</a>s)</tt>, and thus
--   <tt>mergeNoConflict(p<a>:\/:</a>q)=Just(s^<a>:/\:</a>r)</tt> in
--   contradiction to our assumption that <tt>(p^<a>:\/:</a>q</tt> are in
--   conflict i.e. <tt>mergeNoConflict(p^<a>:\/:</a>q)</tt> fails. (This
--   argument takes for granted that the addition of conflictors to prim
--   patches preserves their commute behavior. This is not yet stated as a
--   law but all implementations obviously adhere to it.)
--   
--   As a side note, the fact that we now get an inverse conflictor
--   <tt>s^</tt> as part of the result leads to further problems. For
--   instance, whether our repo is conflicted now depends on the order of
--   patches: <tt>(p<a>:&gt;</a>r)</tt> is not conflicted, but its commute
--   <tt>(q<a>:&gt;</a>s^)</tt> obviously is. In fact,
--   <tt>(q<a>:&gt;</a>s^)</tt> is nothing else but the
--   (identity-preserving) "force-commute" of <tt>(p<a>:&gt;</a>r)</tt>,
--   see the thread at
--   <a>https://lists.osuosl.org/pipermail/darcs-devel/2017-November/018403.html</a>.
mergeNoConflicts :: (Invert p, CommuteNoConflicts p) => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)


-- | Path resolving:
--   
--   <ul>
--   <li>An http URL contains the sequence <tt>"http(s)://"</tt>.</li>
--   <li>A local filepath does not contain colons, except as second
--   character (windows drives) when this filepath is meant to be used as
--   repository name</li>
--   <li>A path that is neither an http URL nor a local file is an
--   ssh-path.</li>
--   </ul>
--   
--   Examples:
--   
--   <pre>
--   /usr/repo/foo                 -- local file
--   c:/src/darcs                  -- local file
--   http://darcs.net/             -- URL
--   peter@host:/path              -- ssh
--   droundy@host:                 -- ssh
--   host:/path                    -- ssh
--   </pre>
--   
--   This means that single-letter hosts in ssh-paths do not work, unless a
--   username is provided.
--   
--   Perhaps ssh-paths should use <tt>"ssh://user@host/path"</tt>-syntax
--   instead?
--   
--   TODO: This whole module should be re-written using a regex matching
--   library! The way we do this here is error-prone and inefficient.
module Darcs.Util.URL
isValidLocalPath :: String -> Bool
isHttpUrl :: String -> Bool
isSshUrl :: String -> Bool
isRelative :: String -> Bool
isAbsolute :: String -> Bool
isSshNopath :: String -> Bool
data SshFilePath
sshRepo :: SshFilePath -> String
sshUhost :: SshFilePath -> String
sshFile :: SshFilePath -> String
sshFilePathOf :: SshFilePath -> String

-- | Given an ssh URL or file path, split it into user@host, repodir, and
--   the file (with any _darcs/ prefix removed)
splitSshUrl :: String -> SshFilePath

-- | Return a canonical representation of an SSH repo in the format
--   uhost:path Notably, this means the returned string does not contain: -
--   an "ssh://" prefix - any redundant slashes (including all trailing
--   ones)
sshCanonRepo :: SshFilePath -> String

module Darcs.Util.ValidHash

-- | External API for the various hash types.
class (Eq h, IsSizeHash h) => ValidHash h

-- | The <a>HashedDir</a> belonging to this type of hash
dirofValidHash :: ValidHash h => h -> HashedDir

-- | Compute hash from file content.
calcValidHash :: ValidHash h => ByteString -> h
data InventoryHash
data PatchHash
data PristineHash

-- | Semantically, this is the type of hashed objects. Git has a type tag
--   inside the hashed file itself, whereas in Darcs the type is determined
--   by the subdirectory.
data HashedDir
HashedPristineDir :: HashedDir
HashedPatchesDir :: HashedDir
HashedInventoriesDir :: HashedDir
encodeValidHash :: ValidHash h => h -> String
decodeValidHash :: ValidHash h => String -> Maybe h
parseValidHash :: ValidHash h => Parser h
getHash :: ValidHash h => h -> Hash
getSize :: ValidHash h => h -> Maybe Int
fromHash :: ValidHash h => Hash -> h
fromSizeAndHash :: ValidHash h => Int -> Hash -> h

-- | Verify file content against a given <a>ValidHash</a>.
checkHash :: ValidHash h => h -> ByteString -> Bool

-- | Check that the given <a>String</a> is an encoding of some
--   <a>ValidHash</a>.
okayHash :: String -> Bool
instance GHC.Classes.Eq Darcs.Util.ValidHash.HashedDir
instance GHC.Show.Show Darcs.Util.ValidHash.SizeHash
instance GHC.Classes.Eq Darcs.Util.ValidHash.SizeHash
instance Darcs.Util.ValidHash.IsSizeHash Darcs.Util.ValidHash.PristineHash
instance GHC.Show.Show Darcs.Util.ValidHash.PristineHash
instance GHC.Classes.Eq Darcs.Util.ValidHash.PristineHash
instance Darcs.Util.ValidHash.IsSizeHash Darcs.Util.ValidHash.PatchHash
instance GHC.Show.Show Darcs.Util.ValidHash.PatchHash
instance GHC.Classes.Eq Darcs.Util.ValidHash.PatchHash
instance Darcs.Util.ValidHash.IsSizeHash Darcs.Util.ValidHash.InventoryHash
instance GHC.Show.Show Darcs.Util.ValidHash.InventoryHash
instance GHC.Classes.Eq Darcs.Util.ValidHash.InventoryHash
instance Darcs.Util.ValidHash.ValidHash Darcs.Util.ValidHash.InventoryHash
instance Darcs.Util.ValidHash.ValidHash Darcs.Util.ValidHash.PatchHash
instance Darcs.Util.ValidHash.ValidHash Darcs.Util.ValidHash.PristineHash
instance Darcs.Util.ValidHash.IsSizeHash Darcs.Util.ValidHash.SizeHash


module Darcs.Util.Workaround
setExecutable :: FilePath -> Bool -> IO ()
getCurrentDirectory :: IO FilePath
installHandler :: Signal -> Handler -> Maybe SignalSet -> IO Handler
raiseSignal :: Signal -> IO ()
data () => Handler
Default :: Handler
Ignore :: Handler
Catch :: IO () -> Handler
CatchOnce :: IO () -> Handler
CatchInfo :: (SignalInfo -> IO ()) -> Handler
CatchInfoOnce :: (SignalInfo -> IO ()) -> Handler
type Signal = CInt
sigINT :: CInt
sigHUP :: CInt
sigABRT :: CInt
sigALRM :: CInt
sigTERM :: CInt
sigPIPE :: CInt

module Darcs.Util.SignalHandler
withSignalsHandled :: IO a -> IO a
withSignalsBlocked :: IO a -> IO a
catchInterrupt :: IO a -> IO a -> IO a

-- | A drop-in replacement for <a>catch</a>, which allows us to catch
--   anything but a signal. Useful for situations where we don't want to
--   inhibit ctrl-C.
catchNonSignal :: IO a -> (SomeException -> IO a) -> IO a
tryNonSignal :: IO a -> IO (Either SomeException a)
stdoutIsAPipe :: IO Bool
instance GHC.Show.Show Darcs.Util.SignalHandler.SignalException
instance GHC.Exception.Type.Exception Darcs.Util.SignalHandler.SignalException

module Darcs.Util.Exception

-- | The firstJustIO is a slight modification to firstJustM: the entries in
--   the list must be IO monad operations and the firstJustIO will silently
--   turn any monad call that throws an exception into Nothing, basically
--   causing it to be ignored.
firstJustIO :: [IO (Maybe a)] -> IO (Maybe a)
catchall :: IO a -> IO a -> IO a
clarifyErrors :: IO a -> String -> IO a
prettyException :: SomeException -> String
prettyError :: IOError -> String

-- | Terminate the program with an error message.
die :: String -> IO a

-- | Handle only a those exceptions for which the predicate succeeds.
handleOnly :: Exception e => (e -> Bool) -> IO a -> IO a -> IO a

-- | Handle only actual IO exceptions i.e. not "user errors" e.g. those
--   raised by calling <a>fail</a>.
--   
--   We use <a>fail</a> all over the place to signify erroneous conditions
--   and we normally don't want to handle such errors.
handleOnlyIOError :: IO a -> IO a -> IO a

-- | Handle only non-existence.
catchDoesNotExistError :: IO a -> IO a -> IO a

-- | Handle only non-existence.
handleDoesNotExistError :: IO a -> IO a -> IO a

-- | Like <a>handleOnlyIOError</a> but restricted to returning a given
--   value.
ifIOError :: a -> IO a -> IO a

-- | Like <a>ifIOError</a> but restricted to handling non-existence.
ifDoesNotExistError :: a -> IO a -> IO a

module Darcs.Util.Ssh
data SshSettings
SshSettings :: String -> String -> String -> SshSettings
[ssh] :: SshSettings -> String
[scp] :: SshSettings -> String
[sftp] :: SshSettings -> String
defaultSsh :: SshSettings
windows :: Bool
copySSH :: String -> SshFilePath -> FilePath -> IO ()
data SSHCmd
SSH :: SSHCmd
SCP :: SSHCmd
SFTP :: SSHCmd

-- | Return the command and arguments needed to run an ssh command First
--   try the appropriate darcs environment variable and SSH_PORT defaulting
--   to "ssh" and no specified port.
getSSH :: SSHCmd -> IO (String, [String])
environmentHelpSsh :: ([String], [String])
environmentHelpScp :: ([String], [String])
environmentHelpSshPort :: ([String], [String])
transferModeHeader :: String

-- | Terminate all child processes that run a remote "darcs transfer-mode"
--   and remove them from the <a>sshConnections</a>, causing subsequent
--   <a>copySSH</a> calls to start a fresh child.
resetSshConnections :: IO ()
instance GHC.Classes.Eq Darcs.Util.Ssh.SshSettings
instance GHC.Show.Show Darcs.Util.Ssh.SshSettings

module Darcs.Util.Compat
stdoutIsAPipe :: IO Bool
maybeRelink :: String -> String -> IO Bool
atomicCreate :: FilePath -> IO ()
sloppyAtomicCreate :: FilePath -> IO ()

module Darcs.Util.Path

-- | <a>encodeWhite</a> translates whitespace in filenames to a
--   darcs-specific format (numerical representation according to
--   <a>ord</a> surrounded by backslashes). Note that backslashes are also
--   escaped since they are used in the encoding.
--   
--   <pre>
--   encodeWhite "hello there" == "hello\32\there"
--   encodeWhite "hello\there" == "hello\92\there"
--   </pre>
encodeWhite :: FilePath -> String

-- | <a>decodeWhite</a> interprets the Darcs-specific "encoded" filenames
--   produced by <a>encodeWhite</a>
--   
--   <pre>
--   decodeWhite "hello\32\there"  == Right "hello there"
--   decodeWhite "hello\92\there"  == Right "hello\there"
--   decodeWhite "hello\there"   == Left "malformed filename"
--   </pre>
decodeWhite :: String -> Either String FilePath
encodeWhiteName :: Name -> ByteString
decodeWhiteName :: ByteString -> Either String Name
data AbsolutePath

-- | Take an absolute path and a string representing a (possibly relative)
--   path and combine them into an absolute path. If the second argument is
--   already absolute, then the first argument gets ignored. This function
--   also takes care that the result is converted to Posix convention and
--   normalized. Also, parent directories ("..") at the front of the string
--   argument get canceled out against trailing directory parts of the
--   absolute path argument.
--   
--   Regarding the last point, someone more familiar with how these
--   functions are used should verify that this is indeed necessary or at
--   least useful.
makeAbsolute :: AbsolutePath -> FilePath -> AbsolutePath

-- | Interpret a possibly relative path wrt the current working directory.
--   This also canonicalizes the path, resolving symbolic links etc.
ioAbsolute :: FilePath -> IO AbsolutePath

-- | This is for situations where a string (e.g. a command line argument)
--   may take the value "-" to mean stdin or stdout (which one depends on
--   context) instead of a normal file path.
data AbsolutePathOrStd
makeAbsoluteOrStd :: AbsolutePath -> String -> AbsolutePathOrStd
ioAbsoluteOrStd :: String -> IO AbsolutePathOrStd

-- | Execute either the first or the second argument action, depending on
--   whether the given path is an <a>AbsolutePath</a> or stdin/stdout.
useAbsoluteOrStd :: (AbsolutePath -> a) -> a -> AbsolutePathOrStd -> a
stdOut :: AbsolutePathOrStd
data AbsoluteOrRemotePath
ioAbsoluteOrRemote :: String -> IO AbsoluteOrRemotePath
isRemote :: AbsoluteOrRemotePath -> Bool

-- | Paths which are relative to the local darcs repository and normalized.
--   Note: These are understood not to have the dot in front.
data SubPath

-- | Make the second path relative to the first, if possible. Note that
--   this returns an empty <a>SubPath</a> if the inputs are equal.
makeSubPathOf :: AbsolutePath -> AbsolutePath -> Maybe SubPath
simpleSubPath :: HasCallStack => FilePath -> Maybe SubPath

-- | Transform a SubPath into an AnchoredPath.
floatSubPath :: SubPath -> Either String AnchoredPath

-- | The first argument must be the absolute path of a <tt>directory</tt>,
--   the second is an arbitrary absolute <tt>path</tt>. Find the longest
--   prefix of <tt>path</tt> that points to the same <tt>directory</tt>; if
--   there is none, return <a>Nothing</a>, else return <a>Just</a> the
--   remainder.
makeRelativeTo :: HasCallStack => AbsolutePath -> AbsolutePath -> IO (Maybe SubPath)
class FilePathOrURL a
toPath :: FilePathOrURL a => a -> String
class FilePathOrURL a => FilePathLike a
toFilePath :: FilePathLike a => a -> FilePath
getCurrentDirectory :: IO AbsolutePath
setCurrentDirectory :: HasCallStack => FilePathLike p => p -> IO ()

-- | Iteratively tries find first non-existing path generated by buildName,
--   it feeds to buildName the number starting with -1. When it generates
--   non-existing path and it isn't first, it displays the message created
--   with buildMsg. Usually used for generation of the name like
--   <a>path</a>_<a>number</a> when <a>path</a> already exist (e.g.
--   darcs.net_0).
getUniquePathName :: Bool -> (FilePath -> String) -> (Int -> FilePath) -> IO FilePath

-- | Construct a filter from a list of AnchoredPaths, that will accept any
--   path that is either a parent or a child of any of the listed paths,
--   and discard everything else.
filterPaths :: [AnchoredPath] -> AnchoredPath -> t -> Bool
data Name
name2fp :: Name -> FilePath

-- | Make a <a>Name</a> from a <a>String</a>. May fail if the input
--   <a>String</a> is invalid, that is, "", ".", "..", or contains a
--   <a>/</a>.
makeName :: String -> Either String Name

-- | Make a <a>Name</a> from a <a>ByteString</a>.
rawMakeName :: ByteString -> Either String Name
eqAnycase :: Name -> Name -> Bool

-- | This is a type of "sane" file paths. These are always canonic in the
--   sense that there are no stray slashes, no ".." components and similar.
--   They are usually used to refer to a location within a Tree, but a
--   relative filesystem path works just as well. These are either
--   constructed from individual name components (using "appendPath",
--   "catPaths" and "makeName"), or converted from a FilePath
--   ("unsafeFloatPath" -- but take care when doing that).
newtype AnchoredPath
AnchoredPath :: [Name] -> AnchoredPath
anchoredRoot :: AnchoredPath

-- | Append an element to the end of a path.
appendPath :: AnchoredPath -> Name -> AnchoredPath

-- | Take a "root" directory and an anchored path and produce a full
--   <a>FilePath</a>. Moreover, you can use <tt>anchorPath ""</tt> to get a
--   relative <a>FilePath</a>.
anchorPath :: FilePath -> AnchoredPath -> FilePath

-- | Check whether a path is a prefix of another path.
isPrefix :: AnchoredPath -> AnchoredPath -> Bool

-- | The effect of renaming on paths. The first argument is the old path,
--   the second is the new path, and the third is the possibly affected
--   path we are interested in.
movedirfilename :: AnchoredPath -> AnchoredPath -> AnchoredPath -> AnchoredPath

-- | Get parent (path) of a given path. foo<i>bar</i>baz -&gt; foo/bar
parent :: AnchoredPath -> Maybe AnchoredPath

-- | List all (proper) parents of a given path. foo<i>bar</i>baz -&gt;
--   [.,foo, foo/bar]
parents :: AnchoredPath -> [AnchoredPath]

-- | Replace the second arg's parent with the first arg.
replaceParent :: AnchoredPath -> AnchoredPath -> Maybe AnchoredPath

-- | Catenate two paths together. Not very safe, but sometimes useful (e.g.
--   when you are representing paths relative to a different point than a
--   Tree root).
catPaths :: AnchoredPath -> AnchoredPath -> AnchoredPath
flatten :: AnchoredPath -> ByteString

-- | Is the given path in (or equal to) the _darcs metadata directory?
inDarcsdir :: AnchoredPath -> Bool

-- | For displaying paths to the user. It should never be used for on-disk
--   patch storage. This adds the "./" for consistency with how repo paths
--   are displayed by <tt>showPatch</tt> and friends, except for the root
--   path which is displayed as plain ".".
displayPath :: AnchoredPath -> FilePath

-- | Interpret an <a>AnchoredPath</a> as relative the current working
--   directory. Intended for IO operations in the file system. Use with
--   care!
realPath :: AnchoredPath -> FilePath
isRoot :: AnchoredPath -> Bool
darcsdirName :: Name
floatPath :: FilePath -> Either String AnchoredPath

-- | Take a relative FilePath and turn it into an AnchoredPath. This is a
--   partial function. Basically, by using unsafeFloatPath, you are
--   testifying that the argument is a path relative to some common root --
--   i.e. the root of the associated <a>Tree</a> object. In particular, the
--   input path may not contain any ocurrences of "." or ".." after
--   normalising. You should sanitize any FilePaths before you declare them
--   "good" by converting into AnchoredPath (using this function),
--   especially if the FilePath come from any external source (command
--   line, file, environment, network, etc)
unsafeFloatPath :: HasCallStack => FilePath -> AnchoredPath
instance GHC.Classes.Ord Darcs.Util.Path.SubPath
instance GHC.Classes.Eq Darcs.Util.Path.SubPath
instance GHC.Classes.Ord Darcs.Util.Path.AbsolutePath
instance GHC.Classes.Eq Darcs.Util.Path.AbsolutePath
instance GHC.Classes.Ord Darcs.Util.Path.AbsolutePathOrStd
instance GHC.Classes.Eq Darcs.Util.Path.AbsolutePathOrStd
instance GHC.Classes.Ord Darcs.Util.Path.AbsoluteOrRemotePath
instance GHC.Classes.Eq Darcs.Util.Path.AbsoluteOrRemotePath
instance GHC.Classes.Ord Darcs.Util.Path.Name
instance GHC.Show.Show Darcs.Util.Path.Name
instance GHC.Classes.Eq Darcs.Util.Path.Name
instance Data.Binary.Class.Binary Darcs.Util.Path.Name
instance GHC.Classes.Ord Darcs.Util.Path.AnchoredPath
instance GHC.Show.Show Darcs.Util.Path.AnchoredPath
instance GHC.Classes.Eq Darcs.Util.Path.AnchoredPath
instance Data.Binary.Class.Binary Darcs.Util.Path.AnchoredPath
instance Darcs.Util.Path.FilePathOrURL Darcs.Util.Path.AbsoluteOrRemotePath
instance GHC.Show.Show Darcs.Util.Path.AbsoluteOrRemotePath
instance GHC.Show.Show Darcs.Util.Path.AbsolutePathOrStd
instance Darcs.Util.Path.FilePathOrURL Darcs.Util.Path.AbsolutePath
instance Darcs.Util.Path.FilePathLike Darcs.Util.Path.AbsolutePath
instance GHC.Show.Show Darcs.Util.Path.AbsolutePath
instance Darcs.Util.Path.FilePathOrURL Darcs.Util.Path.SubPath
instance Darcs.Util.Path.FilePathLike Darcs.Util.Path.SubPath
instance GHC.Show.Show Darcs.Util.Path.SubPath
instance Darcs.Util.Path.FilePathLike GHC.IO.FilePath
instance Darcs.Util.Path.FilePathOrURL GHC.IO.FilePath


-- | The abstract representation of a Tree and useful abstract utilities to
--   handle those.
module Darcs.Util.Tree

-- | Abstraction of a filesystem tree. Please note that the Tree returned
--   by the respective read operations will have TreeStub items in it. To
--   obtain a Tree without such stubs, call expand on it, eg.:
--   
--   <pre>
--   tree &lt;- readDarcsPristine "." &gt;&gt;= expand
--   </pre>
--   
--   When a Tree is expanded, it becomes "final". All stubs are forced and
--   the Tree can be traversed purely. Access to actual file contents stays
--   in IO though.
--   
--   A Tree may have a Hash associated with it. A pair of Tree's is
--   identical whenever their hashes are (the reverse need not hold, since
--   not all Trees come equipped with a hash).
data Tree m
data Blob m
Blob :: !m ByteString -> !Maybe Hash -> Blob m
data TreeItem m
File :: !Blob m -> TreeItem m
SubTree :: !Tree m -> TreeItem m
Stub :: !m (Tree m) -> !Maybe Hash -> TreeItem m
data ItemType
TreeType :: ItemType
BlobType :: ItemType
data Hash
makeTree :: [(Name, TreeItem m)] -> Tree m
makeTreeWithHash :: [(Name, TreeItem m)] -> Hash -> Tree m
emptyTree :: Tree m
emptyBlob :: Monad m => Blob m
makeBlob :: Monad m => ByteString -> Blob m
makeBlobBS :: Monad m => ByteString -> Blob m
expandUpdate :: Monad m => (AnchoredPath -> Tree m -> m (Tree m)) -> Tree m -> m (Tree m)

-- | Expand a stubbed Tree into a one with no stubs in it. You might want
--   to filter the tree before expanding to save IO. This is the basic
--   implementation, which may be overriden by some Tree instances (this is
--   especially true of the Index case).
expand :: Monad m => Tree m -> m (Tree m)

-- | Unfold a path in a (stubbed) Tree, such that the leaf node of the path
--   is reachable without crossing any stubs. Moreover, the leaf ought not
--   be a Stub in the resulting Tree. A non-existent path is expanded as
--   far as it can be.
expandPath :: Monad m => Tree m -> AnchoredPath -> m (Tree m)

-- | Check the disk version of a Tree: expands it, and checks each hash.
--   Returns either the expanded tree or a list of AnchoredPaths where
--   there are problems. The first argument is the hashing function used to
--   create the tree.
checkExpand :: (TreeItem IO -> IO Hash) -> Tree IO -> IO (Either [(AnchoredPath, Maybe Hash, Maybe Hash)] (Tree IO))
items :: Tree m -> Map Name (TreeItem m)

-- | List all contents of a <a>Tree</a>.
list :: Tree m -> [(AnchoredPath, TreeItem m)]
listImmediate :: Tree m -> [(Name, TreeItem m)]

-- | Get hash of a Tree. This is guaranteed to uniquely identify the Tree
--   (including any blob content), as far as cryptographic hashes are
--   concerned. Sha256 is recommended.
treeHash :: Tree m -> Maybe Hash

-- | Look up a <a>Tree</a> item (an immediate subtree or blob).
lookup :: Tree m -> Name -> Maybe (TreeItem m)

-- | Find a <a>TreeItem</a> by its path. Gives <a>Nothing</a> if the path
--   is invalid.
find :: Tree m -> AnchoredPath -> Maybe (TreeItem m)

-- | Find a <a>Blob</a> by its path. Gives <a>Nothing</a> if the path is
--   invalid, or does not point to a Blob.
findFile :: Tree m -> AnchoredPath -> Maybe (Blob m)

-- | Find a <a>Tree</a> by its path. Gives <a>Nothing</a> if the path is
--   invalid, or does not point to a Tree.
findTree :: Tree m -> AnchoredPath -> Maybe (Tree m)

-- | Get a hash of a TreeItem. May be Nothing.
itemHash :: TreeItem m -> Maybe Hash
itemType :: TreeItem m -> ItemType

-- | For every pair of corresponding blobs from the two supplied trees,
--   evaluate the supplied function and accumulate the results in a list.
--   Hint: to get IO actions through, just use sequence on the resulting
--   list. NB. This won't expand any stubs.
zipCommonFiles :: (AnchoredPath -> Blob m -> Blob m -> a) -> Tree m -> Tree m -> [a]

-- | For each file in each of the two supplied trees, evaluate the supplied
--   function (supplying the corresponding file from the other tree, or
--   Nothing) and accumulate the results in a list. Hint: to get IO actions
--   through, just use sequence on the resulting list. NB. This won't
--   expand any stubs.
zipFiles :: (AnchoredPath -> Maybe (Blob m) -> Maybe (Blob m) -> a) -> Tree m -> Tree m -> [a]
zipTrees :: (AnchoredPath -> Maybe (TreeItem m) -> Maybe (TreeItem m) -> a) -> Tree m -> Tree m -> [a]

-- | Cautiously extracts differing subtrees from a pair of Trees. It will
--   never do any unneccessary expanding. Tree hashes are used to cut the
--   comparison as high up the Tree branches as possible. The result is a
--   pair of trees that do not share any identical subtrees. They are
--   derived from the first and second parameters respectively and they are
--   always fully expanded. It might be advantageous to feed the result
--   into <a>zipFiles</a> or <a>zipTrees</a>.
diffTrees :: forall m. Monad m => Tree m -> Tree m -> m (Tree m, Tree m)

-- | All paths in the tree that that have the given path as prefix.
--   
--   <pre>
--   explodePath t p == Prelude.filter (p `isPrefix`) (map fst (list t))
--   </pre>
explodePath :: Tree m -> AnchoredPath -> [AnchoredPath]

-- | Like <a>explodePath</a> but for multiple paths.
explodePaths :: Tree IO -> [AnchoredPath] -> [AnchoredPath]

-- | Like <a>find</a> but monadic and thus able to expand <a>Stub</a>s on
--   the way.
locate :: Monad m => Tree m -> AnchoredPath -> m (Maybe (TreeItem m))
isDir :: TreeItem m -> Bool
treeHas :: Monad m => Tree m -> AnchoredPath -> m Bool
treeHasDir :: Monad m => Tree m -> AnchoredPath -> m Bool
treeHasFile :: Monad m => Tree m -> AnchoredPath -> m Bool
treeHasAnycase :: Monad m => Tree m -> AnchoredPath -> m Bool

-- | Read a Blob into a Lazy ByteString. Might be backed by an mmap, use
--   with care.
readBlob :: Blob m -> m ByteString
class (Monad m) => FilterTree a m

-- | Given <tt>pred tree</tt>, produce a <a>Tree</a> that only has items
--   for which <tt>pred</tt> returns <tt>True</tt>. The tree might contain
--   stubs. When expanded, these will be subject to filtering as well.
filter :: FilterTree a m => (AnchoredPath -> TreeItem m -> Bool) -> a m -> a m

-- | Given two Trees, a <tt>guide</tt> and a <tt>tree</tt>, produces a new
--   Tree that is a identical to <tt>tree</tt>, but only has those items
--   that are present in both <tt>tree</tt> and <tt>guide</tt>. The
--   <tt>guide</tt> Tree may not contain any stubs.
restrict :: FilterTree t m => Tree n -> t m -> t m

-- | Modify a Tree (by replacing, or removing or adding items).
modifyTree :: Monad m => Tree m -> AnchoredPath -> Maybe (TreeItem m) -> Tree m

-- | Does <i>not</i> expand the tree.
updateTree :: Monad m => (TreeItem m -> m (TreeItem m)) -> Tree m -> m (Tree m)

-- | Does <i>not</i> expand the tree.
partiallyUpdateTree :: Monad m => (TreeItem m -> m (TreeItem m)) -> (AnchoredPath -> TreeItem m -> Bool) -> Tree m -> m (Tree m)
updateSubtrees :: (Tree m -> Tree m) -> Tree m -> Tree m

-- | Lay one tree over another. The resulting Tree will look like the base
--   (1st parameter) Tree, although any items also present in the overlay
--   Tree will be taken from the overlay. It is not allowed to overlay a
--   different kind of an object, nor it is allowed for the overlay to add
--   new objects to base. This means that the overlay Tree should be a
--   subset of the base Tree (although any extraneous items will be ignored
--   by the implementation).
overlay :: Applicative m => Tree m -> Tree m -> Tree m

-- | Calculate and insert hashes for all <a>TreeItem</a>s contained in a
--   <a>Tree</a>, including the argument <a>Tree</a> itself. If necessary,
--   this expands <a>Stub</a>s.
addMissingHashes :: Monad m => (TreeItem m -> m Hash) -> Tree m -> m (Tree m)

-- | Specification of <a>explodePath</a>
prop_explodePath :: Tree m -> AnchoredPath -> Bool
instance GHC.Classes.Ord Darcs.Util.Tree.ItemType
instance GHC.Classes.Eq Darcs.Util.Tree.ItemType
instance GHC.Show.Show Darcs.Util.Tree.ItemType
instance GHC.Base.Monad m => Darcs.Util.Tree.FilterTree Darcs.Util.Tree.Tree m


-- | The plain format implementation resides in this module. The plain
--   format does not use any hashing and basically just wraps a normal
--   filesystem tree in the hashed-storage API.
--   
--   NB. The <a>read</a> function on Blobs coming from a plain tree is
--   susceptible to file content changes. Since we use mmap in <a>read</a>,
--   this will break referential transparency and produce unexpected
--   results. Please always make sure that all parallel access to the
--   underlying filesystem tree never mutates files. Unlink + recreate is
--   fine though (in other words, the <a>writePlainTree</a> implemented in
--   this module is safe in this respect).
module Darcs.Util.Tree.Plain
readPlainTree :: FilePath -> IO (Tree IO)

-- | Write out <i>full</i> tree to a plain directory structure. If you
--   instead want to make incremental updates, refer to
--   <a>Darcs.Util.Tree.Monad</a>.
writePlainTree :: Tree IO -> FilePath -> IO ()


-- | A monad transformer for <a>Tree</a> mutation. The main idea is to
--   simulate IO-ish manipulation of real filesystem (that's the state part
--   of the monad), and to keep memory usage down by reasonably often
--   dumping the intermediate data to disk and forgetting it.
--   
--   The implementation is configured by passing a procedure of type
--   <a>DumpItem</a> to <a>runTreeMonad</a>.
--   
--   This module provides the pre-configured <a>virtualTreeIO</a> that
--   never writes any changes, but may trigger filesystem reads as
--   appropriate.
module Darcs.Util.Tree.Monad

-- | A monad transformer that adds state of type <a>TreeState</a> and an
--   environment of type <a>DumpItem</a>.
type TreeMonad m = RWST (DumpItem m) () (TreeState m) m

-- | Internal state of the <a>TreeMonad</a>. Keeps track of the current
--   <a>Tree</a> content and unsync'd changes.
data TreeState m
runTreeMonad :: Monad m => TreeMonad m a -> Tree m -> DumpItem m -> m (a, Tree m)

-- | Run a <a>TreeMonad</a> action without storing any changes. This is
--   useful for running monadic tree mutations for obtaining the resulting
--   <a>Tree</a> (as opposed to their effect of writing a modified tree to
--   disk). The actions can do both read and write -- reads are passed
--   through to the actual filesystem, but the writes are held in memory in
--   the form of a modified <a>Tree</a>.
virtualTreeMonad :: Monad m => TreeMonad m a -> Tree m -> m (a, Tree m)

-- | <a>TreeMonad</a> specialized to <a>IO</a>
type TreeIO = TreeMonad IO

-- | <a>virtualTreeMonad</a> specialized to <a>IO</a>
virtualTreeIO :: TreeIO a -> Tree IO -> IO (a, Tree IO)

-- | Grab content of a file in the current Tree at the given path.
readFile :: MonadThrow m => AnchoredPath -> TreeMonad m ByteString

-- | Check for existence of a node (file or directory, doesn't matter).
exists :: MonadThrow m => AnchoredPath -> TreeMonad m Bool

-- | Check for existence of a directory.
directoryExists :: Monad m => AnchoredPath -> TreeMonad m Bool

-- | Check for existence of a file.
fileExists :: Monad m => AnchoredPath -> TreeMonad m Bool

-- | Change content of a file at a given path. The change will be
--   eventually flushed to disk, but might be buffered for some time.
writeFile :: MonadThrow m => AnchoredPath -> ByteString -> TreeMonad m ()

-- | Create a directory.
createDirectory :: Monad m => AnchoredPath -> TreeMonad m ()

-- | Remove the item at a path.
unlink :: Monad m => AnchoredPath -> TreeMonad m ()

-- | Rename the item at a path.
rename :: MonadThrow m => AnchoredPath -> AnchoredPath -> TreeMonad m ()

-- | Copy an item from some path to another path. Doing this with a SubTree
--   is weird... it means copy recursively, but with lazy copy-on-write
--   semantics. What happens when we flush that? Seems to work, though, as
--   it is used in Darcs.UI.Commands.Convert.Import
copy :: MonadThrow m => AnchoredPath -> AnchoredPath -> TreeMonad m ()
findM :: Monad m => Tree m -> AnchoredPath -> m (Maybe (TreeItem m))
findFileM :: Monad m => Tree m -> AnchoredPath -> m (Maybe (Blob m))
findTreeM :: Monad m => Tree m -> AnchoredPath -> m (Maybe (Tree m))

module Darcs.Util.File

-- | Badly named, since it is actually <a>getSymbolicLinkStatus</a>, with
--   all <a>IOError</a>s turned into <a>Nothing</a>.
getFileStatus :: FilePath -> IO (Maybe FileStatus)

-- | Whether a path is an existing directory, but not a symlink to one.
doesDirectoryReallyExist :: FilePath -> IO Bool

-- | Variant of <a>removeFile</a> that doesn't throw exception when file
--   does not exist.
removeFileMayNotExist :: FilePathLike p => p -> IO ()

-- | Return all files under given directory that aren't directories.
getRecursiveContents :: FilePath -> IO [FilePath]

-- | Return all files under given directory that aren't directories. Unlike
--   <a>getRecursiveContents</a> this function returns the full path.
getRecursiveContentsFullPath :: FilePath -> IO [FilePath]

-- | Recursively copy a directory, where the target directory is supposed
--   to already exist.
copyTree :: FilePath -> FilePath -> IO ()

-- | <tt>fetchFilePS fileOrUrl cache</tt> returns the content of its
--   argument (either a file or an URL). If it has to download an url, then
--   it will use a cache as required by its second argument.
--   
--   We always use default remote darcs, since it is not fatal if the
--   remote darcs does not exist or is too old -- anything that supports
--   transfer-mode should do, and if not, we will fall back to SFTP or SCP.
fetchFilePS :: String -> Cachable -> IO ByteString

-- | <tt>fetchFileLazyPS fileOrUrl cache</tt> lazily reads the content of
--   its argument (either a file or an URL). Warning: this function may
--   constitute a fd leak; make sure to force consumption of file contents
--   to avoid that. See "fetchFilePS" for details.
fetchFileLazyPS :: String -> Cachable -> IO ByteString

-- | Like <a>fetchFilePS</a> but transparently handle gzip compressed
--   files.
gzFetchFilePS :: String -> Cachable -> IO ByteString

-- | Initiate background file download for the given file path or URL to
--   the given location.
speculateFileOrUrl :: String -> FilePath -> IO ()

-- | Very much darcs-specific copying procedure. For local files it tries
--   to hard-link, falling back to normal copy if it fails. Remote URLs are
--   downloaded using either HTTP or SSH. For SSH, this tries to use the
--   given remote darcs command to invoke it's transfer-mode command.
copyFileOrUrl :: String -> String -> FilePath -> Cachable -> IO ()
data Cachable
Cachable :: Cachable
Uncachable :: Cachable
MaxAge :: !CInt -> Cachable
backupByRenaming :: FilePath -> IO ()
backupByCopying :: FilePath -> IO ()

-- | Invoke the given action on a file that is temporarily created in the
--   current directory, and removed afterwards.
withTemp :: (FilePath -> IO a) -> IO a

-- | Invoke the given action on a file that is temporarily created and
--   opened in the current directory, and closed and removed afterwards.
withOpenTemp :: ((Handle, FilePath) -> IO a) -> IO a

module Darcs.Util.Lock
withLock :: String -> IO a -> IO a

-- | Tries to perform some task if it can obtain the lock, Otherwise, just
--   gives up without doing the task
withLockCanFail :: String -> IO a -> IO (Either () a)
environmentHelpLocks :: ([String], [String])

-- | <a>withTempDir</a> creates a temporary directory, runs the action and
--   then removes the directory. The location of that directory is
--   determined by the contents of _darcs<i>prefs</i>tmpdir, if it exists,
--   otherwise by <tt>$DARCS_TMPDIR</tt>, and if that doesn't exist then
--   whatever your operating system considers to be a a temporary directory
--   (e.g. <tt>$TMPDIR</tt> under Unix, <tt>$TEMP</tt> under Windows).
--   
--   If none of those exist it creates the temporary directory in the
--   current directory, unless the current directory is under a _darcs
--   directory, in which case the temporary directory in the parent of the
--   highest _darcs directory to avoid accidentally corrupting darcs's
--   internals. This should not fail, but if it does indeed fail, we go
--   ahead and use the current directory anyway. If
--   <tt>$DARCS_KEEP_TMPDIR</tt> variable is set temporary directory is not
--   removed, this can be useful for debugging.
withTempDir :: FilePath -> (AbsolutePath -> IO a) -> IO a

-- | <a>withPermDir</a> is like <a>withTempDir</a>, except that it doesn't
--   delete the directory afterwards.
withPermDir :: FilePath -> (AbsolutePath -> IO a) -> IO a
withDelayedDir :: FilePath -> (AbsolutePath -> IO a) -> IO a
withNamedTemp :: FilePath -> (FilePath -> IO a) -> IO a
writeBinFile :: FilePathLike p => p -> ByteString -> IO ()
writeTextFile :: FilePathLike p => p -> String -> IO ()
writeDocBinFile :: FilePathLike p => p -> Doc -> IO ()
appendBinFile :: FilePathLike p => p -> ByteString -> IO ()
appendTextFile :: FilePathLike p => p -> String -> IO ()
appendDocBinFile :: FilePathLike p => p -> Doc -> IO ()
readBinFile :: FilePathLike p => p -> IO ByteString
readTextFile :: FilePathLike p => p -> IO [String]
readDocBinFile :: FilePathLike p => p -> IO Doc
writeAtomicFilePS :: FilePathLike p => p -> ByteString -> IO ()
gzWriteAtomicFilePS :: FilePathLike p => p -> ByteString -> IO ()
gzWriteAtomicFilePSs :: FilePathLike p => p -> [ByteString] -> IO ()
gzWriteDocFile :: FilePathLike p => p -> Doc -> IO ()

-- | Variant of <a>removeFile</a> that doesn't throw exception when file
--   does not exist.
removeFileMayNotExist :: FilePathLike p => p -> IO ()
maybeRelink :: String -> String -> IO Bool
tempdirLoc :: IO FilePath
environmentHelpTmpdir :: ([String], [String])
environmentHelpKeepTmpdir :: ([String], [String])
addToErrorLoc :: IOException -> String -> IOException

-- | Do an action in a newly created directory of the given name. If the
--   directory is successfully created but the action raises an exception,
--   the directory and all its content is deleted. Caught exceptions are
--   re-thrown.
withNewDirectory :: FilePath -> IO () -> IO ()

module Darcs.Util.Cache

-- | Cache is an abstract type for hiding the underlying cache locations
data Cache

-- | Smart constructor for <a>CacheLoc</a>.
mkCache :: [CacheLoc] -> Cache
mkDirCache :: FilePath -> Cache
mkRepoCache :: FilePath -> Cache
cacheEntries :: Cache -> [CacheLoc]
data CacheType
Repo :: CacheType
Directory :: CacheType
data CacheLoc
Cache :: !CacheType -> !WritableOrNot -> !String -> CacheLoc
[cacheType] :: CacheLoc -> !CacheType
[cacheWritable] :: CacheLoc -> !WritableOrNot
[cacheSource] :: CacheLoc -> !String
data WritableOrNot
Writable :: WritableOrNot
NotWritable :: WritableOrNot

-- | Semantically, this is the type of hashed objects. Git has a type tag
--   inside the hashed file itself, whereas in Darcs the type is determined
--   by the subdirectory.
data HashedDir
HashedPristineDir :: HashedDir
HashedPatchesDir :: HashedDir
HashedInventoriesDir :: HashedDir
hashedDir :: HashedDir -> FilePath
bucketFolder :: FilePath -> FilePath

-- | Filter caches for remote repos. This affects only entries that are
--   locally valid paths (i.e. not network URLs): they are removed if
--   non-existent, or demoted to NotWritable if they are not actually
--   writable in the file system.
filterRemoteCaches :: Cache -> IO Cache
cleanCaches :: Cache -> HashedDir -> IO ()
cleanCachesWithHint :: Cache -> HashedDir -> [String] -> IO ()

-- | <tt>fetchFileUsingCache cache dir hash</tt> receives a list of caches
--   <tt>cache</tt>, the directory for which that file belongs <tt>dir</tt>
--   and the <tt>hash</tt> of the file to fetch. It tries to fetch the file
--   from one of the sources, trying them in order one by one. If the file
--   cannot be fetched from any of the sources, this operation fails.
--   Otherwise we return the path where we found the file and its content.
fetchFileUsingCache :: ValidHash h => Cache -> h -> IO (FilePath, ByteString)

-- | Add pipelined downloads to the (low-priority) queue, for the rest it
--   is a noop.
speculateFileUsingCache :: ValidHash h => Cache -> h -> IO ()

-- | Do <a>speculateFilesUsingCache</a> for files not already in a writable
--   cache position.
speculateFilesUsingCache :: ValidHash h => Cache -> [h] -> IO ()

-- | Write file content, except if it is already in the cache, in which
--   case merely create a hard link to that file. The returned value is the
--   size and hash of the content.
writeFileUsingCache :: ValidHash h => Cache -> ByteString -> IO h

-- | Return whether the <a>CacheLoc</a> contains a file with the given hash
--   in a writable position.
peekInCache :: ValidHash h => Cache -> h -> IO Bool
parseCacheLoc :: String -> Maybe CacheLoc
showCacheLoc :: CacheLoc -> String
writable :: CacheLoc -> Bool
isThisRepo :: CacheLoc -> Bool

-- | The full filepath of a simple file name inside a given <a>CacheLoc</a>
--   under <a>HashedDir</a>.
hashedFilePath :: CacheLoc -> HashedDir -> FilePath -> FilePath
allHashedDirs :: [HashedDir]

-- | Prints an error message with a list of bad caches.
reportBadSources :: IO ()
closestWritableDirectory :: Cache -> Maybe String

-- | This keeps only <a>Repo</a> <a>NotWritable</a> entries.
dropNonRepos :: Cache -> Cache
instance GHC.Show.Show Darcs.Util.Cache.WritableOrNot
instance GHC.Classes.Eq Darcs.Util.Cache.WritableOrNot
instance GHC.Show.Show Darcs.Util.Cache.CacheType
instance GHC.Classes.Eq Darcs.Util.Cache.CacheType
instance GHC.Show.Show Darcs.Util.Cache.OrOnlySpeculate
instance GHC.Classes.Eq Darcs.Util.Cache.OrOnlySpeculate
instance GHC.Classes.Eq Darcs.Util.Cache.FromWhere
instance GHC.Show.Show Darcs.Util.Cache.Cache
instance GHC.Classes.Eq Darcs.Util.Cache.CacheLoc


-- | A few darcs-specific utility functions. These are used for reading and
--   writing darcs and darcs-compatible hashed trees.
module Darcs.Util.Tree.Hashed
readDarcsHashed :: Cache -> PristineHash -> IO (Tree IO)

-- | Write a Tree into a darcs-style hashed directory.
writeDarcsHashed :: Tree IO -> Cache -> IO PristineHash

-- | Run a <a>TreeIO</a> <tt>action</tt> in a hashed setting. Any changes
--   will be written out to the cache. Please note that actual filesystem
--   files are never removed.
hashedTreeIO :: TreeIO a -> Tree IO -> Cache -> IO (a, Tree IO)
readDarcsHashedNosize :: Cache -> PristineHash -> IO (Tree IO)
darcsAddMissingHashes :: Monad m => Tree m -> m (Tree m)

-- | Compute a darcs-compatible hash value for a tree-like structure.
darcsTreeHash :: Tree m -> Hash
darcsUpdateHashes :: Monad m => Tree m -> m (Tree m)

-- | Return all <a>PristineHash</a>es reachable from the given root set,
--   which must consist of directory hashes only.
followPristineHashes :: Cache -> [PristineHash] -> IO [PristineHash]


-- | This module contains plain tree indexing code. The index itself is a
--   CACHE: you should only ever use it as an optimisation and never as a
--   primary storage. In practice, this means that when we change index
--   format, the application is expected to throw the old index away and
--   build a fresh index. Please note that tracking index validity is out
--   of scope for this module: this is responsibility of your application.
--   It is advisable that in your validity tracking code, you also check
--   for format validity (see <a>indexFormatValid</a>) and scrap and
--   re-create index when needed.
--   
--   The index is a binary file that overlays a hashed tree over the
--   working copy. This means that every working file and directory has an
--   entry in the index, that contains its path and hash and validity data.
--   The validity data is a timestamp plus the file size. The file hashes
--   are sha256's of the file's content. It also contains the fileid to
--   track moved files.
--   
--   There are two entry types, a file entry and a directory entry. Both
--   have a common binary format (see <a>Item</a>). The on-disk format is
--   described by the section <i>Index format</i> below.
--   
--   For each file, the index has a copy of the file's last modification
--   timestamp taken at the instant when the hash has been computed. This
--   means that when file size and timestamp of a file in working tree
--   matches those in the index, we assume that the hash stored in the
--   index for given file is valid. These hashes are then exposed in the
--   resulting <a>Tree</a> object, and can be leveraged by eg.
--   <a>diffTrees</a> to compare many files quickly.
--   
--   You may have noticed that we also keep hashes of directories. These
--   are assumed to be valid whenever the complete subtree has been valid.
--   At any point, as soon as a size or timestamp mismatch is found, the
--   working file in question is opened, its hash (and timestamp and size)
--   is recomputed and updated in-place in the index file (everything lives
--   at a fixed offset and is fixed size, so this isn't an issue). This is
--   also true of directories: when a file in a directory changes hash,
--   this triggers recomputation of all of its parent directory hashes;
--   moreover this is done efficiently -- each directory is updated at most
--   once during an update run.
--   
--   <i>Endianness</i>
--   
--   Since version 6 (magic == <a>HSI6</a>), the file format depends on the
--   endianness of the architecture. To account for the (rare) case where
--   darcs executables from different architectures operate on the same
--   repo, we make an additional check in indexFormatValid to detect
--   whether the file's endianness differs from what we expect. If this is
--   detected, the file is considered invalid and will be re-created.
--   
--   <i>Index format</i>
--   
--   The index starts with a header consisting of a 4 bytes magic word,
--   followed by a 4 byte word to indicate the endianness of the encoding.
--   This word should, when read directly from the mmapped file, be equal
--   to 1.
--   
--   After the header comes the actual content of the index, which is a
--   sequence of <a>Item</a>s. An <a>Item</a> consists of:
--   
--   <ul>
--   <li>size: item size, 8 bytes</li>
--   <li>aux: timestamp (for file) or offset to sibling (for dir), 8
--   bytes</li>
--   <li>fileid: inode or fhandle of the item, 8 bytes</li>
--   <li>hash: sha256 of content, 32 bytes</li>
--   <li>descriptor length: &gt;= 2 due to type and null, 4 bytes</li>
--   <li>descriptor:</li>
--   <li>type: <tt>D</tt> or <tt>F</tt>, one byte</li>
--   <li>path: flattened path, variable &gt;= 0</li>
--   <li>null: terminating null byte</li>
--   <li>alignment padding: 0 to 3 bytes</li>
--   </ul>
--   
--   Each <a>Item</a> is 4 byte aligned. Thus the descriptor length must be
--   rounded up to get the position of the next item using <a>align</a>.
--   Similar, when determining the aux (offset to sibling) for dir items.
--   
--   With directories, the aux holds the offset of the next sibling item in
--   the index, so we can efficiently skip reading the whole subtree
--   starting at a given directory (by just seeking aux bytes forward). The
--   items are pre-ordered with respect to directory structure -- the
--   directory comes first and after it come all its items. Cf.
--   <a>openIndex</a>.
--   
--   For files, the aux field holds a timestamp.
--   
--   Internally, the item is stored as a pointer to the first field (iBase)
--   from which we directly read off the first three fields (size, aux,
--   fileid), and a ByteString for the rest (iHashAndDescriptor), up to but
--   not including the terminating null byte.
--   
--   TODO
--   
--   The null byte terminator seems useless.
--   
--   We could as well use a single plain pointer for the item. The
--   dumpIndex function demonstrates how this could be done.
--   
--   Another possible improvement is to store only the Name of an item, not
--   the full path. We need to keep track of the current path anyway when
--   traversing the index.
module Darcs.Util.Index

-- | Initialize an <a>IndexM</a> from the given index file.
openIndex :: FilePath -> IO Index

-- | Add and remove entries in the given <a>IndexM</a> to make it match the
--   given <a>Tree</a>. If an object in the <a>Tree</a> does not exist in
--   the current working directory, its index entry will have zero hash,
--   size, aux, and fileID. For the hash this translates to <a>Nothing</a>,
--   see <a>iHash'</a>.
updateIndexFrom :: FilePath -> Tree IO -> IO Index

-- | Check that a given file is an index file with a format we can handle.
--   You should remove and re-create the index whenever this is not true.
indexFormatValid :: FilePath -> IO Bool

-- | Read an <a>IndexM</a>, starting with the root, to create a
--   <a>Tree</a>.
treeFromIndex :: Index -> IO (Tree IO)

-- | Return a list containing all the file/folder names in an index, with
--   their respective ItemType and FileID.
listFileIDs :: Index -> IO [((AnchoredPath, ItemType), FileID)]
type Index = IndexM IO

-- | Given <tt>pred tree</tt>, produce a <a>Tree</a> that only has items
--   for which <tt>pred</tt> returns <tt>True</tt>. The tree might contain
--   stubs. When expanded, these will be subject to filtering as well.
filter :: FilterTree a m => (AnchoredPath -> TreeItem m -> Bool) -> a m -> a m

-- | For a given path, get the corresponding fileID from the filesystem.
getFileID :: AnchoredPath -> IO (Maybe FileID)
data IndexEntry
IndexEntry :: Int64 -> Int64 -> FileID -> Maybe Hash -> Char -> AnchoredPath -> IndexEntry
[ieSize] :: IndexEntry -> Int64
[ieAux] :: IndexEntry -> Int64
[ieFileID] :: IndexEntry -> FileID
[ieHash] :: IndexEntry -> Maybe Hash
[ieType] :: IndexEntry -> Char
[iePath] :: IndexEntry -> AnchoredPath
dumpIndex :: FilePath -> IO [IndexEntry]
align :: Integral a => a -> a -> a
instance GHC.Show.Show Darcs.Util.Index.Item
instance GHC.Classes.Eq Darcs.Util.Index.CorruptIndex
instance GHC.Exception.Type.Exception Darcs.Util.Index.CorruptIndex
instance GHC.Show.Show Darcs.Util.Index.CorruptIndex
instance Darcs.Util.Tree.FilterTree Darcs.Util.Index.IndexM GHC.Types.IO

module Darcs.Repository.Paths
makeDarcsdirPath :: String -> String

-- | Location of the lock file.
lockPath :: String

-- | Location of the prefs directory.
prefsDir :: String
prefsDirPath :: String

-- | Location of the (one and only) head inventory.
hashedInventory :: String
hashedInventoryPath :: String

-- | Location of the (one and only) tentative head inventory.
tentativeHashedInventory :: String
tentativeHashedInventoryPath :: String

-- | Location of parent inventories.
inventoriesDir :: FilePath
inventoriesDirPath :: String

-- | Location of pristine trees.
tentativePristinePath :: String
pristineDir :: FilePath
pristineDirPath :: String

-- | Location of patches.
patchesDir :: FilePath
patchesDirPath :: String

-- | Location of index files.
indexPath :: FilePath
indexInvalidPath :: FilePath

-- | Location of the rebase patch
rebasePath :: String
tentativeRebasePath :: String

-- | Location of format file
formatPath :: String

-- | Location of pending files
pendingPath :: FilePath
tentativePendingPath :: FilePath
newPendingPath :: FilePath

-- | Location of unrevert bundle.
unrevertPath :: FilePath
tentativeUnrevertPath :: FilePath

-- | Location of old style (unhashed) files and directories.
oldPristineDirPath :: String
oldCurrentDirPath :: String
oldCheckpointDirPath :: String
oldInventoryPath :: String
oldTentativeInventoryPath :: String


-- | The format file.
--   
--   The purpose of the format file is to check compatibility between
--   repositories in different formats and to allow the addition of new
--   features without risking corruption by old darcs versions that do not
--   yet know about these features.
--   
--   This allows a limited form of forward compatibility between darcs
--   versions. Old versions of darcs that are unaware of features added in
--   later versions will fail with a decent error message instead of
--   crashing or misbehaving or even corrupting new repos.
--   
--   The format file lives at _darcs/format and must only contain printable
--   ASCII characters and must not contain the characters <tt>&lt;</tt> and
--   <tt>&gt;</tt>.
--   
--   (We currently do not strip whitespace from the lines, but may want to
--   do so in the future.)
--   
--   The file consists of format properties. A format property can contain
--   any allowed ASCII character except the vertical bar (<tt>|</tt>) and
--   newlines. Empty lines are ignored and multiple properties on the same
--   line are separated with a <tt>|</tt>.
--   
--   If multiple properties appear on the same line (separated by vertical
--   bars), then this indicates alternative format properties. These have a
--   generic meaning:
--   
--   <ul>
--   <li>If we know *any* of these properties, then we can read the
--   repo.</li>
--   <li>If we know *all* of them, we can also write the repo.</li>
--   </ul>
--   
--   The above rules are necessary conditions, not sufficient ones. It is
--   allowed to further restrict read and/or write access for specific
--   commands, but care should be taken to not unnecessarily break forward
--   compatibility. It is not recommended, but sometimes necessary, to
--   impose ad-hoc restrictions on the format, see <a>transferProblem</a>
--   and <a>readProblem</a> for examples.
--   
--   The no-working-dir property is an example for how to use alternative
--   properties. An old darcs version that does not know this format can
--   perform most read-only operations correctly even if there is no
--   working tree; however, whatsnew will report that the whole tree was
--   removed, so the solution is not perfect.
--   
--   When you add a new property as an alternative to an existing one, you
--   should make sure that the old format remains to be updated in parallel
--   to the new one, so that reading the repo with old darcs versions
--   behaves correctly. If this cannot be guaranteed, it is better to add
--   the new format on a separate line.
--   
--   It is not advisable for commands to modify an existing format file.
--   However, sometimes compatibility requirements may leave us no other
--   choice. In this case make sure to write the format file only after
--   having checked that the existing repo format allows modification of
--   the repo, and that you have taken the repo lock.
module Darcs.Repository.Format

-- | Representation of the format of a repository. Each sublist corresponds
--   to a line in the format file.
newtype RepoFormat
RF :: [[RepoProperty]] -> RepoFormat
data RepoProperty
Darcs1 :: RepoProperty
Darcs2 :: RepoProperty
Darcs3 :: RepoProperty
HashedInventory :: RepoProperty
NoWorkingDir :: RepoProperty
RebaseInProgress :: RepoProperty
RebaseInProgress_2_16 :: RepoProperty
UnknownFormat :: ByteString -> RepoProperty

-- | Identify the format of the repository at the given location
--   (directory, URL, or SSH path). Fails if we weren't able to identify
--   the format.
identifyRepoFormat :: String -> IO RepoFormat

-- | Identify the format of the repository at the given location
--   (directory, URL, or SSH path). Return <tt><a>Left</a> reason</tt> if
--   it fails, where <tt>reason</tt> explains why we weren't able to
--   identify the format. Note that we do no verification of the format,
--   which is handled by <a>readProblem</a> or <a>writeProblem</a> on the
--   resulting <a>RepoFormat</a>.
tryIdentifyRepoFormat :: String -> IO (Either String RepoFormat)

-- | Create a repo format. The first argument specifies the patch format;
--   the second says whether the repo has a working tree.
createRepoFormat :: PatchFormat -> WithWorkingDir -> RepoFormat

-- | Write the repo format to the given file. This is unsafe because we
--   don't check that we are allowed to write to the repo.
unsafeWriteRepoFormat :: RepoFormat -> FilePath -> IO ()

-- | <tt><a>writeProblem</a> source</tt> returns <a>Just</a> an error
--   message if we cannot write to a repo in format <tt>source</tt>, or
--   <a>Nothing</a> if there's no such problem.
writeProblem :: RepoFormat -> Maybe String

-- | <tt><a>readProblem</a> source</tt> returns <a>Just</a> an error
--   message if we cannot read from a repo in format <tt>source</tt>, or
--   <a>Nothing</a> if there's no such problem.
readProblem :: RepoFormat -> Maybe String

-- | <tt><a>transferProblem</a> source target</tt> returns <a>Just</a> an
--   error message if we cannot transfer patches from a repo in format
--   <tt>source</tt> to a repo in format <tt>target</tt>, or <a>Nothing</a>
--   if there are no such problem.
transferProblem :: RepoFormat -> RepoFormat -> Maybe String

-- | Is a given property contained within a given format?
formatHas :: RepoProperty -> RepoFormat -> Bool

-- | Add a single property to an existing format.
addToFormat :: RepoProperty -> RepoFormat -> RepoFormat

-- | Remove a single property from an existing format.
removeFromFormat :: RepoProperty -> RepoFormat -> RepoFormat
instance GHC.Classes.Eq Darcs.Repository.Format.RepoProperty
instance GHC.Show.Show Darcs.Repository.Format.RepoFormat
instance GHC.Show.Show Darcs.Repository.Format.RepoProperty


-- | This module should only be imported by Darcs.UI.Options.* and by
--   <a>Flags</a>. Other modules needing access to <a>DarcsFlag</a> should
--   import <a>Flags</a>
module Darcs.UI.Options.Flags

-- | The <a>DarcsFlag</a> type is a list of all flags that can ever be
--   passed to darcs, or to one of its commands.
data DarcsFlag
Version :: DarcsFlag
ExactVersion :: DarcsFlag
ListCommands :: DarcsFlag
Help :: DarcsFlag
ListOptions :: DarcsFlag
NoTest :: DarcsFlag
Test :: DarcsFlag
OnlyChangesToFiles :: DarcsFlag
ChangesToAllFiles :: DarcsFlag
LeaveTestDir :: DarcsFlag
NoLeaveTestDir :: DarcsFlag
Timings :: DarcsFlag
Debug :: DarcsFlag
DebugHTTP :: DarcsFlag
Verbose :: DarcsFlag
NormalVerbosity :: DarcsFlag
Quiet :: DarcsFlag
To :: String -> DarcsFlag
Cc :: String -> DarcsFlag
Output :: AbsolutePathOrStd -> DarcsFlag
OutputAutoName :: AbsolutePath -> DarcsFlag
Mail :: DarcsFlag
Subject :: String -> DarcsFlag
InReplyTo :: String -> DarcsFlag
Charset :: String -> DarcsFlag
SendmailCmd :: String -> DarcsFlag
Author :: String -> DarcsFlag
SelectAuthor :: DarcsFlag
PatchName :: String -> DarcsFlag
OnePatch :: String -> DarcsFlag
SeveralPatch :: String -> DarcsFlag
AfterPatch :: String -> DarcsFlag
UpToPatch :: String -> DarcsFlag
OnePattern :: String -> DarcsFlag
SeveralPattern :: String -> DarcsFlag
AfterPattern :: String -> DarcsFlag
UpToPattern :: String -> DarcsFlag
OneHash :: String -> DarcsFlag
AfterHash :: String -> DarcsFlag
UpToHash :: String -> DarcsFlag
OneTag :: String -> DarcsFlag
SeveralTag :: String -> DarcsFlag
AfterTag :: String -> DarcsFlag
UpToTag :: String -> DarcsFlag
LastN :: String -> DarcsFlag
MaxCount :: String -> DarcsFlag
IndexRange :: String -> DarcsFlag
OneIndex :: String -> DarcsFlag
NumberPatches :: DarcsFlag
GenContext :: DarcsFlag
Context :: AbsolutePath -> DarcsFlag
Count :: DarcsFlag
LogFile :: AbsolutePath -> DarcsFlag
RmLogFile :: DarcsFlag
DontRmLogFile :: DarcsFlag
DistName :: String -> DarcsFlag
DistZip :: DarcsFlag
All :: DarcsFlag
Recursive :: DarcsFlag
NoRecursive :: DarcsFlag
Minimize :: DarcsFlag
NoMinimize :: DarcsFlag
Reorder :: DarcsFlag
NoReorder :: DarcsFlag
RestrictPaths :: DarcsFlag
DontRestrictPaths :: DarcsFlag
AskDeps :: DarcsFlag
NoAskDeps :: DarcsFlag
IgnoreTimes :: DarcsFlag
DontIgnoreTimes :: DarcsFlag
LookForAdds :: DarcsFlag
NoLookForAdds :: DarcsFlag
LookForMoves :: DarcsFlag
NoLookForMoves :: DarcsFlag
LookForReplaces :: DarcsFlag
NoLookForReplaces :: DarcsFlag
UseMyersDiff :: DarcsFlag
UsePatienceDiff :: DarcsFlag
Intersection :: DarcsFlag
Union :: DarcsFlag
Complement :: DarcsFlag
Sign :: DarcsFlag
SignAs :: String -> DarcsFlag
NoSign :: DarcsFlag
SignSSL :: String -> DarcsFlag
HappyForwarding :: DarcsFlag
NoHappyForwarding :: DarcsFlag
Verify :: AbsolutePath -> DarcsFlag
VerifySSL :: AbsolutePath -> DarcsFlag
RemoteDarcsOpt :: String -> DarcsFlag
EditDescription :: DarcsFlag
NoEditDescription :: DarcsFlag
Toks :: String -> DarcsFlag
EditLongComment :: DarcsFlag
NoEditLongComment :: DarcsFlag
PromptLongComment :: DarcsFlag
KeepDate :: DarcsFlag
NoKeepDate :: DarcsFlag
AllowConflicts :: DarcsFlag
MarkConflicts :: DarcsFlag
NoAllowConflicts :: DarcsFlag
SkipConflicts :: DarcsFlag
Boring :: DarcsFlag
SkipBoring :: DarcsFlag
AllowCaseOnly :: DarcsFlag
DontAllowCaseOnly :: DarcsFlag
AllowWindowsReserved :: DarcsFlag
DontAllowWindowsReserved :: DarcsFlag
DontGrabDeps :: DarcsFlag
DontPromptForDependencies :: DarcsFlag
PromptForDependencies :: DarcsFlag
Compress :: DarcsFlag
NoCompress :: DarcsFlag
UnCompress :: DarcsFlag
WorkRepoDir :: String -> DarcsFlag
WorkRepoUrl :: String -> DarcsFlag
NewRepo :: String -> DarcsFlag
NotInRemote :: Maybe String -> DarcsFlag
Reply :: String -> DarcsFlag
ApplyAs :: String -> DarcsFlag
MachineReadable :: DarcsFlag
HumanReadable :: DarcsFlag
Pipe :: DarcsFlag
Interactive :: DarcsFlag
DiffCmd :: String -> DarcsFlag
ExternalMerge :: String -> DarcsFlag
Summary :: DarcsFlag
NoSummary :: DarcsFlag
PauseForGui :: DarcsFlag
NoPauseForGui :: DarcsFlag
Unified :: DarcsFlag
NonUnified :: DarcsFlag
Reverse :: DarcsFlag
Forward :: DarcsFlag
Complete :: DarcsFlag
Lazy :: DarcsFlag
DiffFlags :: String -> DarcsFlag
XMLOutput :: DarcsFlag
ForceReplace :: DarcsFlag
NonApply :: DarcsFlag
NonVerify :: DarcsFlag
NonForce :: DarcsFlag
DryRun :: DarcsFlag
InheritDefault :: DarcsFlag
NoInheritDefault :: DarcsFlag
SetDefault :: DarcsFlag
NoSetDefault :: DarcsFlag
Disable :: DarcsFlag
SetScriptsExecutable :: DarcsFlag
DontSetScriptsExecutable :: DarcsFlag
Once :: DarcsFlag
Linear :: DarcsFlag
Backoff :: DarcsFlag
Bisect :: DarcsFlag
ShrinkFailure :: DarcsFlag
NoShrinkFailure :: DarcsFlag
Hashed :: DarcsFlag
UseFormat1 :: DarcsFlag
UseFormat2 :: DarcsFlag
UseFormat3 :: DarcsFlag
UseNoWorkingDir :: DarcsFlag
UseWorkingDir :: DarcsFlag
Sibling :: AbsolutePath -> DarcsFlag
Files :: DarcsFlag
NoFiles :: DarcsFlag
Directories :: DarcsFlag
NoDirectories :: DarcsFlag
Pending :: DarcsFlag
NoPending :: DarcsFlag
PosthookCmd :: String -> DarcsFlag
NoPosthook :: DarcsFlag
AskPosthook :: DarcsFlag
RunPosthook :: DarcsFlag
PrehookCmd :: String -> DarcsFlag
NoPrehook :: DarcsFlag
AskPrehook :: DarcsFlag
RunPrehook :: DarcsFlag
UMask :: String -> DarcsFlag
StoreInMemory :: DarcsFlag
ApplyOnDisk :: DarcsFlag
NoHTTPPipelining :: DarcsFlag
Packs :: DarcsFlag
NoPacks :: DarcsFlag
NoCache :: DarcsFlag
AllowUnrelatedRepos :: DarcsFlag
Check :: DarcsFlag
Repair :: DarcsFlag
JustThisRepo :: DarcsFlag
ReadMarks :: AbsolutePath -> DarcsFlag
WriteMarks :: AbsolutePath -> DarcsFlag
NullFlag :: DarcsFlag
NoAmendUnrecord :: DarcsFlag
AmendUnrecord :: DarcsFlag
PatchIndexFlag :: DarcsFlag
NoPatchIndexFlag :: DarcsFlag
EnumPatches :: DarcsFlag
NoEnumPatches :: DarcsFlag
WithPrefsTemplates :: DarcsFlag
NoPrefsTemplates :: DarcsFlag
OptimizeDeep :: DarcsFlag
OptimizeShallow :: DarcsFlag
instance GHC.Show.Show Darcs.UI.Options.Flags.DarcsFlag
instance GHC.Classes.Eq Darcs.UI.Options.Flags.DarcsFlag


-- | Constructing <a>OptSpec</a>s and <a>OptDescr</a>s
module Darcs.UI.Options.Util

-- | This type synonym is here for brevity and because we want to import
--   the data constructors (but not the type) of <a>DarcsFlag</a>
--   qualified.
type Flag = DarcsFlag

-- | We do not instantiate the <tt>d</tt> in <tt><a>OptSpec</a> d f</tt>
--   directly with <a>OptDescr</a>. Instead we (post-) compose it with
--   <tt>(-&gt;) <a>AbsolutePath</a></tt>. Modulo newtype noise, this is
--   the same as
--   
--   <pre>
--   type <a>DarcsOptDescr</a> f = <a>OptDescr</a> (<a>AbsolutePath</a> -&gt; f)
--   </pre>
--   
--   This is so we can pass a directory relative to which an option
--   argument is interpreted (if it has the form of a relative path).
type DarcsOptDescr = Compose OptDescr ((->) AbsolutePath)

-- | This is <a>PrimOptSpec</a> instantiated with <a>DarcsOptDescr</a> and
--   <a>Flag</a>.
type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v

-- | Construct a <a>DarcsOptDescr</a> with no arguments.
noArg :: [Char] -> [String] -> f -> String -> DarcsOptDescr f

-- | Construct a <a>DarcsOptDescr</a> with a <a>String</a> argument.
strArg :: SingleArgOptDescr String f

-- | Construct a <a>DarcsOptDescr</a> with an optional <a>String</a>
--   argument.
optStrArg :: SingleArgOptDescr (Maybe String) f

-- | Construct a <a>DarcsOptDescr</a> with an <a>AbsolutePath</a> argument.
absPathArg :: SingleArgOptDescr AbsolutePath f

-- | Construct a <a>DarcsOptDescr</a> with an <a>AbsolutePathOrStd</a>
--   argument.
absPathOrStdArg :: SingleArgOptDescr AbsolutePathOrStd f

-- | Construct a <a>DarcsOptDescr</a> with an optional <a>AbsolutePath</a>
--   argument.
optAbsPathArg :: [Char] -> [String] -> String -> (AbsolutePath -> f) -> String -> String -> DarcsOptDescr f

-- | The raw material from which multi-valued options are built. See
--   <a>withDefault</a>.
data RawOptSpec f v
RawNoArg :: [Char] -> [String] -> f -> v -> String -> RawOptSpec f v
RawStrArg :: [Char] -> [String] -> (String -> f) -> (f -> [String]) -> (String -> v) -> (v -> [String]) -> String -> String -> RawOptSpec f v
RawAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> f) -> (f -> [AbsolutePath]) -> (AbsolutePath -> v) -> (v -> [AbsolutePath]) -> String -> String -> RawOptSpec f v
RawAbsPathOrStdArg :: [Char] -> [String] -> (AbsolutePathOrStd -> f) -> (f -> [AbsolutePathOrStd]) -> (AbsolutePathOrStd -> v) -> (v -> [AbsolutePathOrStd]) -> String -> String -> RawOptSpec f v
RawOptAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> f) -> (f -> [AbsolutePath]) -> (AbsolutePath -> v) -> (v -> [AbsolutePath]) -> String -> String -> String -> RawOptSpec f v

-- | Construct a <a>PrimDarcsOption</a> from a default value and a list of
--   <a>RawOptSpec</a>.
--   
--   Precondition: the list must have an entry for each possible value
--   (type <tt>v</tt>).
withDefault :: Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v

-- | Construct a <a>Bool</a> valued option with a single flag that takes no
--   arguments and has no default flag.
--   
--   The arguments are: short switches, long switches, flag value, help
--   string.
singleNoArg :: [Char] -> [String] -> Flag -> String -> PrimDarcsOption Bool

-- | Construct a <tt><a>Maybe</a> <a>String</a></tt> valued option with a
--   single flag that takes a <a>String</a> argument and has no default
--   flag.
--   
--   The arguments are: short switches, long switches, flag constructor,
--   single flag parser, help string.
singleStrArg :: [Char] -> [String] -> (String -> Flag) -> (Flag -> Maybe String) -> String -> String -> PrimDarcsOption (Maybe String)

-- | Similar to <a>singleStrArg</a>, except that the flag can be given more
--   than once. The flag arguments are collected in a list of
--   <a>String</a>s.
multiStrArg :: [Char] -> [String] -> (String -> Flag) -> ([Flag] -> [String]) -> String -> String -> PrimDarcsOption [String]

-- | Similar to <a>multiStrArg</a>, except that the flag arguments are
--   optional.
multiOptStrArg :: [Char] -> [String] -> (Maybe String -> Flag) -> ([Flag] -> [Maybe String]) -> String -> String -> PrimDarcsOption [Maybe String]

-- | Construct a <tt><a>Maybe</a> <a>AbsolutePath</a></tt> valued option
--   with a single flag that takes an <a>AbsolutePath</a> argument and has
--   no default flag.
--   
--   The arguments are: short switches, long switches, flag constructor,
--   single flag parser, help string.
singleAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> (Flag -> Maybe AbsolutePath) -> String -> String -> PrimDarcsOption (Maybe AbsolutePath)

-- | Similar to <a>singleAbsPathArg</a>, except that the flag can be given
--   more than once. The flag arguments are collected in a list of
--   <a>AbsolutePath</a>s.
multiAbsPathArg :: [Char] -> [String] -> (AbsolutePath -> Flag) -> ([Flag] -> [AbsolutePath]) -> String -> String -> PrimDarcsOption [AbsolutePath]

-- | A deprecated option. If you want to deprecate only some flags and not
--   the whole option, extract the <a>RawOptSpec</a>s out of the original
--   option and create a new deprecated option. The strings in the first
--   argument are appended to the automatically generated error message in
--   case additional hints should be provided.
deprecated :: [String] -> [RawOptSpec Flag v] -> PrimDarcsOption ()
parseIntArg :: String -> (Int -> Bool) -> String -> Int
parseIndexRangeArg :: String -> (Int, Int)
showIntArg :: Int -> String
showIndexRangeArg :: (Int, Int) -> String
withDashes :: [Char] -> [String] -> [String]
data AbsolutePath

-- | This is for situations where a string (e.g. a command line argument)
--   may take the value "-" to mean stdin or stdout (which one depends on
--   context) instead of a normal file path.
data AbsolutePathOrStd
instance GHC.Classes.Eq Darcs.UI.Options.Util.ArgumentParseError
instance GHC.Exception.Type.Exception Darcs.UI.Options.Util.ArgumentParseError
instance GHC.Show.Show Darcs.UI.Options.Util.ArgumentParseError
instance Darcs.UI.Options.Iso.IsoFunctor (Darcs.UI.Options.Util.RawOptSpec f)

module Darcs.UI.Options.Markdown
optionsMarkdown :: [DarcsOptDescr f] -> String

module Darcs.Repository.Prefs
data Pref
Author :: Pref
Binaries :: Pref
Boring :: Pref
Defaultrepo :: Pref
Defaults :: Pref
Email :: Pref
Motd :: Pref
Post :: Pref
Prefs :: Pref
Repos :: Pref
Sources :: Pref
addToPreflist :: Pref -> String -> IO ()

-- | delete references to other repositories. Used when cloning to a ssh
--   destination. Assume the current working dir is the repository.
deleteSources :: IO ()
getPreflist :: Pref -> IO [String]
setPreflist :: Pref -> [String] -> IO ()
getGlobal :: Pref -> IO [String]
environmentHelpHome :: ([String], [String])
getDefaultRepo :: IO (Maybe String)

-- | addRepoSource adds a new entry to _darcs<i>prefs</i>repos and sets it
--   as default in _darcs<i>prefs</i>defaultrepo, unless --no-set-default
--   or --dry-run is passed, or it is the same repository as the current
--   one.
addRepoSource :: String -> DryRun -> SetDefault -> InheritDefault -> Bool -> IO ()
getPrefval :: String -> IO (Maybe String)
setPrefval :: String -> String -> IO ()
changePrefval :: String -> String -> String -> IO ()
defPrefval :: String -> String -> IO String
writeDefaultPrefs :: WithPrefsTemplates -> IO ()
isBoring :: IO (FilePath -> Bool)
data FileType
BinaryFile :: FileType
TextFile :: FileType
filetypeFunction :: IO (FilePath -> FileType)
getCaches :: UseCache -> Maybe AbsoluteOrRemotePath -> IO Cache
globalCacheDir :: IO (Maybe FilePath)

-- | The relative path of the global preference directory;
--   <tt>~/.darcs</tt> on Unix, and <tt>%APPDATA%/darcs</tt> on Windows.
--   This is used for online documentation.
globalPrefsDirDoc :: String

-- | The path of the global preference directory; <tt>~/.darcs</tt> on
--   Unix, and <tt>%APPDATA%/darcs</tt> on Windows.
globalPrefsDir :: IO (Maybe FilePath)

-- | Fetch and return the message of the day for a given repository.
getMotd :: String -> IO ByteString

-- | Display the message of the day for a given repository,
showMotd :: String -> IO ()
prefsUrl :: String -> Pref -> String
prefsDirPath :: String
prefsFilePath :: FilePath
getPrefLines :: FilePath -> IO [String]
prefsFilesHelp :: [(String, String)]
instance GHC.Classes.Eq Darcs.Repository.Prefs.FileType
instance GHC.Show.Show Darcs.Repository.Prefs.Pref
instance GHC.Read.Read Darcs.Repository.Prefs.Pref
instance GHC.Classes.Ord Darcs.Repository.Prefs.Pref
instance GHC.Classes.Eq Darcs.Repository.Prefs.Pref

module Darcs.Repository.InternalTypes

-- | A <tt>Repository</tt> is a token representing the state of a
--   repository on disk. It is parameterized by
--   
--   <ul>
--   <li><i><tt>rt</tt></i> the access type (whether we are in a
--   transaction or not),</li>
--   <li><i><tt>p</tt></i> the patch type,</li>
--   <li><i><tt>wU</tt></i> the witness for the unrecorded state (what's in
--   the working tree now).</li>
--   <li><i><tt>wR</tt></i> the witness for<ul><li>the recorded state when
--   outside a transaction, or</li><li>the tentative state when inside a
--   transaction.</li></ul></li>
--   </ul>
data Repository (rt :: AccessType) (p :: * -> * -> *) wU wR
data PristineType
NoPristine :: PristineType
PlainPristine :: PristineType
HashedPristine :: PristineType
data AccessType
RO :: AccessType
RW :: AccessType
data SAccessType (rt :: AccessType)
[SRO] :: SAccessType 'RO
[SRW] :: SAccessType 'RW
repoAccessType :: Repository rt p wU wR -> SAccessType rt
repoCache :: Repository rt p wU wR -> Cache
modifyCache :: (Cache -> Cache) -> Repository rt p wU wR -> Repository rt p wU wR
repoFormat :: Repository rt p wU wR -> RepoFormat
modifyRepoFormat :: (RepoFormat -> RepoFormat) -> Repository 'RW p wU wR -> IO (Repository 'RW p wU wR)
repoLocation :: Repository rt p wU wR -> String

-- | Perform an action with the current working directory set to the
--   <a>repoLocation</a>.
withRepoDir :: Repository rt p wU wR -> IO a -> IO a
repoPristineType :: Repository rt p wU wR -> PristineType
unsafeCoerceRepoType :: Repository rt p wU wR -> Repository rt' p wU wR
unsafeCoercePatchType :: Repository rt p wU wR -> Repository rt p' wU wR
unsafeCoerceR :: Repository rt p wU wR -> Repository rt p wU wR'
unsafeCoerceU :: Repository rt p wU wR -> Repository rt p wU' wR
unsafeEndTransaction :: Repository 'RW p wU wR -> Repository 'RO p wU wR

-- | Both <a>unsafeStartTransaction</a> and <a>unsafeEndTransaction</a> are
--   "unsafe" in the sense that they merely "coerce" the type but do not
--   actually perform the steps (<a>IO</a> actions) required to start or
--   end a transaction (this is done by <tt>revertRepositoryChanges</tt>
--   and <tt>finalizeRepositoryChanges</tt>). Technically this is not an
--   actual coercion like with e.g. <a>unsafeCoerceR</a>, due to the
--   singleton typed member, but in practical terms it is no less unsafe,
--   because <a>RO</a> vs. <a>RW</a> changes whether <tt>wR</tt> refers to
--   the recorded or the tentative state, respectively. In particular, you
--   will get different results if you are inside a transaction and read
--   the patchset with a "coerced" Repository of access type 'RO. The same
--   holds for other state that is modified in a transaction, like the
--   pending patch or the rebase state.
unsafeStartTransaction :: Repository 'RO p wU wR -> Repository 'RW p wU wR
mkRepo :: AbsoluteOrRemotePath -> RepoFormat -> PristineType -> Cache -> Repository 'RO p wU wR
instance GHC.Classes.Eq Darcs.Repository.InternalTypes.PristineType
instance GHC.Show.Show Darcs.Repository.InternalTypes.PristineType
instance GHC.Classes.Eq Darcs.Repository.InternalTypes.AccessType

module Darcs.Patch.SummaryData
data SummDetail
SummAddDir :: AnchoredPath -> SummDetail
SummRmDir :: AnchoredPath -> SummDetail
SummFile :: SummOp -> AnchoredPath -> Int -> Int -> Int -> SummDetail
SummMv :: AnchoredPath -> AnchoredPath -> SummDetail
SummNone :: SummDetail
data SummOp
SummAdd :: SummOp
SummRm :: SummOp
SummMod :: SummOp
instance GHC.Classes.Eq Darcs.Patch.SummaryData.SummOp
instance GHC.Classes.Ord Darcs.Patch.SummaryData.SummOp
instance GHC.Classes.Eq Darcs.Patch.SummaryData.SummDetail
instance GHC.Classes.Ord Darcs.Patch.SummaryData.SummDetail

module Darcs.Patch.Object

-- | Given a state type (parameterized over a monad m :: * -&gt; *), this
--   gives us the type of the key with which we can lookup an item (or
--   object) in the state.
type family ObjectIdOf (state :: (* -> *) -> *)

-- | We require from such a key (an <a>ObjectId</a>) that it has a
--   canonical way to format itself to a <a>Doc</a>. For historical
--   reasons, this takes a parameter of type <a>FileNameFormat</a>.
class Eq oid => ObjectId oid
formatObjectId :: ObjectId oid => FileNameFormat -> oid -> Doc

-- | Format a <a>AnchoredPath</a> to a <a>Doc</a> according to the given
--   <a>FileNameFormat</a>.
--   
--   NOTE: This is not only used for display but also to format patch
--   files. This is why we have to do the white space encoding here. See
--   <a>writePatchIfNecessary</a>.
--   
--   Besides white space encoding, for <a>FileNameFormatV2</a> we just pack
--   it into a <a>Doc</a>. For <a>FileNameFormatV1</a> we must emulate the
--   non-standard darcs-1 encoding of file paths: it is an UTF8 encoding of
--   the raw byte stream, interpreted as code points.
--   
--   See also <a>readFileName</a>.
formatFileName :: FileNameFormat -> AnchoredPath -> Doc
ap2fp :: AnchoredPath -> FilePath
instance Darcs.Patch.Object.ObjectId Darcs.Util.Path.AnchoredPath

module Darcs.Patch.Prim.FileUUID.ObjectMap
newtype UUID
UUID :: ByteString -> UUID

-- | An object is located by giving the <a>UUID</a> of the parent
--   <a>Directory</a> and a <a>Name</a>.
data Location
L :: !UUID -> !Name -> Location
data Object (m :: * -> *)
Directory :: DirContent -> Object (m :: * -> *)
Blob :: m FileContent -> !Maybe Hash -> Object (m :: * -> *)
data ObjectMap (m :: * -> *)
ObjectMap :: (UUID -> m (Maybe (Object m))) -> (UUID -> Object m -> m (ObjectMap m)) -> m [UUID] -> ObjectMap (m :: * -> *)
[getObject] :: ObjectMap (m :: * -> *) -> UUID -> m (Maybe (Object m))
[putObject] :: ObjectMap (m :: * -> *) -> UUID -> Object m -> m (ObjectMap m)
[listObjects] :: ObjectMap (m :: * -> *) -> m [UUID]
type DirContent = Map Name UUID
type FileContent = ByteString
isBlob :: Object m -> Bool
isDirectory :: Object m -> Bool
data Name
instance GHC.Show.Show Darcs.Patch.Prim.FileUUID.ObjectMap.UUID
instance GHC.Classes.Ord Darcs.Patch.Prim.FileUUID.ObjectMap.UUID
instance GHC.Classes.Eq Darcs.Patch.Prim.FileUUID.ObjectMap.UUID
instance GHC.Show.Show Darcs.Patch.Prim.FileUUID.ObjectMap.Location
instance GHC.Classes.Eq Darcs.Patch.Prim.FileUUID.ObjectMap.Location

module Darcs.Patch.Inspect
class PatchInspect p
listTouchedFiles :: PatchInspect p => p wX wY -> [AnchoredPath]
hunkMatches :: PatchInspect p => (ByteString -> Bool) -> p wX wY -> Bool
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Witnesses.Ordered.RL p)


-- | The purpose of this module is to deal with many of the common cases
--   that come up when choosing a subset of a group of patches.
--   
--   The idea is to divide a sequence of candidate patches into an initial
--   section named <a>InFirst</a>, a final section named <a>InLast</a>, and
--   between them a third section of not yet decided patches named
--   <a>InMiddle</a>. The reason for the neutral terminology
--   <a>InFirst</a>, <a>InMiddle</a>, and <a>InLast</a>, is that which of
--   <a>InFirst</a> and <a>InLast</a> counts as <tt>selected</tt> or
--   <tt>deselected</tt> depends on what we want to achive, that is, on the
--   command and its options. See <a>Darcs.UI.SelectChanges</a> for
--   examples of how to use the functions from this module.
--   
--   Obviously if there are dependencies between the patches that will put
--   a constraint on how you can choose to divide them up. Unless stated
--   otherwise, functions that move patches from one section to another
--   pull all dependent patches with them.
--   
--   Internally, we don't necessarily reorder patches immediately, but
--   merely tag them with the desired status, and thus postpone the actual
--   commutation. This saves a lot of unnecessary work, especially when
--   choices are made interactively, where the user can revise earlier
--   decisions.
module Darcs.Patch.Choices

-- | A sequence of <a>LabelledPatch</a>es where each patch is either
--   <a>InFirst</a>, <a>InMiddle</a>, or <a>InLast</a>. The representation
--   is optimized for the case where we start chosing patches from the left
--   of the sequence: patches that are <a>InFirst</a> are commuted to the
--   head immediately, but patches that are <a>InMiddle</a> or
--   <a>InLast</a> are mixed together; when a patch is marked
--   <a>InLast</a>, its dependencies are not updated until we retrieve the
--   final result.
data PatchChoices p wX wY

-- | See module documentation for <a>Darcs.Patch.Choices</a>.
data Slot
InFirst :: Slot
InMiddle :: Slot
InLast :: Slot

-- | Create a <a>PatchChoices</a> from a sequence of patches, so that all
--   patches are initially <a>InMiddle</a>.
patchChoices :: FL p wX wY -> PatchChoices p wX wY

-- | Create a <a>PatchChoices</a> from an already labelled sequence of
--   patches, so that all patches are initially <a>InMiddle</a>.
mkPatchChoices :: FL (LabelledPatch p) wX wY -> PatchChoices p wX wY

-- | Given a <a>LabelledPatch</a> determine to which section of the given
--   <a>PatchChoices</a> it belongs. This is not trivial to compute, since
--   a patch tagged as <a>InMiddle</a> may be forced to actually be
--   <a>InLast</a> by dependencies. We return a possibly re-ordered
--   <a>PatchChoices</a> so as not to waste the commutation effort.
patchSlot :: forall p wA wB wX wY. Commute p => LabelledPatch p wA wB -> PatchChoices p wX wY -> (Slot, PatchChoices p wX wY)

-- | Retrieve the resulting sections from a <a>PatchChoice</a>. The result
--   is a triple <tt>first:&gt;middle:&gt;last</tt>, such that all patches
--   in <tt>first</tt> are <a>InFirst</a>, all patches in <tt>middle</tt>
--   are <a>InMiddle</a>, and all patches in <tt>last</tt> are
--   <a>InLast</a>.
getChoices :: Commute p => PatchChoices p wX wY -> (FL (LabelledPatch p) :> (FL (LabelledPatch p) :> FL (LabelledPatch p))) wX wY

-- | Like <a>getChoices</a> but lumps together <a>InFirst</a> and
--   <a>InMiddle</a> patches.
--   
--   <pre>
--   separateFirstMiddleFromLast c == case getChoices c of f:&gt;m:&gt;l -&gt; f+&gt;+m:&gt;l
--   </pre>
separateFirstMiddleFromLast :: Commute p => PatchChoices p wX wZ -> (FL (LabelledPatch p) :> FL (LabelledPatch p)) wX wZ

-- | Like <a>getChoices</a> but lumps together <a>InMiddle</a> and
--   <a>InLast</a> patches. This is more efficient than using
--   <a>getChoices</a> and then catenating <a>InMiddle</a> and
--   <a>InLast</a> sections because we have to commute less. (This is what
--   <a>PatchChoices</a> are optimized for.)
--   
--   <pre>
--   separateFirstFromMiddleLast c == case getChoices c of f:&gt;m:&gt;l -&gt; f:&gt;m+&gt;+l
--   </pre>
separateFirstFromMiddleLast :: PatchChoices p wX wZ -> (FL (LabelledPatch p) :> FL (LabelledPatch p)) wX wZ

-- | Force all patches matching the given predicate to be <a>InFirst</a>,
--   pulling any dependencies with them. This even forces any patches that
--   were already tagged <a>InLast</a>.
forceMatchingFirst :: forall p wA wB. Commute p => (forall wX wY. LabelledPatch p wX wY -> Bool) -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Force all patches labelled with one of the given labels to be
--   <a>InFirst</a>, pulling any dependencies with them. This even forces
--   any patches that were already tagged <a>InLast</a>.
forceFirsts :: Commute p => [Label] -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Force a single patch labelled with the given label to be
--   <a>InFirst</a>, pulling any dependencies with them. This even forces
--   any patches that were already tagged <a>InLast</a>.
forceFirst :: Commute p => Label -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Similar to <a>forceMatchingFirst</a> only that patches are forced to
--   be <a>InLast</a> regardless of their previous status.
forceMatchingLast :: Commute p => (forall wX wY. LabelledPatch p wX wY -> Bool) -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Force all patches labelled with one of the given labels to be
--   <a>InLast</a>, pulling any dependencies with them. This even forces
--   any patches that were previously tagged <a>InFirst</a>.
forceLasts :: Commute p => [Label] -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Force a single patch labelled with the given label to be
--   <a>InLast</a>, pulling any dependencies with them, regardless of their
--   previous status.
forceLast :: Commute p => Label -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Force a patch with the given <a>Label</a> to be <a>InMiddle</a>,
--   pulling any dependencies with it, regardless of their previous status.
forceMiddle :: Commute p => Label -> PatchChoices p wA wB -> PatchChoices p wA wB

-- | Turn <a>InMiddle</a> patches into <a>InFirst</a> and <a>InLast</a>
--   patches into <a>InMiddle</a>. Does *not* pull dependencies into
--   <a>InFirst</a>, instead patches that cannot be commuted past
--   <a>InLast</a> patches stay <a>InMiddle</a>.
makeEverythingSooner :: forall p wX wY. Commute p => PatchChoices p wX wY -> PatchChoices p wX wY

-- | Turn <a>InFirst</a> patches into <a>InMiddle</a> ones and
--   <a>InMiddle</a> into <a>InLast</a> ones.
makeEverythingLater :: PatchChoices p wX wY -> PatchChoices p wX wY

-- | Make all <a>InMiddle</a> patches either <a>InFirst</a> or
--   <a>InLast</a>. This does *not* modify any patches that are already
--   determined to be <a>InLast</a> by dependencies.
selectAllMiddles :: forall p wX wY. Commute p => Bool -> PatchChoices p wX wY -> PatchChoices p wX wY

-- | Use the given monadic <a>PatchChoices</a> transformer on the
--   <a>InMiddle</a> section of a <a>PatchChoices</a>, then fold the result
--   back into the original <a>PatchChoices</a>.
refineChoices :: (Commute p, Monad m) => (forall wU wV. FL (LabelledPatch p) wU wV -> PatchChoices p wU wV -> m (PatchChoices p wU wV)) -> PatchChoices p wX wY -> m (PatchChoices p wX wY)

-- | Substitute a single <a>LabelledPatch</a> with an equivalent list of
--   patches, preserving its status as <a>InFirst</a>, <a>InMiddle</a> or
--   <a>InLast</a>). The patch is looked up using equality of
--   <a>Label</a>s.
substitute :: forall p wX wY. Sealed2 (LabelledPatch p :||: FL (LabelledPatch p)) -> PatchChoices p wX wY -> PatchChoices p wX wY

-- | A patch with a <a>Label</a> attached to it.
data LabelledPatch p wX wY

-- | <a>Label</a> <tt>mp i</tt> acts as a temporary identifier to help us
--   keep track of patches during the selection process. These are useful
--   for finding patches that may have moved around during patch selection
--   (being pushed forwards or backwards as dependencies arise).
--   
--   The identifier is implemented as a tuple <tt>Label mp i</tt>. The
--   <tt>i</tt> is an integer, expected to be unique within the patches
--   being scrutinised. The <tt>mp</tt> is motivated by patch splitting; it
--   provides a convenient way to generate a new identifier from the patch
--   being split. For example, if we split a patch identified as <tt>Label
--   Nothing 5</tt>, the resulting sub-patches could be identified as
--   <tt>Label (Just (Label Nothing 5))1</tt>, <tt>Label (Just (Label
--   Nothing 5)) 2</tt>, etc.
--   
--   IOW, <a>Label</a> is a non-empty, reversed list of <a>Int</a>s.
data Label
label :: LabelledPatch p wX wY -> Label
unLabel :: LabelledPatch p wX wY -> p wX wY

-- | Label a sequence of patches, maybe using the given parent label.
labelPatches :: Maybe Label -> FL p wX wY -> FL (LabelledPatch p) wX wY
getLabelInt :: Label -> Int
instance GHC.Classes.Eq Darcs.Patch.Choices.Label
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Choices.PatchChoice p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Choices.PatchChoice p)
instance Darcs.Patch.Invert.Invert p => Darcs.Patch.Invert.Invert (Darcs.Patch.Choices.LabelledPatch p)
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Choices.LabelledPatch p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Choices.LabelledPatch p)

module Darcs.Patch.ApplyMonad
class (Monad m, ApplyMonadOperations state m) => ApplyMonad (state :: (* -> *) -> *) m | m -> state
readFilePS :: ApplyMonad state m => ObjectIdOf state -> m ByteString
class (Monad m, ApplyMonad state (ApplyMonadOver state m)) => ApplyMonadTrans state m where {
    type ApplyMonadOver state m :: * -> *;
}
runApplyMonad :: ApplyMonadTrans state m => ApplyMonadOver state m x -> state m -> m (x, state m)
type family ApplyMonadOperations (state :: (* -> *) -> *) :: (* -> *) -> Constraint

-- | withFileNames takes a maybe list of existing rename-pairs, a list of
--   filenames and an action, and returns the resulting triple of affected
--   files, updated filename list and new rename details. If the
--   rename-pairs are not present, a new list is generated from the
--   filesnames.
withFileNames :: Maybe [OrigFileNameOf] -> [AnchoredPath] -> FilePathMonad a -> FilePathMonadState
class MonadThrow m => ApplyMonadTree m
mDoesDirectoryExist :: ApplyMonadTree m => AnchoredPath -> m Bool
mDoesFileExist :: ApplyMonadTree m => AnchoredPath -> m Bool
mReadFilePS :: ApplyMonadTree m => AnchoredPath -> m ByteString
mCreateDirectory :: ApplyMonadTree m => AnchoredPath -> m ()
mRemoveDirectory :: ApplyMonadTree m => AnchoredPath -> m ()
mCreateFile :: ApplyMonadTree m => AnchoredPath -> m ()
mRemoveFile :: ApplyMonadTree m => AnchoredPath -> m ()
mRename :: ApplyMonadTree m => AnchoredPath -> AnchoredPath -> m ()
mModifyFilePS :: ApplyMonadTree m => AnchoredPath -> (ByteString -> m ByteString) -> m ()
mChangePref :: ApplyMonadTree m => String -> String -> String -> m ()
evalApplyMonad :: ApplyMonadTrans state m => ApplyMonadOver state m a -> state m -> m a
instance GHC.Base.Monad Darcs.Patch.ApplyMonad.Pure
instance GHC.Base.Applicative Darcs.Patch.ApplyMonad.Pure
instance GHC.Base.Functor Darcs.Patch.ApplyMonad.Pure
instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Patch.ApplyMonad.FilePathMonad
instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Patch.ApplyMonad.FilePathMonad
instance Control.Monad.Catch.MonadThrow Darcs.Patch.ApplyMonad.Pure
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.ApplyMonad.ApplyMonadTrans Darcs.Util.Tree.Tree m
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree (Darcs.Util.Tree.Monad.TreeMonad m)
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.ApplyMonad.ApplyMonadTree (Darcs.Util.Tree.Monad.TreeMonad m)

module Darcs.Repository.ApplyPatches

-- | Apply patches, emitting warnings if there are any IO errors
runTolerantly :: TolerantWrapper TolerantIO a -> IO a

-- | Apply patches, ignoring all errors
runSilently :: TolerantWrapper SilentIO a -> IO a
data DefaultIO a

-- | The default mode of applying patches: fail if the directory is not as
--   we expect
runDefault :: DefaultIO a -> IO a
instance Control.Monad.Catch.MonadThrow Darcs.Repository.ApplyPatches.DefaultIO
instance GHC.Base.Monad Darcs.Repository.ApplyPatches.DefaultIO
instance GHC.Base.Applicative Darcs.Repository.ApplyPatches.DefaultIO
instance GHC.Base.Functor Darcs.Repository.ApplyPatches.DefaultIO
instance Control.Monad.Catch.MonadThrow Darcs.Repository.ApplyPatches.TolerantIO
instance GHC.Base.Monad Darcs.Repository.ApplyPatches.TolerantIO
instance GHC.Base.Applicative Darcs.Repository.ApplyPatches.TolerantIO
instance GHC.Base.Functor Darcs.Repository.ApplyPatches.TolerantIO
instance Control.Monad.Catch.MonadThrow Darcs.Repository.ApplyPatches.SilentIO
instance GHC.Base.Monad Darcs.Repository.ApplyPatches.SilentIO
instance GHC.Base.Applicative Darcs.Repository.ApplyPatches.SilentIO
instance GHC.Base.Functor Darcs.Repository.ApplyPatches.SilentIO
instance Darcs.Repository.ApplyPatches.TolerantMonad m => Darcs.Repository.ApplyPatches.TolerantMonad (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance GHC.Base.Monad m => GHC.Base.Monad (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance GHC.Base.Functor m => GHC.Base.Functor (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance Darcs.Repository.ApplyPatches.TolerantMonad m => Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance Darcs.Repository.ApplyPatches.TolerantMonad m => Darcs.Patch.ApplyMonad.ApplyMonadTree (Darcs.Repository.ApplyPatches.TolerantWrapper m)
instance Darcs.Repository.ApplyPatches.TolerantMonad Darcs.Repository.ApplyPatches.SilentIO
instance Darcs.Repository.ApplyPatches.TolerantMonad Darcs.Repository.ApplyPatches.TolerantIO
instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Repository.ApplyPatches.DefaultIO
instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Repository.ApplyPatches.DefaultIO


module Darcs.Patch.Apply
class Apply p where {
    type ApplyState p :: (* -> *) -> *;
}
apply :: (Apply p, ApplyMonad (ApplyState p) m) => p wX wY -> m ()
unapply :: (Apply p, ApplyMonad (ApplyState p) m) => p wX wY -> m ()
unapply :: (Apply p, ApplyMonad (ApplyState p) m, Invert p) => p wX wY -> m ()
type ObjectIdOfPatch p = ObjectIdOf (ApplyState p)
applyToPaths :: (Apply p, ApplyState p ~ Tree) => p wX wY -> Maybe [(AnchoredPath, AnchoredPath)] -> [AnchoredPath] -> ([AnchoredPath], [AnchoredPath], [(AnchoredPath, AnchoredPath)])

-- | Apply a patch to a <a>Tree</a>, yielding a new <a>Tree</a>.
applyToTree :: (Apply p, MonadThrow m, ApplyState p ~ Tree) => p wX wY -> Tree m -> m (Tree m)
applyToState :: forall p m wX wY. (Apply p, ApplyMonadTrans (ApplyState p) m) => p wX wY -> ApplyState p m -> m (ApplyState p m)

-- | Attempts to apply a given patch to a Tree. If the apply fails, we
--   return Nothing, otherwise we return the updated Tree.
maybeApplyToTree :: (Apply p, ApplyState p ~ Tree, MonadCatch m) => p wX wY -> Tree m -> m (Maybe (Tree m))
effectOnPaths :: (Apply p, ApplyState p ~ Tree) => p wX wY -> [AnchoredPath] -> [AnchoredPath]
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.TouchesFiles
lookTouch :: (Apply p, ApplyState p ~ Tree) => Maybe [(AnchoredPath, AnchoredPath)] -> [AnchoredPath] -> p wX wY -> (Bool, [AnchoredPath], [AnchoredPath], [(AnchoredPath, AnchoredPath)])
chooseTouching :: (Apply p, Commute p, PatchInspect p, ApplyState p ~ Tree) => Maybe [AnchoredPath] -> FL p wX wY -> Sealed (FL p wX)
deselectNotTouching :: (Apply p, Commute p, PatchInspect p, ApplyState p ~ Tree) => Maybe [AnchoredPath] -> PatchChoices p wX wY -> PatchChoices p wX wY
selectNotTouching :: (Apply p, Commute p, PatchInspect p, ApplyState p ~ Tree) => Maybe [AnchoredPath] -> PatchChoices p wX wY -> PatchChoices p wX wY

module Darcs.Patch.Show
class ShowPatchBasic p
showPatch :: ShowPatchBasic p => ShowPatchFor -> p wX wY -> Doc
displayPatch :: ShowPatchBasic p => p wX wY -> Doc
data ShowPatchFor
ForDisplay :: ShowPatchFor
ForStorage :: ShowPatchFor

-- | This class is used only for user interaction, not for storage. The
--   default implementations for <a>description</a> and <a>content</a> are
--   suitable only for <tt>PrimPatch</tt> and <tt>RepoPatch</tt> types.
--   Logically, <a>description</a> should default to <a>mempty</a> while
--   <a>content</a> should default to <a>displayPatch</a>. We define them
--   the other way around so that <a>showFriendly</a> gives reasonable
--   results for all patch types.
class ShowPatchBasic p => ShowPatch p
content :: ShowPatch p => p wX wY -> Doc
description :: ShowPatch p => p wX wY -> Doc
summary :: ShowPatch p => p wX wY -> Doc
summaryFL :: ShowPatch p => FL p wX wY -> Doc
thing :: ShowPatch p => p wX wY -> String
things :: ShowPatch p => p wX wY -> String
class ShowPatchBasic p => ShowContextPatch p

-- | Show a patch with context lines added, as diff -u does. Thus, it
--   differs from showPatch only for hunks. It is used for instance before
--   putting it into a bundle. As this unified context is not included in
--   patch representation, this requires access to the <a>ApplyState</a>.
--   
--   Note that this applies the patch in the <a>ApplyMonad</a> given by the
--   context. This is done in order to simplify showing multiple patches in
--   a series, since each patch may change the context lines for later
--   changes.
--   
--   For a version that does not apply the patch see
--   <a>showPatchWithContext</a>.
showPatchWithContextAndApply :: (ShowContextPatch p, ApplyMonad (ApplyState p) m) => ShowPatchFor -> p wX wY -> m Doc

-- | Like <a>showPatchWithContextAndApply</a> but without applying the
--   patch in the monad <tt>m</tt>.
showPatchWithContext :: (ApplyMonadTrans (ApplyState p) m, ShowContextPatch p) => ShowPatchFor -> ApplyState p m -> p wX wY -> m Doc

-- | Format a <a>AnchoredPath</a> to a <a>Doc</a> according to the given
--   <a>FileNameFormat</a>.
--   
--   NOTE: This is not only used for display but also to format patch
--   files. This is why we have to do the white space encoding here. See
--   <a>writePatchIfNecessary</a>.
--   
--   Besides white space encoding, for <a>FileNameFormatV2</a> we just pack
--   it into a <a>Doc</a>. For <a>FileNameFormatV1</a> we must emulate the
--   non-standard darcs-1 encoding of file paths: it is an UTF8 encoding of
--   the raw byte stream, interpreted as code points.
--   
--   See also <a>readFileName</a>.
formatFileName :: FileNameFormat -> AnchoredPath -> Doc

module Darcs.Patch.Info

-- | A PatchInfo value contains the metadata of a patch. The date, name,
--   author and log fields are UTF-8 encoded text in darcs 2.4 and later,
--   and just sequences of bytes (decoded with whatever is the locale when
--   displayed) in earlier darcs.
--   
--   The members with names that start with '_' are not supposed to be used
--   directly in code that does not care how the patch info is stored.
--   
--   <tt>_piLegacyIsInverted</tt>:
--   
--   Historically, the <tt>isInverted</tt> flag was used to indicate that a
--   Named patch was inverted.
--   
--   We no longer support direct inversion of <a>Named</a> patches, except
--   sometimes via the <a>Invertible</a> wrapper which tracks inversion in
--   the wrapper.
--   
--   However, going even further back in time, inverted patches could be
--   written out by <tt>darcs rollback</tt>. This was changed in 2008 so
--   any patches on disk with this flag set would have been written by a
--   darcs from prior to then. As they still exist, including in the darcs
--   repository itself, we need to support them.
--   
--   As far as current darcs is concerned, the flag should be treated like
--   any other field in <a>PatchInfo</a> apart from never being set
--   freshly:
--   
--   <ul>
--   <li>There is no semantic relationship between a <a>PatchInfo</a> with
--   <tt>piLegacyIsInverted = False</tt> and the same <a>PatchInfo</a> with
--   <tt>piLegacyIsInverted = True</tt>. For example they are not inverses
--   of each other.</li>
--   <li>New or amended patches should never be written out with
--   <tt>_piLegacyIsInverted = True</tt>.</li>
--   <li>We do need to maintain backwards compatibility so we take care to
--   preserve things like the hash, on-disk format etc.</li>
--   <li>A patch with <tt>_piLegacyIsInverted = True</tt> should work with
--   all the normal darcs operations.</li>
--   </ul>
--   
--   The flag is completely separate and orthogonal to the tracking of
--   explicit inversion in the <a>Invertible</a> wrapper. The
--   <a>Invertible</a> wrapper is only used in memory and never stored to
--   disk so there should be no confusion when reading a patch from disk.
--   Within the codebase they serve completely different purposes and
--   should not interact at all.
data PatchInfo
PatchInfo :: !ByteString -> !ByteString -> !ByteString -> ![ByteString] -> !Bool -> PatchInfo
[_piDate] :: PatchInfo -> !ByteString
[_piName] :: PatchInfo -> !ByteString
[_piAuthor] :: PatchInfo -> !ByteString
[_piLog] :: PatchInfo -> ![ByteString]

-- | See the long description of this field in the docs above.
[_piLegacyIsInverted] :: PatchInfo -> !Bool
rawPatchInfo :: TestOnly => String -> String -> String -> [String] -> Bool -> PatchInfo

-- | <tt>patchinfo date name author log</tt> constructs a new
--   <a>PatchInfo</a> value with the given details, automatically assigning
--   an Ignore-this header to guarantee the patch is unique. The function
--   does not verify the date string's sanity.
patchinfo :: String -> String -> String -> [String] -> IO PatchInfo

-- | addJunk adds a line that contains a random number to make the patch
--   unique.
addJunk :: PatchInfo -> IO PatchInfo
replaceJunk :: PatchInfo -> IO PatchInfo

-- | Hash on patch metadata (patch name, author, date, log, and the legacy
--   "inverted" flag. Robust against context changes but does not guarantee
--   patch contents. Usually used as matcher or patch identifier (see
--   Darcs.Patch.Match).
makePatchname :: PatchInfo -> SHA1

-- | Parser for <a>PatchInfo</a> as stored in patch bundles and inventory
--   files, for example:
--   
--   <pre>
--   [Document the foo interface
--   John Doe &lt;john.doe@example.com&gt;**20110615084241
--    Ignore-this: 85b94f67d377c4ab671101266ef9c229
--    Nobody knows what a 'foo' is, so describe it.
--   ]
--   </pre>
--   
--   See <a>showPatchInfo</a> for the inverse operation.
readPatchInfo :: Parser PatchInfo

-- | Get the name, including an "UNDO: " prefix if the patch is a legacy
--   inverted patch.
justName :: PatchInfo -> String

-- | Returns the author of a patch.
justAuthor :: PatchInfo -> String
justLog :: PatchInfo -> String
displayPatchInfo :: PatchInfo -> Doc
toXml :: PatchInfo -> Doc
toXmlShort :: PatchInfo -> Doc
piDate :: PatchInfo -> CalendarTime
piDateString :: PatchInfo -> String

-- | Returns the name of the patch. Unlike <a>justName</a>, it does not
--   preprend "UNDO: " to the name if the patch has the legacy inverted
--   flag set.
piName :: PatchInfo -> String
piRename :: PatchInfo -> String -> PatchInfo

-- | Returns the author of a patch.
piAuthor :: PatchInfo -> String

-- | Get the tag name, if the patch is a tag patch.
piTag :: PatchInfo -> Maybe String

-- | Get the log message of a patch.
piLog :: PatchInfo -> [String]
showPatchInfo :: ShowPatchFor -> PatchInfo -> Doc
isTag :: PatchInfo -> Bool
escapeXML :: String -> Doc
validDate :: String -> Bool
validLog :: String -> Bool
validAuthor :: String -> Bool
validDatePS :: ByteString -> Bool
validLogPS :: ByteString -> Bool
validAuthorPS :: ByteString -> Bool
instance GHC.Show.Show Darcs.Patch.Info.PatchInfo
instance GHC.Classes.Ord Darcs.Patch.Info.PatchInfo
instance GHC.Classes.Eq Darcs.Patch.Info.PatchInfo

module Darcs.Repository.Inventory.Format
data Inventory
Inventory :: Maybe InventoryHash -> [InventoryEntry] -> Inventory
[inventoryParent] :: Inventory -> Maybe InventoryHash
[inventoryPatches] :: Inventory -> [InventoryEntry]
type HeadInventory = (PristineHash, Inventory)
type InventoryEntry = (PatchInfo, PatchHash)

-- | External API for the various hash types.
class (Eq h, IsSizeHash h) => ValidHash h

-- | The <a>HashedDir</a> belonging to this type of hash
dirofValidHash :: ValidHash h => h -> HashedDir

-- | Compute hash from file content.
calcValidHash :: ValidHash h => ByteString -> h
decodeValidHash :: ValidHash h => String -> Maybe h
encodeValidHash :: ValidHash h => h -> String
data InventoryHash
data PatchHash
data PristineHash
inventoryPatchNames :: Inventory -> [String]
parseInventory :: ByteString -> Either String Inventory
parseHeadInventory :: ByteString -> Either String HeadInventory
showInventory :: Inventory -> Doc
showInventoryPatches :: [InventoryEntry] -> Doc
showInventoryEntry :: InventoryEntry -> Doc
emptyInventory :: Inventory

-- | Replace the pristine hash at the start of a raw, unparsed
--   <a>HeadInventory</a> or add it if none is present.
pokePristineHash :: PristineHash -> ByteString -> Doc
peekPristineHash :: ByteString -> PristineHash

-- | skipPristineHash drops the 'pristine: HASH' prefix line, if present.
skipPristineHash :: ByteString -> ByteString
pristineName :: ByteString
prop_inventoryParseShow :: Inventory -> Bool
prop_peekPokePristineHash :: (PristineHash, ByteString) -> Bool
prop_skipPokePristineHash :: (PristineHash, ByteString) -> Bool
instance GHC.Show.Show Darcs.Repository.Inventory.Format.Inventory
instance GHC.Classes.Eq Darcs.Repository.Inventory.Format.Inventory

module Darcs.Patch.Index.Types

-- | The FileId for a file consists of the FilePath (creation name) and an
--   index. The index denotes how many files with the same name have been
--   added before (and subsequently deleted or moved)
data FileId
FileId :: AnchoredPath -> Int -> FileId
[cname] :: FileId -> AnchoredPath
[count] :: FileId -> Int

-- | Convert FileId to string
showFileId :: FileId -> String

-- | The PatchId identifies a patch and can be created from a PatchInfo
--   with makePatchname
newtype PatchId
PID :: SHA1 -> PatchId
[patchId] :: PatchId -> SHA1
pid2string :: PatchId -> String
short :: PatchId -> Int
zero :: PatchId
makePatchID :: PatchInfo -> PatchId
instance GHC.Classes.Ord Darcs.Patch.Index.Types.FileId
instance GHC.Show.Show Darcs.Patch.Index.Types.FileId
instance GHC.Classes.Eq Darcs.Patch.Index.Types.FileId
instance GHC.Classes.Eq Darcs.Patch.Index.Types.PatchId
instance GHC.Classes.Ord Darcs.Patch.Index.Types.PatchId
instance GHC.Show.Show Darcs.Patch.Index.Types.PatchId
instance Data.Binary.Class.Binary Darcs.Patch.Index.Types.PatchId
instance Data.Binary.Class.Binary Darcs.Patch.Index.Types.FileId

module Darcs.Patch.Ident

-- | Class of patches that have an identity/name.
--   
--   Patches with an identity give rise to the notion of <i>nominal
--   equality</i>, expressed by the operators <a>=\^/=</a> and
--   <a>=/^\=</a>.
--   
--   Laws:
--   
--   <ul>
--   <li><i><i>ident-commute</i></i> Patch identity must be invariant under
--   commutation:<pre>'commute' (p :&gt; _) == 'Just' (_ :&gt; p') =&gt;
--   'ident' p == 'ident' p'</pre>and thus (via symmetry of
--   <a>commute</a>):<pre>'commute' (_ :&gt; q) == 'Just' (q' :&gt; _)
--   =&gt; 'ident' q == 'ident' q'</pre>Conversely, patches with the same
--   identity result from a series of <a>commute</a>s:<pre>'ident' p ==
--   'ident' p' =&gt; exists qs, qs' :: FL p. 'commuteFL' (p :&gt; qs) ==
--   'Just' (qs' :&gt; p')</pre></li>
--   <li><i><i>ident-compare</i></i> In general, comparing patches via
--   their identity is weaker than (semantic) equality:<pre>'unsafeCompare'
--   p q =&gt; 'ident' p == 'ident' q</pre>However, if the patches have a
--   common context, then semantic and nominal equality should coincide, up
--   to internal re-ordering:<pre>p '=\~/=' q &lt;=&gt; p '=\^/='
--   q</pre><pre>p '=/~\=' q &lt;=&gt; p '=/^\=' q</pre>(Technical note:
--   equality up to internal re-ordering is currently only defined for
--   <a>FL</a>s, but it should be obvious how to generalize it.)</li>
--   </ul>
--   
--   Taken together, these laws express the assumption that recording a
--   patch gives it a universally unique identity.
--   
--   Note that violations of this universal property are currently not
--   detected in a reliable way. Fixing this is possible but far from easy.
class Ord (PatchId p) => Ident p
ident :: Ident p => p wX wY -> PatchId p

-- | Constraint for patches that have an identity that is signed, i.e. can
--   be positive (uninverted) or negative (inverted).
--   
--   Provided that an instance <tt>Invert</tt> exists, inverting a patch
--   inverts its identity:
--   
--   <pre>
--   'ident' ('invert' p) = 'invertId' ('ident' p)
--   </pre>
type SignedIdent p = (Ident p, SignedId (PatchId p))

-- | The reason this is not associated to class <a>Ident</a> is that for
--   technical reasons we want to be able to define type instances for
--   patches that don't have an identity and therefore cannot be lawful
--   members of class <a>Ident</a>.
type family PatchId (p :: * -> * -> *)

-- | Nominal equality for patches with an identity in the same context.
--   Usually quite a bit faster than structural equality.
(=\^/=) :: Ident p => p wA wB -> p wA wC -> EqCheck wB wC
(=/^\=) :: Ident p => p wA wC -> p wB wC -> EqCheck wA wB

-- | Signed identities.
--   
--   Like for class <tt>Invert</tt>, we require that <a>invertId</a> is
--   self-inverse:
--   
--   <pre>
--   'invertId' . 'invertId' = 'id'
--   </pre>
--   
--   We also require that inverting changes the sign:
--   
--   <pre>
--   'positiveId' . 'invertId' = 'not' . 'positiveId'
--   </pre>
--   
--   Side remark: in mathematical terms, these properties can be expressed
--   by stating that <a>invertId</a> is an involution and that
--   <a>positiveId</a> is a "homomorphism of sets with an involution"
--   (there is no official term for this) from <tt>a</tt> to the simplest
--   non-trivial set with involution, namely <a>Bool</a> with the
--   involution <a>not</a>.
class Ord a => SignedId a
positiveId :: SignedId a => a -> Bool
invertId :: SignedId a => a -> a

-- | Storable identities.
--   
--   The methods here can be used to help implement ReadPatch and ShowPatch
--   for a patch type containing the identity.
--   
--   As with all Read/Show pairs, We expect that the output of <tt>showId
--   ForStorage x</tt> can be parsed by <a>readId</a> to produce
--   <tt>x</tt>:
--   
--   <pre>
--   'parse' 'readId' . 'renderPS' . 'showId' 'ForStorage' == 'id'
--   </pre>
class StorableId a
readId :: StorableId a => Parser a
showId :: StorableId a => ShowPatchFor -> a -> Doc

-- | Remove a patch from an FL of patches with an identity. The result is
--   <a>Just</a> whenever the patch has been found and removed and
--   <a>Nothing</a> otherwise. If the patch is not found at the head of the
--   sequence we must first commute it to the head before we can remove it.
--   
--   We assume that this commute always succeeds. This is justified because
--   patches are created with a (universally) unique identity, implying
--   that if two patches have the same identity, then they have originally
--   been the same patch; thus being at a different position must be due to
--   commutation, meaning we can commute it back.
--   
--   For patch types that define semantic equality via nominal equality,
--   this is only faster than <tt>removeFL</tt> if the patch does not occur
--   in the sequence, otherwise we have to perform the same number of
--   commutations.
fastRemoveFL :: forall p wX wY wZ. (Commute p, Ident p) => p wX wY -> FL p wX wZ -> Maybe (FL p wY wZ)

-- | Same as <a>fastRemoveFL</a> only for <a>RL</a>.
fastRemoveRL :: forall p wX wY wZ. (Commute p, Ident p) => p wY wZ -> RL p wX wZ -> Maybe (RL p wX wY)
fastRemoveSubsequenceRL :: (Commute p, Ident p) => RL p wY wZ -> RL p wX wZ -> Maybe (RL p wX wY)

-- | Find the common and uncommon parts of two lists that start in a common
--   context, using patch identity for comparison. Of the common patches,
--   only one is retained, the other is discarded.
findCommonFL :: (Commute p, Ident p) => FL p wX wY -> FL p wX wZ -> Fork (FL p) (FL p) (FL p) wX wY wZ
findCommonRL :: (Commute p, Ident p) => RL p wX wY -> RL p wX wZ -> Fork (RL p) (RL p) (RL p) wX wY wZ
findCommonWithThemFL :: (Commute p, Ident p) => FL p wX wY -> FL p wX wZ -> (FL p :> FL p) wX wY
findCommonWithThemRL :: (Commute p, Ident p) => RL p wX wY -> RL p wX wZ -> (RL p :> RL p) wX wY

-- | Try to commute all patches matching any of the <a>PatchId</a>s in the
--   set to the head of an <a>FL</a>, i.e. backwards in history.
commuteToPrefix :: (Commute p, Ident p) => Set (PatchId p) -> FL p wX wY -> Maybe ((FL p :> RL p) wX wY)
prop_identInvariantUnderCommute :: (Commute p, Ident p) => (p :> p) wX wY -> Maybe Bool
prop_sameIdentityImpliesCommutable :: (Commute p, Eq2 p, Ident p) => (p :\/: (RL p :> p)) wX wY -> Maybe Bool
prop_equalImpliesSameIdentity :: (Eq2 p, Ident p) => p wA wB -> p wC wD -> Maybe Bool
prop_sameIdentityImpliesEqual :: (Eq2 p, Ident p) => (p :\/: p) wX wY -> Maybe Bool
instance Darcs.Patch.Ident.Ident p => Darcs.Patch.Ident.Ident (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Ident.Ident p => Darcs.Patch.Ident.Ident (Darcs.Patch.Witnesses.Ordered.RL p)
instance Darcs.Patch.Ident.Ident p => Darcs.Patch.Ident.Ident (p Darcs.Patch.Witnesses.Ordered.:> p)

module Darcs.Patch.Bracketed

-- | This type exists for legacy support of on-disk format patch formats.
--   It is a wrapper type that explicitly tracks the nesting of braces and
--   parens in the on-disk representation of such patches. It is used as an
--   intermediate form when reading such patches normally, and also for
--   round-tripping such patches when checking the hash in bundles. It
--   shouldn't be used for anything else.
data Bracketed p wX wY
[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
mapBracketed :: (forall wA wB. p wA wB -> q wA wB) -> Bracketed p wX wY -> Bracketed q wX wY
unBracketed :: Bracketed p wX wY -> FL p wX wY
type BracketedFL p wX wY = FL (Bracketed p) wX wY
mapBracketedFLFL :: (forall wA wB. p wA wB -> q wA wB) -> BracketedFL p wX wY -> BracketedFL q wX wY
unBracketedFL :: BracketedFL p wX wY -> FL p wX wY
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Bracketed.Bracketed p)
instance Darcs.Patch.Show.ShowPatchBasic p => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Bracketed.Bracketed p)

module Darcs.Patch.Read

-- | This class is used to decode patches from their binary representation.
class ReadPatch p
readPatch' :: ReadPatch p => Parser (Sealed (p wX))
readPatch :: ReadPatch p => ByteString -> Either String (Sealed (p wX))
readPatchPartial :: ReadPatch p => ByteString -> Either String (Sealed (p wX), ByteString)
bracketedFL :: forall p wX. (forall wY. Parser (Sealed (p wY))) -> Char -> Char -> Parser (Sealed (FL p wX))
peekfor :: ByteString -> Parser a -> Parser a -> Parser a
readFileName :: HasCallStack => FileNameFormat -> Parser AnchoredPath
instance Darcs.Patch.Read.ReadPatch p => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Bracketed.Bracketed p)
instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Format.PatchListFormat p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Witnesses.Ordered.FL p)
instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Format.PatchListFormat p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.Repair

-- | <a>Repair</a> and <a>RepairToFL</a> deal with repairing old patches
--   that were were written out due to bugs or that we no longer wish to
--   support. <a>Repair</a> is implemented by collections of patches (FL,
--   Named, PatchInfoAnd) that might need repairing.
class Repair p
applyAndTryToFix :: (Repair p, ApplyMonad (ApplyState p) m) => p wX wY -> m (Maybe (String, p wX wY))

-- | <a>RepairToFL</a> is implemented by single patches that can be
--   repaired (Prim, Patch, RepoPatchV2) There is a default so that patch
--   types with no current legacy problems don't need to have an
--   implementation.
class Apply p => RepairToFL p
applyAndTryToFixFL :: (RepairToFL p, ApplyMonad (ApplyState p) m) => p wX wY -> m (Maybe (String, FL p wX wY))
mapMaybeSnd :: (a -> b) -> Maybe (c, a) -> Maybe (c, b)
class Check p
isInconsistent :: Check p => p wX wY -> Maybe Doc
instance Darcs.Patch.Repair.RepairToFL p => Darcs.Patch.Repair.Repair (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Repair.Check p => Darcs.Patch.Repair.Check (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Repair.Check p => Darcs.Patch.Repair.Check (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.Index.Monad
withPatchMods :: FileModMonad a -> Set AnchoredPath -> FileModState

-- | Apply a patch to set of <a>AnchoredPath</a>s, yielding the new set of
--   <a>AnchoredPath</a>s and <a>FileMod</a>s
applyToFileMods :: (Apply p, ApplyState p ~ Tree) => p wX wY -> Set AnchoredPath -> FileModState

-- | This is used to track changes to files
data FileMod a
PTouch :: a -> FileMod a
PCreateFile :: a -> FileMod a
PCreateDir :: a -> FileMod a
PRename :: a -> a -> FileMod a
PRemove :: a -> FileMod a

-- | this is used for duplicate patches that don't have any effect, but we
--   still want to keep track of them
PDuplicateTouch :: a -> FileMod a
instance GHC.Base.Functor Darcs.Patch.Index.Monad.FileMod
instance GHC.Classes.Eq a => GHC.Classes.Eq (Darcs.Patch.Index.Monad.FileMod a)
instance GHC.Show.Show a => GHC.Show.Show (Darcs.Patch.Index.Monad.FileMod a)
instance Control.Monad.State.Class.MonadState Darcs.Patch.Index.Monad.FileModState Darcs.Patch.Index.Monad.FileModMonad
instance Control.Monad.Catch.MonadThrow Darcs.Patch.Index.Monad.FileModMonad
instance GHC.Base.Monad Darcs.Patch.Index.Monad.FileModMonad
instance GHC.Base.Applicative Darcs.Patch.Index.Monad.FileModMonad
instance GHC.Base.Functor Darcs.Patch.Index.Monad.FileModMonad
instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Patch.Index.Monad.FileModMonad
instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Patch.Index.Monad.FileModMonad

module Darcs.Patch.FileHunk
data FileHunk oid wX wY
FileHunk :: oid -> !Int -> [ByteString] -> [ByteString] -> FileHunk oid wX wY
class IsHunk p
isHunk :: IsHunk p => p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)
showFileHunk :: ObjectId oid => FileNameFormat -> FileHunk oid wX wY -> Doc
showContextFileHunk :: ObjectId oid => FileNameFormat -> [ByteString] -> FileHunk oid wB wC -> [ByteString] -> Doc
instance Darcs.Patch.Invert.Invert (Darcs.Patch.FileHunk.FileHunk oid)

module Darcs.Patch.Viewing
showContextHunk :: (ApplyMonad state m, oid ~ ObjectIdOf state, ObjectId oid) => FileNameFormat -> FileHunk oid wX wY -> m Doc
instance (Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Witnesses.Ordered.FL p)
instance (Darcs.Patch.Apply.Apply p, Darcs.Patch.FileHunk.IsHunk p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowContextPatch p, Darcs.Patch.Object.ObjectId (Darcs.Patch.Apply.ObjectIdOfPatch p)) => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Witnesses.Ordered.FL p)
instance (Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Witnesses.Ordered.FL p)
instance (Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Witnesses.Ordered.RL p)
instance (Darcs.Patch.Show.ShowContextPatch p, Darcs.Patch.Apply.Apply p, Darcs.Patch.FileHunk.IsHunk p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Object.ObjectId (Darcs.Patch.Apply.ObjectIdOfPatch p)) => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Witnesses.Ordered.RL p)
instance (Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Witnesses.Ordered.RL p)


-- | <a>Contexted</a> patches.
module Darcs.Patch.V3.Contexted
data Contexted p wX

-- | Identity of a contexted patch.
ctxId :: Ident p => Contexted p wX -> PatchId p

-- | We sometimes want to pattern match on a <a>Contexted</a> patch but
--   still guard against violation of the invariants. So we export a view
--   that is isomorphic to the <a>Contexted</a> type but doesn't allow to
--   manipulate the internals.
ctxView :: Contexted p wX -> Sealed ((FL p :> p) wX)

-- | <a>Contexted</a> patches conflict with each other if the identity of
--   one is in the context of the other or they cannot be merged cleanly.
ctxNoConflict :: (CleanMerge p, Commute p, Ident p) => Contexted p wX -> Contexted p wX -> Bool

-- | Convert a <a>Contexted</a> patch into a plain <a>FL</a> with the patch
--   at the end.
ctxToFL :: Contexted p wX -> Sealed (FL p wX)

-- | Wether the first argument is contained (identity-wise) in the context
--   of the second, in other words, the second depends on the first. This
--   does not include equality, only proper dependency.
ctxDepends :: Ident p => Contexted p wX -> Contexted p wX -> Bool

-- | A <a>Contexted</a> patch with empty context.
ctx :: p wX wY -> Contexted p wX

-- | Add a patch to the context of a <a>Contexted</a> patch. This is the
--   place where we take care of the invariants.
ctxAdd :: (Commute p, Invert p, Ident p) => p wX wY -> Contexted p wY -> Contexted p wX

-- | Add an <a>RL</a> of patches to the context.
ctxAddRL :: (Commute p, Invert p, Ident p) => RL p wX wY -> Contexted p wY -> Contexted p wX

-- | Add an <a>FL</a> of patches to the context but invert it first.
ctxAddInvFL :: (Commute p, Invert p, Ident p) => FL p wX wY -> Contexted p wX -> Contexted p wY

-- | Add an <a>FL</a> of patches to the context.
ctxAddFL :: (Commute p, Invert p, Ident p) => FL p wX wY -> Contexted p wY -> Contexted p wX

-- | (Definition 10.2) Commute a patch past a <a>Contexted</a> patch. This
--   commutes it past the context and then past the patch itself. If it
--   succeeds, the patch that we commuted past gets dropped. Note that this
--   does <i>not</i> succeed if the inverted patch is in the
--   <a>Contexted</a> patch.
commutePast :: Commute p => p wX wY -> Contexted p wY -> Maybe (Contexted p wX)

-- | Not defined in the paper but used in the commute algorithm.
commutePastRL :: Commute p => RL p wX wY -> Contexted p wY -> Maybe (Contexted p wX)
ctxTouches :: PatchInspect p => Contexted p wX -> [AnchoredPath]
ctxHunkMatches :: PatchInspect p => (ByteString -> Bool) -> Contexted p wX -> Bool
showCtx :: (ShowPatchBasic p, PatchListFormat p) => ShowPatchFor -> Contexted p wX -> Doc
readCtx :: (ReadPatch p, PatchListFormat p) => Parser (Contexted p wX)

-- | This property states that no prefix of the context commutes with the
--   rest of the <a>Contexted</a> patch and that the context never contains
--   a patch and its inverse.
prop_ctxInvariants :: (Commute p, Invert p, SignedIdent p) => Contexted p wX -> Bool

-- | This property states that equal <a>Contexted</a> patches have equal
--   content up to reorderings of the context patches.
prop_ctxEq :: (Commute p, Eq2 p, Ident p) => Contexted p wX -> Contexted p wX -> Bool

-- | This property states that patches in the context of a <a>Contexted</a>
--   patch as well as the patch itself are positive. It does <i>not</i>
--   necessarily hold for all <a>Contexted</a> patches.
prop_ctxPositive :: SignedIdent p => Contexted p wX -> Bool
instance Darcs.Patch.Ident.Ident p => GHC.Classes.Eq (Darcs.Patch.V3.Contexted.Contexted p wX)
instance Darcs.Patch.Ident.Ident p => GHC.Classes.Ord (Darcs.Patch.V3.Contexted.Contexted p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.V3.Contexted.Contexted p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V3.Contexted.Contexted p)

module Darcs.Patch.Annotate.Class
type AnnotateResult = Vector (Maybe PatchInfo, ByteString)
data Content2 f g
FileContent :: f (g ByteString) -> Content2 f g
DirContent :: f (g AnchoredPath) -> Content2 f g
data Annotated2 f g
Annotated2 :: !AnnotateResult -> !Content2 f g -> Maybe AnchoredPath -> PatchInfo -> Annotated2 f g
[annotated] :: Annotated2 f g -> !AnnotateResult
[current] :: Annotated2 f g -> !Content2 f g
[currentPath] :: Annotated2 f g -> Maybe AnchoredPath
[currentInfo] :: Annotated2 f g -> PatchInfo
type Content = Content2 [] ((,) Int)
type Annotated = Annotated2 [] ((,) Int)
type AnnotatedM = State Annotated
class Annotate p
annotate :: Annotate p => p wX wY -> AnnotatedM ()
instance GHC.Classes.Eq Darcs.Patch.Annotate.Class.Content
instance GHC.Show.Show Darcs.Patch.Annotate.Class.Content
instance GHC.Classes.Eq Darcs.Patch.Annotate.Class.Annotated
instance GHC.Show.Show Darcs.Patch.Annotate.Class.Annotated

module Darcs.Patch.Prim.Class
class PrimConstruct prim
addfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
rmfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
adddir :: PrimConstruct prim => AnchoredPath -> prim wX wY
rmdir :: PrimConstruct prim => AnchoredPath -> prim wX wY
move :: PrimConstruct prim => AnchoredPath -> AnchoredPath -> prim wX wY
changepref :: PrimConstruct prim => String -> String -> String -> prim wX wY
hunk :: PrimConstruct prim => AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY
tokreplace :: PrimConstruct prim => AnchoredPath -> String -> String -> String -> prim wX wY
binary :: PrimConstruct prim => AnchoredPath -> ByteString -> ByteString -> prim wX wY
primFromHunk :: PrimConstruct prim => FileHunk (ObjectIdOfPatch prim) wX wY -> prim wX wY
class (Commute prim, Eq2 prim, Invert prim) => PrimCoalesce prim

-- | Try to shrink the input sequence by getting rid of self-cancellations
--   and identity patches or by coalescing patches. Also sort patches
--   according to some internally defined order (specific to the patch
--   type) as far as possible while respecting dependencies. A result of
--   <a>Nothing</a> means that we could not shrink the input.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultTryToShrink</a>.
tryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)

-- | This is similar to <a>tryToShrink</a> but always gives back a result:
--   if the sequence could not be shrunk we merely give back a sorted
--   version.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultSortCoalesceFL</a>.
sortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY

-- | Coalesce adjacent patches to one with the same effect.
--   
--   <pre>
--   apply (primCoalesce p q) == apply p &gt;&gt; apply q
--   </pre>
primCoalesce :: PrimCoalesce prim => prim wX wY -> prim wY wZ -> Maybe (prim wX wZ)

-- | Whether prim patch has no effect at all and thus can be eliminated as
--   far as coalescing is concerned.
isIdentity :: PrimCoalesce prim => prim wX wY -> EqCheck wX wY

-- | Provide a total order between arbitrary patches that is consistent
--   with <a>Eq2</a>:
--   
--   <pre>
--   unsafeCompare p q == IsEq  &lt;=&gt;  comparePrim p q == EQ
--   </pre>
comparePrim :: PrimCoalesce prim => prim wA wB -> prim wC wD -> Ordering
class PrimDetails prim
summarizePrim :: PrimDetails prim => prim wX wY -> [SummDetail]

-- | Prim patches that support "sifting". This is the process of
--   eliminating changes from a sequence of prims that can be recovered by
--   comparing states (normally the pristine and working states), except
--   those that other changes depend on. In other words, changes to the
--   content of (tracked) files. The implementation is allowed and expected
--   to shrink and coalesce changes in the process.
class PrimSift prim

-- | Whether a prim is a candidate for sifting
primIsSiftable :: PrimSift prim => prim wX wY -> Bool
class PrimShow prim
showPrim :: PrimShow prim => FileNameFormat -> prim wA wB -> Doc
showPrimWithContextAndApply :: (PrimShow prim, ApplyMonad (ApplyState prim) m) => FileNameFormat -> prim wA wB -> m Doc
class PrimRead prim
readPrim :: PrimRead prim => FileNameFormat -> Parser (Sealed (prim wX))
class PrimApply prim
applyPrimFL :: (PrimApply prim, ApplyMonad (ApplyState prim) m) => FL prim wX wY -> m ()
type PrimPatch prim = (Annotate prim, Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCoalesce prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim)
class PrimMangleUnravelled prim

-- | Mangle conflicting alternatives if possible.
mangleUnravelled :: PrimMangleUnravelled prim => Unravelled prim wX -> Maybe (Mangled prim wX)

-- | Result of mangling a single Unravelled.
type Mangled prim wX = Sealed (FL prim wX)

-- | A list of conflicting alternatives. They form a connected component of
--   the conflict graph i.e. one transitive conflict.
type Unravelled prim wX = [Sealed (FL prim wX)]
primCleanMerge :: (Commute prim, Invert prim) => PartialMergeFn prim prim

module Darcs.Patch.Prim.V1.Core
data Prim wX wY
[Move] :: !AnchoredPath -> !AnchoredPath -> Prim wX wY
[DP] :: !AnchoredPath -> !DirPatchType wX wY -> Prim wX wY
[FP] :: !AnchoredPath -> !FilePatchType wX wY -> Prim wX wY
[ChangePref] :: !String -> !String -> !String -> Prim wX wY
data DirPatchType wX wY
RmDir :: DirPatchType wX wY
AddDir :: DirPatchType wX wY
data FilePatchType wX wY
RmFile :: FilePatchType wX wY
AddFile :: FilePatchType wX wY
Hunk :: !Int -> [ByteString] -> [ByteString] -> FilePatchType wX wY
TokReplace :: !String -> !String -> !String -> FilePatchType wX wY
Binary :: ByteString -> ByteString -> FilePatchType wX wY
instance GHC.Classes.Ord (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY)
instance GHC.Classes.Ord (Darcs.Patch.Prim.V1.Core.DirPatchType wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Prim.V1.Core.DirPatchType wX wY)
instance (Darcs.Patch.Object.ObjectIdOf (Darcs.Patch.Apply.ApplyState Darcs.Patch.Prim.V1.Core.Prim) GHC.Types.~ Darcs.Util.Path.AnchoredPath) => Darcs.Patch.Prim.Class.PrimConstruct Darcs.Patch.Prim.V1.Core.Prim
instance (Darcs.Patch.Object.ObjectIdOf (Darcs.Patch.Apply.ApplyState Darcs.Patch.Prim.V1.Core.Prim) GHC.Types.~ Darcs.Util.Path.AnchoredPath) => Darcs.Patch.FileHunk.IsHunk Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Invert.Invert Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Inspect.PatchInspect Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Debug.PatchDebug Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.V1.Core.Prim
instance GHC.Classes.Eq (Darcs.Patch.Prim.V1.Core.Prim wX wY)
instance Darcs.Patch.Prim.Class.PrimSift Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.V1.Core.DirPatchType
instance Darcs.Patch.Invert.Invert Darcs.Patch.Prim.V1.Core.DirPatchType
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.V1.Core.FilePatchType
instance Darcs.Patch.Invert.Invert Darcs.Patch.Prim.V1.Core.FilePatchType

module Darcs.Patch.Prim.V1.Details
instance Darcs.Patch.Prim.Class.PrimDetails Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1.Show
showHunk :: FileNameFormat -> AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Doc
instance GHC.Show.Show (Darcs.Patch.Prim.V1.Core.Prim wX wY)
instance GHC.Show.Show (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY)
instance GHC.Show.Show (Darcs.Patch.Prim.V1.Core.DirPatchType wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Prim.V1.Core.Prim wX)
instance (Darcs.Patch.Apply.Apply Darcs.Patch.Prim.V1.Core.Prim, Darcs.Patch.Apply.ApplyState Darcs.Patch.Prim.V1.Core.Prim GHC.Types.~ Darcs.Util.Tree.Tree, Darcs.Patch.Apply.ObjectIdOfPatch Darcs.Patch.Prim.V1.Core.Prim GHC.Types.~ Darcs.Util.Path.AnchoredPath) => Darcs.Patch.Prim.Class.PrimShow Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1.Commute
instance GHC.Base.Functor Darcs.Patch.Prim.V1.Commute.Perhaps
instance GHC.Base.Applicative Darcs.Patch.Prim.V1.Commute.Perhaps
instance GHC.Base.Monad Darcs.Patch.Prim.V1.Commute.Perhaps
instance GHC.Base.Alternative Darcs.Patch.Prim.V1.Commute.Perhaps
instance GHC.Base.MonadPlus Darcs.Patch.Prim.V1.Commute.Perhaps
instance Darcs.Patch.Commute.Commute Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Merge.CleanMerge Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1.Apply
instance Darcs.Patch.Apply.Apply Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Repair.RepairToFL Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Prim.Class.PrimApply Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1.Read
instance Darcs.Patch.Prim.Class.PrimRead Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1.Mangle
instance Darcs.Patch.Prim.Class.PrimMangleUnravelled Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.FileUUID.Core
data Prim wX wY
[Hunk] :: !UUID -> !Hunk wX wY -> Prim wX wY
[HunkMove] :: !HunkMove wX wY -> Prim wX wY
[Manifest] :: !UUID -> !Location -> Prim wX wY
[Demanifest] :: !UUID -> !Location -> Prim wX wY
[Identity] :: Prim wX wX
data Hunk wX wY
H :: !Int -> !FileContent -> !FileContent -> Hunk wX wY
data HunkMove wX wY
HM :: !UUID -> !Int -> !UUID -> !Int -> !FileContent -> HunkMove wX wY
data Object (m :: * -> *)
Directory :: DirContent -> Object (m :: * -> *)
Blob :: m FileContent -> !Maybe Hash -> Object (m :: * -> *)
newtype UUID
UUID :: ByteString -> UUID

-- | An object is located by giving the <a>UUID</a> of the parent
--   <a>Directory</a> and a <a>Name</a>.
data Location
L :: !UUID -> !Name -> Location
data Name
type FileContent = ByteString
instance GHC.Show.Show (Darcs.Patch.Prim.FileUUID.Core.Hunk wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Prim.FileUUID.Core.Hunk wX wY)
instance GHC.Show.Show (Darcs.Patch.Prim.FileUUID.Core.HunkMove wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Prim.FileUUID.Core.HunkMove wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Prim.FileUUID.Core.Prim wX wY)
instance GHC.Show.Show (Darcs.Patch.Prim.FileUUID.Core.Prim wX wY)
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Prim.FileUUID.Core.Prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Prim.Class.PrimConstruct Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.FileHunk.IsHunk Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Invert.Invert Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Inspect.PatchInspect Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.FileUUID.Core.HunkMove
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Prim.FileUUID.Core.Hunk wX)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.Prim.FileUUID.Core.Hunk
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Prim.FileUUID.Core.Hunk

module Darcs.Patch.Prim.FileUUID.Read
instance Darcs.Patch.Prim.Class.PrimRead Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Read.ReadPatch Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.Prim.FileUUID.Details
instance Darcs.Patch.Prim.Class.PrimDetails Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.Prim.FileUUID.Commute
instance Darcs.Patch.Commute.Commute Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Merge.CleanMerge Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.Prim.FileUUID.Coalesce
instance Darcs.Patch.Prim.Class.PrimCoalesce Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Prim.Class.PrimSift Darcs.Patch.Prim.FileUUID.Core.Prim


-- | Generic coalesce functions
--   
--   Some of the algorithms in this module do complex recursive operations
--   on sequences of patches in order to simplify them. These algorithms
--   require that we know whether some intermediate step has made any
--   progress. If not, we want to terminate or try something different.
--   
--   We capture this as an effect by tagging intermediate data with the
--   <a>Any</a> monoid, a newtype wrapper for <a>Bool</a> with disjunction
--   as <a>mappend</a>. The standard <tt>instance <a>Monoid</a> a =&gt;
--   <a>Monad</a> (a,)'</tt> defined in the base package then gives use the
--   desired semantics. That is, when we sequence operations using
--   <a>&gt;&gt;=</a>, the result tells us whether <a>Any</a> of the two
--   operations have made progress.
module Darcs.Patch.Prim.Coalesce

-- | Either <a>primCoalesce</a> or cancel inverses.
--   
--   <pre>
--   primCoalesce (p :&gt; q) == Just r =&gt; apply r = apply p &gt;&gt; apply q
--   </pre>
coalesce :: PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY)
defaultTryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)
defaultSortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY

-- | Conversion between <tt>(<a>Any</a>, a)</tt> and <tt><a>Maybe</a>
--   a</tt>.
withAnyToMaybe :: (Any, a) -> Maybe a

-- | The heart of <a>sortCoalesceFL</a>.
sortCoalesceFL2 :: PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY)

module Darcs.Patch.Prim.V1.Coalesce
instance Darcs.Patch.Prim.Class.PrimCoalesce Darcs.Patch.Prim.V1.Core.Prim

module Darcs.Patch.Prim.V1
data Prim wX wY

module Darcs.Patch.Prim.Canonize

-- | Put a sequence of primitive patches into canonical form.
--   
--   Even if the patches are just hunk patches, this is not necessarily the
--   same set of results as you would get if you applied the sequence to a
--   specific tree and recalculated a diff.
--   
--   XXX Why not? How does it differ? The implementation for Prim.V1 does
--   sortCoalesceFL and then invokes the diff algorithm for each hunk. How
--   can that be any different to applying the sequence and then taking the
--   diff? Is this merely because diff does not sort by file path?
--   
--   Besides, diff and apply <i>must</i> be inverses in the sense that for
--   any two states {start, end}, we have
--   
--   <pre>
--   diff start (apply (diff start end)) == end
--   </pre>
canonizeFL :: (IsHunk prim, PrimCoalesce prim, PrimConstruct prim) => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY

module Darcs.Patch.Prim
class PrimApply prim
applyPrimFL :: (PrimApply prim, ApplyMonad (ApplyState prim) m) => FL prim wX wY -> m ()
class (Commute prim, Eq2 prim, Invert prim) => PrimCoalesce prim

-- | Try to shrink the input sequence by getting rid of self-cancellations
--   and identity patches or by coalescing patches. Also sort patches
--   according to some internally defined order (specific to the patch
--   type) as far as possible while respecting dependencies. A result of
--   <a>Nothing</a> means that we could not shrink the input.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultTryToShrink</a>.
tryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)

-- | This is similar to <a>tryToShrink</a> but always gives back a result:
--   if the sequence could not be shrunk we merely give back a sorted
--   version.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultSortCoalesceFL</a>.
sortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY

-- | Coalesce adjacent patches to one with the same effect.
--   
--   <pre>
--   apply (primCoalesce p q) == apply p &gt;&gt; apply q
--   </pre>
primCoalesce :: PrimCoalesce prim => prim wX wY -> prim wY wZ -> Maybe (prim wX wZ)

-- | Whether prim patch has no effect at all and thus can be eliminated as
--   far as coalescing is concerned.
isIdentity :: PrimCoalesce prim => prim wX wY -> EqCheck wX wY

-- | Provide a total order between arbitrary patches that is consistent
--   with <a>Eq2</a>:
--   
--   <pre>
--   unsafeCompare p q == IsEq  &lt;=&gt;  comparePrim p q == EQ
--   </pre>
comparePrim :: PrimCoalesce prim => prim wA wB -> prim wC wD -> Ordering
class PrimConstruct prim
addfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
rmfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
adddir :: PrimConstruct prim => AnchoredPath -> prim wX wY
rmdir :: PrimConstruct prim => AnchoredPath -> prim wX wY
move :: PrimConstruct prim => AnchoredPath -> AnchoredPath -> prim wX wY
changepref :: PrimConstruct prim => String -> String -> String -> prim wX wY
hunk :: PrimConstruct prim => AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY
tokreplace :: PrimConstruct prim => AnchoredPath -> String -> String -> String -> prim wX wY
binary :: PrimConstruct prim => AnchoredPath -> ByteString -> ByteString -> prim wX wY
primFromHunk :: PrimConstruct prim => FileHunk (ObjectIdOfPatch prim) wX wY -> prim wX wY
class PrimDetails prim
summarizePrim :: PrimDetails prim => prim wX wY -> [SummDetail]
class PrimMangleUnravelled prim

-- | Mangle conflicting alternatives if possible.
mangleUnravelled :: PrimMangleUnravelled prim => Unravelled prim wX -> Maybe (Mangled prim wX)
type PrimPatch prim = (Annotate prim, Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCoalesce prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim)
class PrimRead prim
readPrim :: PrimRead prim => FileNameFormat -> Parser (Sealed (prim wX))
class PrimShow prim
showPrim :: PrimShow prim => FileNameFormat -> prim wA wB -> Doc
showPrimWithContextAndApply :: (PrimShow prim, ApplyMonad (ApplyState prim) m) => FileNameFormat -> prim wA wB -> m Doc

-- | Prim patches that support "sifting". This is the process of
--   eliminating changes from a sequence of prims that can be recovered by
--   comparing states (normally the pristine and working states), except
--   those that other changes depend on. In other words, changes to the
--   content of (tracked) files. The implementation is allowed and expected
--   to shrink and coalesce changes in the process.
class PrimSift prim

-- | Whether a prim is a candidate for sifting
primIsSiftable :: PrimSift prim => prim wX wY -> Bool

-- | Result of mangling a single Unravelled.
type Mangled prim wX = Sealed (FL prim wX)

-- | A list of conflicting alternatives. They form a connected component of
--   the conflict graph i.e. one transitive conflict.
type Unravelled prim wX = [Sealed (FL prim wX)]

-- | Put a sequence of primitive patches into canonical form.
--   
--   Even if the patches are just hunk patches, this is not necessarily the
--   same set of results as you would get if you applied the sequence to a
--   specific tree and recalculated a diff.
--   
--   XXX Why not? How does it differ? The implementation for Prim.V1 does
--   sortCoalesceFL and then invokes the diff algorithm for each hunk. How
--   can that be any different to applying the sequence and then taking the
--   diff? Is this merely because diff does not sort by file path?
--   
--   Besides, diff and apply <i>must</i> be inverses in the sense that for
--   any two states {start, end}, we have
--   
--   <pre>
--   diff start (apply (diff start end)) == end
--   </pre>
canonizeFL :: (IsHunk prim, PrimCoalesce prim, PrimConstruct prim) => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY

-- | Either <a>primCoalesce</a> or cancel inverses.
--   
--   <pre>
--   primCoalesce (p :&gt; q) == Just r =&gt; apply r = apply p &gt;&gt; apply q
--   </pre>
coalesce :: PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY)

module Darcs.Patch.Split

-- | A splitter is something that can take a patch and (possibly) render it
--   as text in some format of its own choosing. This text can then be
--   presented to the user for editing, and the result given to the
--   splitter for parsing. If the parse succeeds, the result is a list of
--   patches that could replace the original patch in any context.
--   Typically this list will contain the changed version of the patch,
--   along with fixup pieces to ensure that the overall effect of the list
--   is the same as the original patch. The individual elements of the list
--   can then be offered separately to the user, allowing them to accept
--   some and reject others.
--   
--   There's no immediate application for a splitter for anything other
--   than Prim (you shouldn't go editing named patches, you'll break them!)
--   However you might want to compose splitters for FilePatchType to make
--   splitters for Prim etc, and the generality doesn't cost anything.
data Splitter p
Splitter :: (forall wX wY. p wX wY -> Maybe (ByteString, ByteString -> Maybe (FL p wX wY))) -> (forall wX wY. FL p wX wY -> FL p wX wY) -> Splitter p
[applySplitter] :: Splitter p -> forall wX wY. p wX wY -> Maybe (ByteString, ByteString -> Maybe (FL p wX wY))
[canonizeSplit] :: Splitter p -> forall wX wY. FL p wX wY -> FL p wX wY

-- | This generic splitter just lets the user edit the printed
--   representation of the patch. Should not be used expect for testing and
--   experimentation.
rawSplitter :: (ShowPatch p, ReadPatch p, Invert p) => Splitter p

-- | Never splits. In other code we normally pass around Maybe Splitter
--   instead of using this as the default, because it saves clients that
--   don't care about splitting from having to import this module just to
--   get noSplitter.
noSplitter :: Splitter p

-- | Split a primitive hunk patch up by allowing the user to edit both the
--   before and after lines, then insert fixup patches to clean up the
--   mess.
primSplitter :: PrimPatch p => DiffAlgorithm -> Splitter p
reversePrimSplitter :: PrimPatch prim => DiffAlgorithm -> Splitter prim

module Darcs.Patch.FromPrim
class PrimPatch (PrimOf p) => PrimPatchBase p where {
    type PrimOf (p :: (* -> * -> *)) :: (* -> * -> *);
}
class FromPrim p
fromAnonymousPrim :: FromPrim p => PrimOf p wX wY -> p wX wY
fromPrim :: FromPrim p => PatchId p -> PrimOf p wX wY -> p wX wY
fromPrims :: FromPrim p => PatchInfo -> FL (PrimOf p) wX wY -> FL p wX wY
fromPrim :: (FromPrim p, PatchId p ~ ()) => PatchId p -> PrimOf p wX wY -> p wX wY
fromPrims :: (FromPrim p, PatchId p ~ ()) => PatchInfo -> FL (PrimOf p) wX wY -> FL p wX wY
class ToPrim p
toPrim :: ToPrim p => p wX wY -> Maybe (PrimOf p wX wY)
type ToFromPrim p = (FromPrim p, ToPrim p)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.V1.Core

-- | The format of a merger is <tt>Merger undos unwindings conflicting
--   original</tt>.
--   
--   <tt>undos</tt> = the effect of the merger
--   
--   <tt>unwindings</tt> = TODO: eh?
--   
--   <tt>conflicting</tt> = the patch we conflict with
--   
--   <tt>original</tt> = the patch we really are
data RepoPatchV1 prim wX wY
[PP] :: prim wX wY -> RepoPatchV1 prim wX wY
[Merger] :: FL (RepoPatchV1 prim) wX wY -> RL (RepoPatchV1 prim) wX wB -> RepoPatchV1 prim wC wX -> RepoPatchV1 prim wC wD -> RepoPatchV1 prim wX wY
[Regrem] :: FL (RepoPatchV1 prim) wX wY -> RL (RepoPatchV1 prim) wX wB -> RepoPatchV1 prim wC wX -> RepoPatchV1 prim wC wD -> RepoPatchV1 prim wY wX
isMerger :: RepoPatchV1 prim wA wB -> Bool
mergerUndo :: RepoPatchV1 prim wX wY -> FL (RepoPatchV1 prim) wX wY
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.V1.Core.RepoPatchV1 prim wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V1.Core.RepoPatchV1 prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.FromPrim.FromPrim (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.FromPrim.ToPrim (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Repair.Check (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Debug.PatchDebug prim => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.V1.Core.RepoPatchV1 prim)

module Darcs.Patch.V1.Show
showPatch_ :: ShowPatchBasic prim => prim wX wY -> Doc
instance Darcs.Patch.Show.ShowPatchBasic prim => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.V1.Core.RepoPatchV1 prim)

module Darcs.Patch.Unwind
class Unwind p

-- | Get hold of the underlying primitives for a given patch, placed in the
--   context of the patch. If there are conflicts then context patches will
--   be needed.
fullUnwind :: Unwind p => p wX wY -> Unwound (PrimOf p) wX wY

-- | An <a>Unwound</a> represents a primitive patch, together with any
--   other primitives that are required to place the primitive in a
--   different context. Typically, the presence of context patches
--   indicates that the underlying primitive would be in conflict in the
--   given context.
--   
--   We have the following invariants: - if a context contains a patch,
--   that context does not also contain the inverse of that patch (when
--   commuted next to each other) - if either context contains a patch that
--   commutes with the underlying patch, then neither context contains the
--   inverse of that patch (when commuted next to each other) Another way
--   of putting it is that all possible pairs of patch+inverse that can be
--   reached by commutation are removed.
data Unwound prim wX wY
[Unwound] :: FL prim wA wB -> FL prim wB wC -> RL prim wC wD -> Unwound prim wA wD
mkUnwound :: (Commute prim, Invert prim, Eq2 prim) => FL prim wA wB -> FL prim wB wC -> FL prim wC wD -> Unwound prim wA wD

-- | Given a list of unwound patches, use commutation and cancellation of
--   inverses to remove intermediate contexts. This is not guaranteed to be
--   possible in general, but should be possible if the patches that were
--   unwound were all originally recorded (unconflicted) in the same
--   context, e.g. as part of the same <a>Named</a>.
squashUnwound :: (Show2 prim, Commute prim, Eq2 prim, Invert prim) => FL (Unwound prim) wX wY -> Unwound prim wX wY
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.Unwind.Unwound prim wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Unwind.Unwound prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Unwind.Unwound prim)
instance (Darcs.Patch.Format.PatchListFormat prim, Darcs.Patch.Show.ShowPatchBasic prim) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Unwind.Unwound prim)
instance Darcs.Patch.Invert.Invert prim => Darcs.Patch.Invert.Invert (Darcs.Patch.Unwind.Unwound prim)

module Darcs.Patch.Summary
plainSummary :: (Summary e, PrimDetails (PrimOf e)) => e wX wY -> Doc
plainSummaryFL :: (Summary e, PrimDetails (PrimOf e)) => FL e wX wY -> Doc
plainSummaryPrim :: PrimDetails prim => prim wX wY -> Doc
plainSummaryPrims :: PrimDetails prim => Bool -> FL prim wX wY -> Doc
xmlSummary :: (Summary p, PrimDetails (PrimOf p)) => p wX wY -> Doc
class Summary p
conflictedEffect :: Summary p => p wX wY -> [IsConflictedPrim (PrimOf p)]
data ConflictState
Okay :: ConflictState
Conflicted :: ConflictState
Duplicated :: ConflictState

-- | This type tags a patch with a <a>ConflictState</a> and also hides the
--   context witnesses (as in <tt>Sealed2</tt>), so we can put them in a
--   list.
data IsConflictedPrim prim
[IsC] :: !ConflictState -> !prim wX wY -> IsConflictedPrim prim
listConflictedFiles :: (Summary p, PatchInspect (PrimOf p)) => p wX wY -> [AnchoredPath]
instance GHC.Read.Read Darcs.Patch.Summary.ConflictState
instance GHC.Show.Show Darcs.Patch.Summary.ConflictState
instance GHC.Classes.Ord Darcs.Patch.Summary.ConflictState
instance GHC.Classes.Eq Darcs.Patch.Summary.ConflictState
instance GHC.Classes.Eq Darcs.Patch.Summary.SummChunk
instance GHC.Classes.Ord Darcs.Patch.Summary.SummChunk
instance Darcs.Patch.Summary.Summary p => Darcs.Patch.Summary.Summary (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.Summary.IsConflictedPrim prim)

module Darcs.Patch.Prim.FileUUID.Show
displayHunk :: Maybe UUID -> Hunk wX wY -> Doc
instance Darcs.Patch.Format.PatchListFormat Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Show.ShowPatchBasic Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Apply.Apply Darcs.Patch.Prim.FileUUID.Core.Prim => Darcs.Patch.Show.ShowContextPatch Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Show.ShowPatch Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Prim.Class.PrimShow Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.Prim.FileUUID.Apply
hunkEdit :: Hunk wX wY -> FileContent -> Either String FileContent
data ObjectMap (m :: * -> *)
ObjectMap :: (UUID -> m (Maybe (Object m))) -> (UUID -> Object m -> m (ObjectMap m)) -> m [UUID] -> ObjectMap (m :: * -> *)
[getObject] :: ObjectMap (m :: * -> *) -> UUID -> m (Maybe (Object m))
[putObject] :: ObjectMap (m :: * -> *) -> UUID -> Object m -> m (ObjectMap m)
[listObjects] :: ObjectMap (m :: * -> *) -> m [UUID]
instance Darcs.Patch.Apply.Apply Darcs.Patch.Prim.FileUUID.Core.Prim
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.Prim.FileUUID.Apply.ApplyMonadObjectMap (Control.Monad.Trans.State.Lazy.StateT (Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap m) m)
instance Darcs.Patch.Repair.RepairToFL Darcs.Patch.Prim.FileUUID.Core.Prim
instance Darcs.Patch.Prim.Class.PrimApply Darcs.Patch.Prim.FileUUID.Core.Prim
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap (Control.Monad.Trans.State.Lazy.StateT (Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap m) m)
instance Control.Monad.Catch.MonadThrow m => Darcs.Patch.ApplyMonad.ApplyMonadTrans Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap m

module Darcs.Patch.Prim.FileUUID
data Prim wX wY
instance Darcs.Patch.Prim.Class.PrimMangleUnravelled Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.Effect

-- | Patches whose concrete effect can be expressed as a list of primitive
--   patches.
--   
--   A minimal definition would be either of <tt>effect</tt> or
--   <tt>effectRL</tt>.
class Effect p
effect :: Effect p => p wX wY -> FL (PrimOf p) wX wY
instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.Witnesses.Ordered.FL p)
instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.Witnesses.Ordered.RL p)

module Darcs.Patch.V2.Non

-- | A <a>Non</a> stores a context with a <tt>Prim</tt> patch. It is a
--   patch whose effect isn't visible - a Non-affecting patch.
data Non p wX
[Non] :: FL p wX wY -> PrimOf p wY wZ -> Non p wX

-- | Nonable represents the class of patches that can be turned into a Non.
class Nonable p
non :: Nonable p => p wX wY -> Non p wX

-- | unNon converts a Non into a FL of its context followed by the
--   primitive patch.
unNon :: FromPrim p => Non p wX -> Sealed (FL p wX)

-- | showNon creates a Doc representing a Non.
showNon :: (ShowPatchBasic p, PatchListFormat p, PrimPatchBase p) => ShowPatchFor -> Non p wX -> Doc

-- | showNons creates a Doc representing a list of Nons.
showNons :: (ShowPatchBasic p, PatchListFormat p, PrimPatchBase p) => ShowPatchFor -> [Non p wX] -> Doc

-- | readNon is a parser that attempts to read a single Non.
readNon :: (ReadPatch p, PatchListFormat p, PrimPatchBase p) => Parser (Non p wX)

-- | readNons is a parser that attempts to read a list of Nons.
readNons :: (ReadPatch p, PatchListFormat p, PrimPatchBase p) => Parser [Non p wX]

-- | commutePrimsOrAddToCtx takes a WL of prims and attempts to commute
--   them past a Non.
commutePrimsOrAddToCtx :: (WL l, Apply p, Commute p, Invert p, ToFromPrim p) => l (PrimOf p) wX wY -> Non p wY -> Non p wX

-- | <a>commuteOrAddToCtx</a> <tt>x cy</tt> tries to commute <tt>x</tt>
--   past <tt>cy</tt> and always returns some variant <tt>cy'</tt>. If
--   commutation suceeds, the variant is just straightforwardly the
--   commuted version. If commutation fails, the variant consists of
--   <tt>x</tt> prepended to the context of <tt>cy</tt>.
commuteOrAddToCtx :: (Commute p, ToFromPrim p) => p wX wY -> Non p wY -> Non p wX

-- | commuteOrRemFromCtx attempts to remove a given patch from a Non. If
--   the patch was not in the Non, then the commute will succeed and the
--   modified Non will be returned. If the commute fails then the patch is
--   either in the Non context, or the Non patch itself; we attempt to
--   remove the patch from the context and then return the non with the
--   updated context.
--   
--   TODO: understand if there is any case where p is equal to the prim
--   patch of the Non, in which case, we return the original Non, is that
--   right?
commuteOrRemFromCtx :: (Commute p, Invert p, Eq2 p, ToFromPrim p) => p wX wY -> Non p wX -> Maybe (Non p wY)

-- | <a>commuteOrAddToCtxRL</a> <tt>xs cy</tt> commutes as many patches of
--   <tt>xs</tt> past <tt>cy</tt> as possible, adding any that don't
--   commute to the context of cy. Suppose we have
--   
--   <pre>
--   x1 x2 x3 [c1 c2 y]
--   </pre>
--   
--   and that in our example <tt>x1</tt> fails to commute past <tt>c1</tt>,
--   this function would commute down to
--   
--   <pre>
--   x1 [c1'' c2'' y''] x2' x3'
--   </pre>
--   
--   and return <tt>[x1 c1'' c2'' y'']</tt>
commuteOrAddToCtxRL :: (Apply p, Commute p, Invert p, ToFromPrim p) => RL p wX wY -> Non p wY -> Non p wX

-- | commuteOrRemFromCtxFL attempts to remove a FL of patches from a Non,
--   returning Nothing if any of the individual removes fail.
commuteOrRemFromCtxFL :: (Apply p, Commute p, Invert p, Eq2 p, ToFromPrim p) => FL p wX wY -> Non p wX -> Maybe (Non p wY)
remNons :: (Nonable p, Effect p, Apply p, Commute p, Invert p, Eq2 p, ToFromPrim p, PrimPatchBase p) => [Non p wX] -> Non p wX -> Non p wX

-- | (*&gt;) attemts to modify a Non by commuting it past a given patch.
(*>) :: (Commute p, Invert p, ToFromPrim p) => Non p wX -> p wX wY -> Maybe (Non p wY)

-- | (&gt;*) attempts to modify a Non, by commuting a given patch past it.
(>*) :: (Commute p, ToFromPrim p) => p wX wY -> Non p wY -> Maybe (Non p wX)

-- | (*&gt;&gt;) attempts to modify a Non by commuting it past a given WL
--   of patches.
(*>>) :: (WL l, Apply p, Commute p, Invert p, ToFromPrim p, PrimPatchBase p) => Non p wX -> l (PrimOf p) wX wY -> Maybe (Non p wY)

-- | (&gt;&gt;*) attempts to modify a Non by commuting a given WL of
--   patches past it.
(>>*) :: (WL l, Apply p, Commute p, Invert p, ToFromPrim p) => l (PrimOf p) wX wY -> Non p wY -> Maybe (Non p wX)
instance Darcs.Patch.V2.Non.WL Darcs.Patch.Witnesses.Ordered.FL
instance Darcs.Patch.V2.Non.WL Darcs.Patch.Witnesses.Ordered.RL
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => GHC.Show.Show (Darcs.Patch.V2.Non.Non p wX)
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V2.Non.Non p)
instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Witnesses.Eq.Eq2 p, Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.FromPrim.PrimOf p)) => GHC.Classes.Eq (Darcs.Patch.V2.Non.Non p wX)

module Darcs.Patch.Conflict
class Conflict p
isConflicted :: Conflict p => p wX wY -> Bool

-- | The first parameter is a context containing all patches preceding the
--   ones for which we want to calculate the conflict resolution, which is
--   the second parameter. Each element of the result list represents the
--   resolution of one maximal set of transitively conflicting
--   alternatives, in other words, a connected subset of the conflict
--   graph. But the elements themselves must not conflict with each other,
--   guaranteeing that they can be cleanly merged into a single <a>FL</a>
--   of prims.
resolveConflicts :: Conflict p => RL p wO wX -> RL p wX wY -> [ConflictDetails (PrimOf p) wY]
data ConflictDetails prim wX
ConflictDetails :: Maybe (Mangled prim wX) -> Unravelled prim wX -> ConflictDetails prim wX
[conflictMangled] :: ConflictDetails prim wX -> Maybe (Mangled prim wX)
[conflictParts] :: ConflictDetails prim wX -> Unravelled prim wX

-- | Result of mangling a single Unravelled.
type Mangled prim wX = Sealed (FL prim wX)

-- | A list of conflicting alternatives. They form a connected component of
--   the conflict graph i.e. one transitive conflict.
type Unravelled prim wX = [Sealed (FL prim wX)]

-- | For one conflict (a connected set of conflicting prims), store the
--   conflicting parts and, if possible, their mangled version.
mangleOrFail :: PrimMangleUnravelled prim => Unravelled prim wX -> ConflictDetails prim wX

-- | By definition, a conflicting patch is resolved if another patch (that
--   is not itself conflicted) depends on the conflict. If the
--   representation of conflicts is self-contained as it is for V1 and V2,
--   then we can calculate the maximal set of conflicting alternatives for
--   a conflict separately for each conflictor at the end of a repo. This
--   function can then be used to lift this to an <a>RL</a> of patches.
--   
--   So, when looking for conflicts in a list of patches, we go through the
--   whole list looking for individual patches that represent a conflict.
--   But then we try to commute them past all the patches we've already
--   seen. If we fail, i.e. there's something that depends on the conflict,
--   then we forget about the conflict; this is the Nothing case of the
--   <tt>commuteNoConflictsFL</tt> call. Otherwise the patch is now in the
--   correct position to extract the conflicting alternatives.
combineConflicts :: forall p wX wY. CommuteNoConflicts p => (forall wA wB. p wA wB -> [Unravelled (PrimOf p) wB]) -> RL p wX wY -> [Unravelled (PrimOf p) wY]

-- | Find all patches in the context that conflict with a given patch,
--   commuting them to the head (past the patch in question).
--   
--   This actually works by commuting the patch and its dependencies
--   backward until it becomes unconflicted, then minimizing the trailing
--   patches by re-commuting them backward as long as that keeps the patch
--   unconflicted.
--   
--   Precondition: the context must contain all conflicting patches.
findConflicting :: forall p wX wY wZ. (Commute p, Conflict p, ShowPatch p) => RL p wX wY -> p wY wZ -> (RL p :> (p :> RL p)) wX wZ

module Darcs.Patch.V2.RepoPatch

-- | <a>RepoPatchV2</a> is used to represents prim patches that are
--   duplicates of, or conflict with, another prim patch in the repository.
--   
--   <tt>Normal prim</tt>: A primitive patch
--   
--   <tt>Duplicate x</tt>: This patch has no effect since <tt>x</tt> is
--   already present in the repository.
--   
--   <pre>
--   Etacilpud x: invert (Duplicate x)
--   </pre>
--   
--   <tt>Conflictor ix xx x</tt>: <tt>ix</tt> is the set of patches: * that
--   conflict with <tt>x</tt> and also conflict with another patch in the
--   repository. * that conflict with a patch that conflict with <tt>x</tt>
--   
--   <tt>xx</tt> is the sequence of patches that conflict *only* with
--   <tt>x</tt>
--   
--   <tt>x</tt> is the original, conflicting patch.
--   
--   <tt>ix</tt> and <tt>x</tt> are stored as <tt>Non</tt> objects, which
--   include any necessary context to uniquely define the patch that is
--   referred to.
--   
--   The intuition is that a Conflictor should have the effect of inverting
--   any patches that <tt>x</tt> conflicts with, that haven't already been
--   undone by another Conflictor in the repository. Therefore, the effect
--   of a Conflictor is <tt>invert xx</tt>.
--   
--   <tt>InvConflictor ix xx x</tt>: like <tt>invert (Conflictor ix xx
--   x)</tt>
data RepoPatchV2 prim wX wY
[Duplicate] :: Non (RepoPatchV2 prim) wX -> RepoPatchV2 prim wX wX
[Etacilpud] :: Non (RepoPatchV2 prim) wX -> RepoPatchV2 prim wX wX
[Normal] :: prim wX wY -> RepoPatchV2 prim wX wY
[Conflictor] :: [Non (RepoPatchV2 prim) wX] -> FL prim wX wY -> Non (RepoPatchV2 prim) wX -> RepoPatchV2 prim wY wX
[InvConflictor] :: [Non (RepoPatchV2 prim) wX] -> FL prim wX wY -> Non (RepoPatchV2 prim) wX -> RepoPatchV2 prim wX wY

-- | This is used for unit-testing and for internal sanity checks
isConsistent :: PrimPatch prim => RepoPatchV2 prim wX wY -> Maybe Doc

-- | <a>isForward</a> <tt>p</tt> is <tt>True</tt> if <tt>p</tt> is either
--   an <a>InvConflictor</a> or <a>Etacilpud</a>.
isForward :: PrimPatch prim => RepoPatchV2 prim wS wY -> Maybe Doc

-- | <a>isDuplicate</a> <tt>p</tt> is <tt>True</tt> if <tt>p</tt> is either
--   a <a>Duplicate</a> or <a>Etacilpud</a> patch.
isDuplicate :: RepoPatchV2 prim wS wY -> Bool

-- | <a>mergeUnravelled</a> is used when converting from Darcs V1 patches
--   (Mergers) to Darcs V2 patches (Conflictors).
mergeUnravelled :: PrimPatch prim => [Sealed (FL prim wX)] -> Maybe (FlippedSeal (RepoPatchV2 prim) wX)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Merge.Merge (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Debug.PatchDebug prim => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Summary.Summary (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Conflict.Conflict (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Unwind.Unwind (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.CommuteNoConflicts.CommuteNoConflicts (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Repair.Check (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.FromPrim.FromPrim (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.FromPrim.ToPrim (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Invert.Invert prim => Darcs.Patch.Invert.Invert (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Commute.Commute (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Inspect.PatchInspect prim => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Apply.Apply (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Repair.RepairToFL (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowPatch (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Read.ReadPatch (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.V2.Non.Nonable (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Effect.Effect (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)
instance Darcs.Patch.FileHunk.IsHunk prim => Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.V2.RepoPatch.RepoPatchV2 prim)

module Darcs.Patch.V2

-- | <a>RepoPatchV2</a> is used to represents prim patches that are
--   duplicates of, or conflict with, another prim patch in the repository.
--   
--   <tt>Normal prim</tt>: A primitive patch
--   
--   <tt>Duplicate x</tt>: This patch has no effect since <tt>x</tt> is
--   already present in the repository.
--   
--   <pre>
--   Etacilpud x: invert (Duplicate x)
--   </pre>
--   
--   <tt>Conflictor ix xx x</tt>: <tt>ix</tt> is the set of patches: * that
--   conflict with <tt>x</tt> and also conflict with another patch in the
--   repository. * that conflict with a patch that conflict with <tt>x</tt>
--   
--   <tt>xx</tt> is the sequence of patches that conflict *only* with
--   <tt>x</tt>
--   
--   <tt>x</tt> is the original, conflicting patch.
--   
--   <tt>ix</tt> and <tt>x</tt> are stored as <tt>Non</tt> objects, which
--   include any necessary context to uniquely define the patch that is
--   referred to.
--   
--   The intuition is that a Conflictor should have the effect of inverting
--   any patches that <tt>x</tt> conflicts with, that haven't already been
--   undone by another Conflictor in the repository. Therefore, the effect
--   of a Conflictor is <tt>invert xx</tt>.
--   
--   <tt>InvConflictor ix xx x</tt>: like <tt>invert (Conflictor ix xx
--   x)</tt>
data RepoPatchV2 prim wX wY

module Darcs.Patch.V1.Commute
merge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY

-- | merger takes two patches, (which have been determined to conflict) and
--   constructs a Merger patch to represent the conflict. <tt>p1</tt> is
--   considered to be conflicting with <tt>p2</tt> (<tt>p1</tt> is the
--   "first" patch in the repo ordering), the resulting Merger is therefore
--   a representation of <tt>p2</tt>.
merger :: PrimPatch prim => String -> RepoPatchV1 prim wX wY -> RepoPatchV1 prim wX wZ -> Sealed (RepoPatchV1 prim wY)
unravel :: PrimPatch prim => RepoPatchV1 prim wX wY -> [Sealed (FL prim wX)]
publicUnravel :: PrimPatch prim => RepoPatchV1 prim wX wY -> [Sealed (FL prim wY)]
instance GHC.Base.Functor Darcs.Patch.V1.Commute.Perhaps
instance GHC.Base.Applicative Darcs.Patch.V1.Commute.Perhaps
instance GHC.Base.Monad Darcs.Patch.V1.Commute.Perhaps
instance GHC.Base.Alternative Darcs.Patch.V1.Commute.Perhaps
instance GHC.Base.MonadPlus Darcs.Patch.V1.Commute.Perhaps
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Merge.Merge (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Commute.Commute (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.CommuteNoConflicts.CommuteNoConflicts (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Conflict.Conflict (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Unwind.Unwind (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Summary.Summary (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Effect.Effect (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance (Darcs.Patch.Prim.Class.PrimPatch prim, Darcs.Patch.Apply.ApplyState prim GHC.Types.~ Darcs.Patch.Apply.ApplyState (Darcs.Patch.V1.Core.RepoPatchV1 prim)) => Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Invert.Invert prim => Darcs.Patch.Invert.Invert (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Witnesses.Eq.Eq2 prim => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Witnesses.Eq.Eq2 prim => GHC.Classes.Eq (Darcs.Patch.V1.Core.RepoPatchV1 prim wX wY)

module Darcs.Patch.V1.Read
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Read.ReadPatch (Darcs.Patch.V1.Core.RepoPatchV1 prim)

module Darcs.Patch.V1.Apply
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Apply.Apply (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Repair.RepairToFL (Darcs.Patch.V1.Core.RepoPatchV1 prim)

module Darcs.Patch.V1.Viewing
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.V1.Core.RepoPatchV1 prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowPatch (Darcs.Patch.V1.Core.RepoPatchV1 prim)

module Darcs.Patch.V1

-- | The format of a merger is <tt>Merger undos unwindings conflicting
--   original</tt>.
--   
--   <tt>undos</tt> = the effect of the merger
--   
--   <tt>unwindings</tt> = TODO: eh?
--   
--   <tt>conflicting</tt> = the patch we conflict with
--   
--   <tt>original</tt> = the patch we really are
data RepoPatchV1 prim wX wY


-- | <a>Named</a> patches group a set of changes with meta data
--   (<a>PatchInfo</a>) and explicit dependencies (created using `darcs
--   tag` or using --ask-deps).
--   
--   While the data constructor <a>NamedP</a> is exported for technical
--   reasons, code outside this modules should (and generally does) treat
--   it as an abstract data type. The only exception is the rebase
--   implementation i.e. the modules under <a>Darcs.Patch.Rebase</a>.
module Darcs.Patch.Named

-- | The <tt>Named</tt> type adds a patch info about a patch, that is a
--   name.
--   
--   <tt>NamedP info deps p</tt> represents patch <tt>p</tt> with name
--   <tt>info</tt>. <tt>deps</tt> is a list of dependencies added at the
--   named patch level, compared with the unnamed level (ie, dependencies
--   added with <tt>darcs record --ask-deps</tt>).
data Named p wX wY
[NamedP] :: !PatchInfo -> ![PatchInfo] -> !FL p wX wY -> Named p wX wY
infopatch :: forall p wX wY. FromPrim p => PatchInfo -> FL (PrimOf p) wX wY -> Named p wX wY
adddeps :: Named p wX wY -> [PatchInfo] -> Named p wX wY
setinfo :: PatchInfo -> Named p wX wY -> Named p wX wY
anonymous :: FromPrim p => FL (PrimOf p) wX wY -> IO (Named p wX wY)

-- | This slightly ad-hoc class is here so we can call <a>getdeps</a> with
--   patch types that wrap a <a>Named</a>, such as <tt>RebaseChange</tt>.
class HasDeps p
getdeps :: HasDeps p => p wX wY -> [PatchInfo]
patch2patchinfo :: Named p wX wY -> PatchInfo
patchname :: Named p wX wY -> String
patchcontents :: Named p wX wY -> FL p wX wY
fmapNamed :: (forall wA wB. p wA wB -> q wA wB) -> Named p wX wY -> Named q wX wY
fmapFL_Named :: (FL p wA wB -> FL q wC wD) -> Named p wA wB -> Named q wC wD
mergerIdNamed :: MergeFn p1 p2 -> MergeFn p1 (Named p2)
data ShowDepsFormat
ShowDepsVerbose :: ShowDepsFormat
ShowDepsSummary :: ShowDepsFormat

-- | Support for rebase
data ShowWhichDeps
ShowNormalDeps :: ShowWhichDeps
ShowDroppedDeps :: ShowWhichDeps
showDependencies :: ShowWhichDeps -> ShowDepsFormat -> [PatchInfo] -> Doc
instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Named.Named p wX wY)
instance GHC.Classes.Eq Darcs.Patch.Named.ShowDepsFormat
instance GHC.Classes.Eq Darcs.Patch.Named.ShowWhichDeps
instance (Darcs.Patch.Summary.Summary p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Named.HasDeps (Darcs.Patch.Named.Named p)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Ident.Ident (Darcs.Patch.Named.Named p)
instance Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Format.PatchListFormat p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Repair.RepairToFL p => Darcs.Patch.Repair.Repair (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Witnesses.Eq.Eq2 p) => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Merge.CleanMerge p => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Merge.Merge p => Darcs.Patch.Merge.Merge (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Conflict.Conflict p, Darcs.Patch.Summary.Summary p, Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Conflict.Conflict (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Unwind.Unwind p) => Darcs.Patch.Unwind.Unwind (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Summary.Summary p => Darcs.Patch.Summary.Summary (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Repair.Check p => Darcs.Patch.Repair.Check (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Named.Named p)
instance (Darcs.Patch.Apply.Apply p, Darcs.Patch.FileHunk.IsHunk p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Object.ObjectId (Darcs.Patch.Apply.ObjectIdOfPatch p), Darcs.Patch.Show.ShowContextPatch p) => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Named.Named p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Named.Named p)
instance Darcs.Patch.Debug.PatchDebug p => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.Named.Named p)

module Darcs.Patch.Rebase.Name

-- | A <a>RebaseName</a> encapsulates the concept of the name of a patch,
--   without any contents. This allows us to track explicit dependencies in
--   the rebase state, changing them to follow uses of amend-record or
--   unsuspend on a depended-on patch, and warning the user if any are lost
--   entirely.
data RebaseName wX wY
[AddName] :: PatchInfo -> RebaseName wX wY
[DelName] :: PatchInfo -> RebaseName wX wY
[Rename] :: PatchInfo -> PatchInfo -> RebaseName wX wY

-- | Commute a <a>RebaseName</a> and a primitive patch. They trivially
--   commute so this just involves changing the witnesses. This is unsafe
--   if the patch being commuted actually has a name (e.g. Named or
--   PatchInfo - PrimWithName is ok),
commuteNamePrim :: (RebaseName :> prim) wX wY -> (prim :> RebaseName) wX wY

-- | Commute a primitive patch and a <a>RebaseName</a>. They trivially
--   commute so this just involves changing the witnesses. This is unsafe
--   if the patch being commuted actually has a name (e.g. Named or
--   PatchInfo - PrimWithName is ok),
commutePrimName :: (prim :> RebaseName) wX wY -> (RebaseName :> prim) wX wY

-- | Commute an unnamed patch with a named patch. This is unsafe if the
--   second patch actually does have a name (e.g. Named, PatchInfoAnd,
--   etc), as it won't check the explicit dependencies.
commuterIdNamed :: CommuteFn p1 p2 -> CommuteFn p1 (Named p2)

-- | Commute an unnamed patch with a named patch. This is unsafe if the
--   first patch actually does have a name (e.g. Named, PatchInfoAnd, etc),
--   as it won't check the explicit dependencies.
commuterNamedId :: CommuteFn p1 p2 -> CommuteFn (Named p1) p2

-- | Commute a name patch and a named patch. In most cases this is trivial
--   but we do need to check explicit dependencies.
commuteNameNamed :: CommuteFn RebaseName (Named p)

-- | Commute a named patch and a name patch. In most cases this is trivial
--   but we do need to check explicit dependencies.
commuteNamedName :: CommuteFn (Named p) RebaseName
pushFixupName :: PushFixupFn RebaseName RebaseName (FL RebaseName) (Maybe2 RebaseName)
instance GHC.Show.Show (Darcs.Patch.Rebase.Name.RebaseName wX wY)
instance GHC.Classes.Eq (Darcs.Patch.Rebase.Name.RebaseName wX wY)
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Rebase.Name.RebaseName wX)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Show.ShowPatchBasic Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Show.ShowPatch Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Read.ReadPatch Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Commute.Commute Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Invert.Invert Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Inspect.PatchInspect Darcs.Patch.Rebase.Name.RebaseName
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.Rebase.Name.RebaseName

module Darcs.Patch.Rebase.Fixup

-- | A single rebase fixup, needed to ensure that the actual patches being
--   stored in the rebase state have the correct context.
data RebaseFixup prim wX wY
[PrimFixup] :: prim wX wY -> RebaseFixup prim wX wY
[NameFixup] :: RebaseName wX wY -> RebaseFixup prim wX wY
commuteNamedFixup :: Commute prim => (Named prim :> RebaseFixup prim) wX wY -> Maybe ((RebaseFixup prim :> Named prim) wX wY)
commuteFixupNamed :: Commute prim => (RebaseFixup prim :> Named prim) wX wY -> Maybe ((Named prim :> RebaseFixup prim) wX wY)
pushFixupFixup :: PrimPatch prim => DiffAlgorithm -> PushFixupFn (RebaseFixup prim) (RebaseFixup prim) (FL (RebaseFixup prim)) (Maybe2 (RebaseFixup prim))

-- | Split a sequence of fixups into names and prims
flToNamesPrims :: FL (RebaseFixup prim) wX wY -> (FL RebaseName :> FL prim) wX wY
namedToFixups :: Effect p => Named p wX wY -> FL (RebaseFixup (PrimOf p)) wX wY
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.Rebase.Fixup.RebaseFixup prim wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Rebase.Fixup.RebaseFixup prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Apply.Apply prim => Darcs.Patch.Apply.Apply (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Invert.Invert prim => Darcs.Patch.Invert.Invert (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Inspect.PatchInspect prim => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Show.ShowPatchBasic prim => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Read.ReadPatch prim => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)
instance Darcs.Patch.Commute.Commute prim => Darcs.Patch.Commute.Commute (Darcs.Patch.Rebase.Fixup.RebaseFixup prim)

module Darcs.Patch.PatchInfoAnd

-- | <tt><a>Hopefully</a> p C</tt> <tt>(x y)</tt> is <tt><a>Either</a>
--   String (p C</tt> <tt>(x y))</tt> in a form adapted to darcs patches.
--   The <tt>C</tt> <tt>(x y)</tt> represents the type witness for the
--   patch that should be there. The <tt>Hopefully</tt> type just tells
--   whether we expect the patch to be hashed or not, and
--   <a>SimpleHopefully</a> does the real work of emulating <a>Either</a>.
--   <tt>Hopefully sh</tt> represents an expected unhashed patch, and
--   <tt>Hashed hash sh</tt> represents an expected hashed patch with its
--   hash.
data Hopefully a wX wY
type PatchInfoAnd p = PatchInfoAndG (Named p)

-- | <tt><a>PatchInfoAnd</a> p wA wB</tt> represents a hope we have to get
--   a patch through its info. We're not sure we have the patch, but we
--   know its info.
data PatchInfoAndG p wA wB

-- | <tt><a>piap</a> i p</tt> creates a PatchInfoAnd containing p with info
--   i.
piap :: PatchInfo -> p wA wB -> PatchInfoAndG p wA wB

-- | <tt>n2pia</tt> creates a PatchInfoAnd representing a <tt>Named</tt>
--   patch.
n2pia :: (Ident p, PatchId p ~ PatchInfo) => p wX wY -> PatchInfoAndG p wX wY
patchInfoAndPatch :: PatchInfo -> Hopefully p wA wB -> PatchInfoAndG p wA wB
fmapPIAP :: (p wX wY -> q wX wY) -> PatchInfoAndG p wX wY -> PatchInfoAndG q wX wY
fmapFLPIAP :: (FL p wX wY -> FL q wX wY) -> PatchInfoAnd p wX wY -> PatchInfoAnd q wX wY

-- | <tt><a>hopefully</a> hp</tt> tries to get a patch from a
--   <a>PatchInfoAnd</a> value. If it fails, it outputs an error "failed to
--   read patch: &lt;description of the patch&gt;". We get the description
--   of the patch from the info part of <tt>hp</tt>
hopefully :: PatchInfoAndG p wA wB -> p wA wB
info :: PatchInfoAndG p wA wB -> PatchInfo

-- | Return <a>Just</a> the patch content or <a>Nothing</a> if it is
--   unavailable.
hopefullyM :: PatchInfoAndG p wA wB -> Maybe (p wA wB)
createHashed :: PatchHash -> (PatchHash -> IO (Sealed (a wX))) -> IO (Sealed (Hopefully a wX))
extractHash :: PatchInfoAndG p wA wB -> Either (p wA wB) PatchHash
actually :: a wX wY -> Hopefully a wX wY
unavailable :: String -> Hopefully a wX wY
patchDesc :: forall p wX wY. PatchInfoAnd p wX wY -> String
instance GHC.Show.Show (a wX wY) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.SimpleHopefully a wX wY)
instance GHC.Show.Show (a wX wY) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.Hopefully a wX wY)
instance GHC.Show.Show (p wA wB) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p wA wB)
instance GHC.Exception.Type.Exception Darcs.Patch.PatchInfoAnd.PatchNotAvailable
instance GHC.Show.Show Darcs.Patch.PatchInfoAnd.PatchNotAvailable
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.PatchInfoAnd.PatchInfoAnd p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.PatchInfoAnd.PatchInfoAnd p)
instance Darcs.Patch.Repair.RepairToFL p => Darcs.Patch.Repair.Repair (Darcs.Patch.PatchInfoAnd.PatchInfoAnd p)
instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Conflict.Conflict p, Darcs.Patch.Summary.Summary p, Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Conflict.Conflict (Darcs.Patch.PatchInfoAnd.PatchInfoAnd p)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Ident.Ident (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Show.ShowPatchBasic p => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Show.ShowContextPatch p => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance (Darcs.Patch.Summary.Summary p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatch p) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance (Darcs.Patch.Ident.PatchId p GHC.Types.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Commute.Commute p) => Darcs.Patch.Commute.Commute (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance (Darcs.Patch.Ident.PatchId p GHC.Types.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Merge.CleanMerge p) => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance (Darcs.Patch.Ident.PatchId p GHC.Types.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Merge.Merge p) => Darcs.Patch.Merge.Merge (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Ident.Ident p, Darcs.Patch.Ident.PatchId p GHC.Types.~ Darcs.Patch.Info.PatchInfo) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Debug.PatchDebug p => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.PatchInfoAnd.PatchInfoAndG p)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.PatchInfoAnd.Hopefully p)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.PatchInfoAnd.SimpleHopefully p)

module Darcs.Patch.Set

-- | The patches in a repository are stored in chunks broken up at "clean"
--   tags. A tag is clean if the only patches before it in the current
--   repository ordering are ones that the tag depends on (either directly
--   or indirectly). Each chunk is stored in a separate inventory file on
--   disk.
--   
--   A <a>PatchSet</a> represents a repo's history as the list of patches
--   since the last clean tag, and then a list of patch lists each
--   delimited by clean tags.
--   
--   Because the invariants about clean tags can only be maintained if a
--   <a>PatchSet</a> contains the whole history, the first witness is
--   always forced to be <a>Origin</a>. The type still has two witnesses so
--   it can easily be used with combinators like <a>:&gt;</a> and
--   <tt>Fork</tt>.
--   
--   The history is lazily loaded from disk so does not normally need to be
--   all kept in memory.
data PatchSet p wStart wY
[PatchSet] :: RL (Tagged p) Origin wX -> RL (PatchInfoAnd p) wX wY -> PatchSet p Origin wY

-- | A <a>Tagged</a> is a single chunk of a <a>PatchSet</a>. It has a
--   <a>PatchInfo</a> representing a clean tag, the hash of the previous
--   inventory (if it exists), and the list of patches since that previous
--   inventory.
data Tagged p wX wZ
[Tagged] :: RL (PatchInfoAnd p) wX wY -> PatchInfoAnd p wY wZ -> Maybe InventoryHash -> Tagged p wX wZ
type SealedPatchSet p wStart = Sealed ((PatchSet p) wStart)

-- | <a>Origin</a> is a type used to represent the initial context of a
--   repo.
data Origin

-- | Runs a progress action for each tag and patch in a given PatchSet,
--   using the passed progress message. Does not alter the PatchSet.
progressPatchSet :: String -> PatchSet p wStart wX -> PatchSet p wStart wX
patchSetInventoryHashes :: PatchSet p wX wY -> [Maybe InventoryHash]

-- | The tag names of <i>all</i> tags of a given <a>PatchSet</a>.
patchSetTags :: PatchSet p wX wY -> [String]
emptyPatchSet :: PatchSet p Origin Origin

-- | <a>appendPSFL</a> takes a <a>PatchSet</a> and a <a>FL</a> of patches
--   that "follow" the PatchSet, and concatenates the patches into the
--   PatchSet.
appendPSFL :: PatchSet p wStart wX -> FL (PatchInfoAnd p) wX wY -> PatchSet p wStart wY

-- | <a>patchSet2RL</a> takes a <a>PatchSet</a> and returns an equivalent,
--   linear <a>RL</a> of patches.
patchSet2RL :: PatchSet p wStart wX -> RL (PatchInfoAnd p) wStart wX

-- | <a>patchSet2FL</a> takes a <a>PatchSet</a> and returns an equivalent,
--   linear <a>FL</a> of patches.
patchSet2FL :: PatchSet p wStart wX -> FL (PatchInfoAnd p) wStart wX
inOrderTags :: PatchSet p wS wX -> [PatchInfo]
patchSetSnoc :: PatchSet p wX wY -> PatchInfoAnd p wY wZ -> PatchSet p wX wZ

-- | Split a <a>PatchSet</a> <i>before</i> the latest known clean tag. The
--   left part is what comes before the tag, the right part is the tag and
--   its non-dependencies.
patchSetSplit :: PatchSet p wX wY -> (PatchSet p :> RL (PatchInfoAnd p)) wX wY

-- | Drop the last <tt>n</tt> patches from the given <a>PatchSet</a>.
patchSetDrop :: Int -> PatchSet p wStart wX -> SealedPatchSet p wStart
instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Set.PatchSet p wStart wY)
instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Set.Tagged p wX wZ)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Set.PatchSet p wStart)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Set.PatchSet p)
instance Darcs.Patch.Ident.Ident (Darcs.Patch.Set.PatchSet p)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Set.Tagged p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Set.Tagged p)

module Darcs.Patch.Progress

-- | Evaluate an <a>RL</a> list and report progress.
progressRL :: String -> RL a wX wY -> RL a wX wY

-- | Evaluate an <a>FL</a> list and report progress.
progressFL :: String -> FL a wX wY -> FL a wX wY

-- | Evaluate an <a>RL</a> list and report progress. In addition to
--   printing the number of patches we got, show the name of the last tag
--   we got.
progressRLShowTags :: String -> RL (PatchInfoAnd p) wX wY -> RL (PatchInfoAnd p) wX wY


-- | Definitions used in this module:
--   
--   <ul>
--   <li><i>Explicit dependencies</i> The set of patches that a (named)
--   patch depends on "by name", i.e. irrespective of (non-)commutation
--   (non commuting patches are implicit dependencies). The most important
--   example are tags, but non-tag patches can also have explicit
--   dependencies by recording them with --ask-deps.</li>
--   <li><i>Covered</i> A patch <tt>p</tt> is covered by a tag <tt>t</tt>
--   if <tt>t</tt> explicitly depends on <tt>p</tt> or a tag covered by
--   <tt>t</tt> explicitly depends on <tt>p</tt>. In other words, the
--   transitive closure of the relation "is depended on", restricted to
--   situations where the right hand side is a tag. Note that it does
--   <i>not</i> take explicit dependencies of non-tag patches into account
--   at all.</li>
--   <li><i>Clean</i> A tag <tt>t</tt> in a repository is clean if all
--   patches prior to the tag are covered by <tt>t</tt>. Tags normally
--   start out as clean tags (the exception is if --ask-deps is used). It
--   typically becomes unclean when it is merged into another repo (here
--   the exceptions are if --reorder-patches is used, or if the target repo
--   is actually a subset of the source repo).</li>
--   </ul>
module Darcs.Patch.Depends

-- | Return the <a>PatchInfo</a> for all the patches in a <a>PatchSet</a>
--   that are not *explicitly* depended on by any tag (in the given
--   <a>PatchSet</a>).
--   
--   This is exactly the set of patches that a new tag recorded on top of
--   the <a>PatchSet</a> would explicitly depend on.
--   
--   Note that the result is not minimal with respect to dependencies, not
--   even explicit dependencies: explicit dependencies of regular (non-tag)
--   patches are completely ignored.
getUncovered :: PatchSet p wStart wX -> [PatchInfo]

-- | Two <a>PatchSet</a>s are considered unrelated unless they share a
--   common inventory, or either <a>PatchSet</a> has less than 5 patches,
--   or they have at least one patch in common.
areUnrelatedRepos :: Commute p => PatchSet p Origin wX -> PatchSet p Origin wY -> Bool

-- | The symmetric difference between two <a>PatchSet</a>s, expressed as a
--   <a>Fork</a> consisting of the intersection <a>PatchSet</a> and the
--   trailing lists of left-only and right-only patches.
--   
--   From a purely functional point of view this is a symmetric function.
--   However, laziness effects make it asymmetric: the LHS is more likely
--   to be evaluated fully, while the RHS is evaluated as sparingly as
--   possible. For efficiency, the LHS should come from the local repo and
--   the RHS from the remote one. This asymmetry can also have a semantic
--   effect, namely if <a>PatchSet</a>s have *unavailable* patches or
--   inventories, for instance when we deal with a lazy clone of a repo
--   that is no longer accessible. In this case the order of arguments may
--   determine whether the command fails or succeeds.
findCommon :: Commute p => PatchSet p Origin wX -> PatchSet p Origin wY -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wX wY
findCommonWithThem :: Commute p => PatchSet p Origin wX -> PatchSet p Origin wY -> (PatchSet p :> FL (PatchInfoAnd p)) Origin wX
findUncommon :: Commute p => PatchSet p Origin wX -> PatchSet p Origin wY -> (FL (PatchInfoAnd p) :\/: FL (PatchInfoAnd p)) wX wY
patchSetMerge :: (Commute p, Merge p) => PatchSet p Origin wX -> PatchSet p Origin wY -> (FL (PatchInfoAnd p) :/\: FL (PatchInfoAnd p)) wX wY
countUsThem :: Commute p => PatchSet p Origin wX -> PatchSet p Origin wY -> (Int, Int)
removeFromPatchSet :: (Commute p, Eq2 p) => FL (PatchInfoAnd p) wX wY -> PatchSet p wStart wY -> Maybe (PatchSet p wStart wX)

-- | Create a new <a>Tagged</a> section for the most recent clean tag found
--   in the tail of un-<a>Tagged</a> patches without re-ordering patches.
--   Note that earlier tags may remain un-<a>Tagged</a> even if they are
--   actually clean.
slightlyOptimizePatchset :: PatchSet p wStart wX -> PatchSet p wStart wX

-- | Create a <a>Tagged</a> section for every clean tag. For unclean tags
--   we try to make them clean, but only if that doesn't make an earlier
--   clean tag dirty. This means that the operation is idempotent and in
--   particular monotonic, which justifies the "optimize" in the name.
fullyOptimizePatchSet :: forall p wZ. Commute p => PatchSet p Origin wZ -> PatchSet p Origin wZ

-- | Take a tag's <a>PatchInfo</a>, and a <a>PatchSet</a>, and attempt to
--   find the tag in the <a>PatchSet</a>. If found, return a new
--   <a>PatchSet</a>, in which the tag is now clean (and the last of the
--   <a>Tagged</a> list), while all patches that are not covered by the tag
--   are in the trailing list of patches. If the tag is not in the
--   <a>PatchSet</a>, we return <a>Nothing</a>.
splitOnTag :: Commute p => PatchInfo -> PatchSet p wStart wX -> Maybe (PatchSet p wStart wX)

-- | A <a>PatchSet</a> consisting of the patches contained in any of the
--   input <a>PatchSet</a>s. The input <a>PatchSet</a>s are merged in left
--   to right order, left patches first.
patchSetUnion :: (Commute p, Merge p) => [SealedPatchSet p Origin] -> SealedPatchSet p Origin

-- | A <a>PatchSet</a> consisting of the patches common to all input
--   <a>PatchSet</a>s. This is *undefined* for the empty list since
--   intersection of <a>PatchSet</a>s has no unit.
patchSetIntersection :: Commute p => [SealedPatchSet p Origin] -> SealedPatchSet p Origin

-- | Reorder a <a>PatchSet</a> such that the latest tag becomes clean.
cleanLatestTag :: Commute p => PatchSet p wStart wX -> PatchSet p wStart wX

-- | Split a <a>PatchSet</a> at the latest clean tag. The left part is what
--   comes before the tag, the right part is the tag and its
--   non-dependencies.
contextPatches :: PatchSet p wX wY -> (PatchSet p :> RL (PatchInfoAnd p)) wX wY


module Darcs.Patch.Annotate
annotateFile :: AnnotateRP p => RL (PatchInfoAnd p) wX wY -> AnchoredPath -> ByteString -> AnnotateResult
annotateDirectory :: AnnotateRP p => RL (PatchInfoAnd p) wX wY -> AnchoredPath -> [AnchoredPath] -> AnnotateResult
format :: ByteString -> AnnotateResult -> String
machineFormat :: ByteString -> AnnotateResult -> String
type AnnotateResult = Vector (Maybe PatchInfo, ByteString)
class Annotate p
annotate :: Annotate p => p wX wY -> AnnotatedM ()

-- | This constraint expresses what is needed for a repo patch to support
--   the high-level interface to annotation (currently annotateFile and
--   annotateDirectory)
type AnnotateRP p = (Annotate (PrimOf p), Invert (PrimOf p), Effect p)
instance GHC.Classes.Eq Darcs.Patch.Annotate.FileOrDirectory
instance GHC.Show.Show Darcs.Patch.Annotate.FileOrDirectory
instance Darcs.Patch.Annotate.Class.Annotate Darcs.Patch.Prim.V1.Core.Prim
instance Darcs.Patch.Annotate.Class.Annotate Darcs.Patch.Prim.FileUUID.Core.Prim

module Darcs.Patch.V2.Prim
newtype Prim x y
Prim :: Prim x y -> Prim x y
[unPrim] :: Prim x y -> Prim x y
instance GHC.Show.Show (Darcs.Patch.V2.Prim.Prim x y)
instance Darcs.Patch.Prim.Class.PrimSift Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimMangleUnravelled Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimDetails Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimConstruct Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimCoalesce Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimApply Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Inspect.PatchInspect Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.FileHunk.IsHunk Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Invert.Invert Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Commute.Commute Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Merge.CleanMerge Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Apply.Apply Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Annotate.Class.Annotate Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V2.Prim.Prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Read.ReadPatch Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Show.ShowPatchBasic Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Show.ShowContextPatch Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Show.ShowPatch Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Format.PatchListFormat Darcs.Patch.V2.Prim.Prim
instance Darcs.Patch.Repair.RepairToFL Darcs.Patch.V2.Prim.Prim

module Darcs.Patch.V1.Prim
newtype Prim x y
Prim :: Prim x y -> Prim x y
[unPrim] :: Prim x y -> Prim x y
instance GHC.Show.Show (Darcs.Patch.V1.Prim.Prim x y)
instance Darcs.Patch.Prim.Class.PrimSift Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimMangleUnravelled Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimDetails Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimConstruct Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimCoalesce Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Prim.Class.PrimApply Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Inspect.PatchInspect Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.FileHunk.IsHunk Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Invert.Invert Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Commute.Commute Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Merge.CleanMerge Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Apply.Apply Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Annotate.Class.Annotate Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V1.Prim.Prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Read.ReadPatch Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Show.ShowPatchBasic Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Show.ShowContextPatch Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Show.ShowPatch Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Format.PatchListFormat Darcs.Patch.V1.Prim.Prim
instance Darcs.Patch.Repair.RepairToFL Darcs.Patch.V1.Prim.Prim

module Darcs.Patch.RepoPatch
type RepoPatch p = (AnnotateRP p, Apply p, ApplyState p ~ ApplyState (PrimOf p), Check p, Commute p, Conflict p, Effect p, Eq2 p, FromPrim p, IsHunk p, IsHunk (PrimOf p), Merge p, PatchInspect p, PatchListFormat p, PrimPatchBase p, ReadPatch p, RepairToFL p, ShowContextPatch p, ShowPatch p, Summary p, ToPrim p, Unwind p)

-- | This constraint expresses what is needed for a repo patch to support
--   the high-level interface to annotation (currently annotateFile and
--   annotateDirectory)
type AnnotateRP p = (Annotate (PrimOf p), Invert (PrimOf p), Effect p)
class Apply p where {
    type ApplyState p :: (* -> *) -> *;
}
apply :: (Apply p, ApplyMonad (ApplyState p) m) => p wX wY -> m ()
unapply :: (Apply p, ApplyMonad (ApplyState p) m) => p wX wY -> m ()
unapply :: (Apply p, ApplyMonad (ApplyState p) m, Invert p) => p wX wY -> m ()
class Check p
isInconsistent :: Check p => p wX wY -> Maybe Doc

-- | Class of patches that that can be commuted.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li><i>commute-symmetry</i> <pre>commute (p:&gt;q) == Just (q':&gt;p')
--   &lt;=&gt; commute (q':&gt;p') == Just (p':&gt;q)</pre></li>
--   <li><i>invert-commute</i> If patches are invertible, then<pre>commute
--   (p:&gt;q) == Just (q':&gt;p') &lt;=&gt; commute (invert q:&gt;invert
--   p) == Just (invert p':&gt;invert q')</pre></li>
--   </ul>
--   
--   The more general law
--   
--   <ul>
--   <li><i>square-commute</i> <pre>commute (p:&gt;q) == Just (q':&gt;p')
--   =&gt; commute (invert p:&gt;q') == Just (q:&gt;invert p')</pre></li>
--   </ul>
--   
--   is valid in general only provided we know (a priori) that
--   <tt><a>commute</a> (<tt>invert</tt> p<a>:&gt;</a>q')</tt> succeeds, in
--   other words, that p and q are not in conflict with each other. See
--   <a>Darcs.Patch.CommuteNoConflicts</a> for an extended discussion.
class Commute p
commute :: Commute p => (p :> p) wX wY -> Maybe ((p :> p) wX wY)
class Conflict p
isConflicted :: Conflict p => p wX wY -> Bool

-- | The first parameter is a context containing all patches preceding the
--   ones for which we want to calculate the conflict resolution, which is
--   the second parameter. Each element of the result list represents the
--   resolution of one maximal set of transitively conflicting
--   alternatives, in other words, a connected subset of the conflict
--   graph. But the elements themselves must not conflict with each other,
--   guaranteeing that they can be cleanly merged into a single <a>FL</a>
--   of prims.
resolveConflicts :: Conflict p => RL p wO wX -> RL p wX wY -> [ConflictDetails (PrimOf p) wY]

-- | Patches whose concrete effect can be expressed as a list of primitive
--   patches.
--   
--   A minimal definition would be either of <tt>effect</tt> or
--   <tt>effectRL</tt>.
class Effect p
effect :: Effect p => p wX wY -> FL (PrimOf p) wX wY

-- | An witness aware equality class. A minimal definition defines any one
--   of <a>unsafeCompare</a>, <a>=\/=</a> and <a>=/\=</a>.
class Eq2 p

-- | It is unsafe to define a class instance via this method, because if it
--   returns True then the default implementations of <a>=\/=</a> and
--   <a>=/\=</a> will coerce the equality of two witnesses.
--   
--   Calling this method is safe, although <a>=\/=</a> or <a>=/\=</a> would
--   be better choices as it is not usually meaningul to compare two
--   patches that don't share either a starting or an ending context
unsafeCompare :: Eq2 p => p wA wB -> p wC wD -> Bool

-- | Compare two things with the same starting witness. If the things
--   compare equal, evidence of the ending witnesses being equal will be
--   returned.
(=\/=) :: Eq2 p => p wA wB -> p wA wC -> EqCheck wB wC

-- | Compare two things with the same ending witness. If the things compare
--   equal, evidence of the starting witnesses being equal will be
--   returned.
(=/\=) :: Eq2 p => p wA wC -> p wB wC -> EqCheck wA wB
infix 4 =\/=
infix 4 =/\=
class FromPrim p
fromAnonymousPrim :: FromPrim p => PrimOf p wX wY -> p wX wY
fromPrim :: FromPrim p => PatchId p -> PrimOf p wX wY -> p wX wY
fromPrims :: FromPrim p => PatchInfo -> FL (PrimOf p) wX wY -> FL p wX wY
fromPrim :: (FromPrim p, PatchId p ~ ()) => PatchId p -> PrimOf p wX wY -> p wX wY
fromPrims :: (FromPrim p, PatchId p ~ ()) => PatchInfo -> FL (PrimOf p) wX wY -> FL p wX wY
class IsHunk p
isHunk :: IsHunk p => p wX wY -> Maybe (FileHunk (ObjectIdOfPatch p) wX wY)

-- | Patches that can always be merged, even if they conflict.
--   
--   Instances should obey the following laws:
--   
--   <ul>
--   <li><i><i>symmetry</i></i> <pre>merge (p :\/: q) == q' :/\: p'
--   &lt;=&gt; merge (q :\/: p) == p' :/\: q'</pre></li>
--   <li><i><i>merge-commute</i></i> <pre>merge (p :\/: q) == q' :/\: p'
--   ==&gt; commute (p :&gt; q') == Just (q :&gt; p')</pre>that is, the two
--   branches of a merge commute to each other.</li>
--   <li><i><i>extension</i></i> <pre>cleanMerge (p :\/: q) == Just (q'
--   :/\: p') =&gt; merge (p :\/: q) == q' :/\: p'</pre>that is,
--   <a>merge</a> is an extension of <a>cleanMerge</a>.</li>
--   </ul>
class CleanMerge p => Merge p
merge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY
class PatchInspect p
listTouchedFiles :: PatchInspect p => p wX wY -> [AnchoredPath]
hunkMatches :: PatchInspect p => (ByteString -> Bool) -> p wX wY -> Bool

-- | Showing and reading lists of patches. This class allows us to control
--   how lists of patches are formatted on disk. For legacy reasons V1
--   patches have their own special treatment (see <a>ListFormat</a>).
--   Other patch types use the default format which just puts them in a
--   sequence without separators or any prelude/epilogue.
--   
--   This means that 'FL (FL p)' etc would be ambiguous, so there are no
--   instances for 'FL p' or other list types.
class PatchListFormat p
patchListFormat :: PatchListFormat p => ListFormat p
class PrimPatch (PrimOf p) => PrimPatchBase p where {
    type PrimOf (p :: (* -> * -> *)) :: (* -> * -> *);
}

-- | This class is used to decode patches from their binary representation.
class ReadPatch p
readPatch' :: ReadPatch p => Parser (Sealed (p wX))

-- | <a>RepairToFL</a> is implemented by single patches that can be
--   repaired (Prim, Patch, RepoPatchV2) There is a default so that patch
--   types with no current legacy problems don't need to have an
--   implementation.
class Apply p => RepairToFL p
applyAndTryToFixFL :: (RepairToFL p, ApplyMonad (ApplyState p) m) => p wX wY -> m (Maybe (String, FL p wX wY))
class ShowPatchBasic p => ShowContextPatch p

-- | Show a patch with context lines added, as diff -u does. Thus, it
--   differs from showPatch only for hunks. It is used for instance before
--   putting it into a bundle. As this unified context is not included in
--   patch representation, this requires access to the <a>ApplyState</a>.
--   
--   Note that this applies the patch in the <a>ApplyMonad</a> given by the
--   context. This is done in order to simplify showing multiple patches in
--   a series, since each patch may change the context lines for later
--   changes.
--   
--   For a version that does not apply the patch see
--   <a>showPatchWithContext</a>.
showPatchWithContextAndApply :: (ShowContextPatch p, ApplyMonad (ApplyState p) m) => ShowPatchFor -> p wX wY -> m Doc

-- | This class is used only for user interaction, not for storage. The
--   default implementations for <a>description</a> and <a>content</a> are
--   suitable only for <tt>PrimPatch</tt> and <tt>RepoPatch</tt> types.
--   Logically, <a>description</a> should default to <a>mempty</a> while
--   <a>content</a> should default to <a>displayPatch</a>. We define them
--   the other way around so that <a>showFriendly</a> gives reasonable
--   results for all patch types.
class ShowPatchBasic p => ShowPatch p
content :: ShowPatch p => p wX wY -> Doc
description :: ShowPatch p => p wX wY -> Doc
summary :: ShowPatch p => p wX wY -> Doc
summaryFL :: ShowPatch p => FL p wX wY -> Doc
thing :: ShowPatch p => p wX wY -> String
things :: ShowPatch p => p wX wY -> String
class ShowPatchBasic p
showPatch :: ShowPatchBasic p => ShowPatchFor -> p wX wY -> Doc
class Summary p
conflictedEffect :: Summary p => p wX wY -> [IsConflictedPrim (PrimOf p)]
class ToPrim p
toPrim :: ToPrim p => p wX wY -> Maybe (PrimOf p wX wY)
class Unwind p

-- | Get hold of the underlying primitives for a given patch, placed in the
--   context of the patch. If there are conflicts then context patches will
--   be needed.
fullUnwind :: Unwind p => p wX wY -> Unwound (PrimOf p) wX wY


-- | Formal inverses for patches that aren't really invertible. Note that
--   most the mixed {<a>Fwd</a>,<a>Rev</a>} cases for <a>Commute</a> and
--   <a>Eq2</a> are just errors.
module Darcs.Patch.Invertible

-- | Wrapper type to allow formal inversion of patches which aren't really
--   invertible.
data Invertible p wX wY

-- | Wrap a patch to make it (formally) <a>Invertible</a>. The result is
--   initially positive i.e. <a>Fwd</a>.
mkInvertible :: p wX wY -> Invertible p wX wY

-- | Get the underlying patch from an <a>Invertible</a>, assuming (as a
--   precondition) that it is positive i.e. <a>Fwd</a>.
fromPositiveInvertible :: Invertible p wX wY -> p wX wY

-- | Run a function on the patch inside an <a>Invertible</a>. The function
--   has to be parametric in the witnesses, so we can run it with both a
--   <a>Fwd</a> and a <a>Rev</a> patch.
withInvertible :: (forall wA wB. p wA wB -> r) -> Invertible p wX wY -> r
instance GHC.Classes.Ord ident => GHC.Classes.Ord (Darcs.Patch.Invertible.InvertibleId ident)
instance GHC.Classes.Eq ident => GHC.Classes.Eq (Darcs.Patch.Invertible.InvertibleId ident)
instance GHC.Classes.Ord ident => Darcs.Patch.Ident.SignedId (Darcs.Patch.Invertible.InvertibleId ident)
instance Darcs.Patch.Ident.Ident p => Darcs.Patch.Ident.Ident (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Invert.Invert (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Witnesses.Eq.Eq2 p => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Show.ShowPatchBasic p => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Show.ShowPatch p => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Show.ShowContextPatch p => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Invertible.Invertible p)
instance Darcs.Patch.Format.PatchListFormat p => Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Invertible.Invertible p)

module Darcs.Patch.Bundle

-- | A <a>Bundle</a> is a context together with some patches. The context
--   consists of unavailable patches.
data Bundle p wX wY
[Bundle] :: (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) wX wY -> Bundle p wX wY
makeBundle :: (RepoPatch p, ApplyMonadTrans (ApplyState p) IO, ObjectId (ObjectIdOfPatch p)) => Maybe (ApplyState p IO) -> PatchSet p wStart wX -> FL (Named p) wX wY -> IO Doc
parseBundle :: RepoPatch p => ByteString -> Either String (Sealed (Bundle p wX))

-- | Interpret a <a>Bundle</a> in the context of a <a>PatchSet</a>. This
--   means we match up a possible tag in the context of the <a>Bundle</a>.
--   This fails if the tag couldn't be found.
interpretBundle :: Commute p => PatchSet p Origin wT -> Bundle p wA wB -> Either String (PatchSet p Origin wB)
readContextFile :: Commute p => PatchSet p Origin wX -> FilePath -> IO (SealedPatchSet p Origin)

-- | Minimize the context of an <a>FL</a> of patches to be packed into a
--   bundle.
minContext :: RepoPatch p => PatchSet p wStart wB -> FL (PatchInfoAnd p) wB wC -> Sealed ((PatchSet p :> FL (PatchInfoAnd p)) wStart)

module Darcs.Patch
class PrimPatch (PrimOf p) => PrimPatchBase p where {
    type PrimOf (p :: (* -> * -> *)) :: (* -> * -> *);
}

-- | The <tt>Named</tt> type adds a patch info about a patch, that is a
--   name.
--   
--   <tt>NamedP info deps p</tt> represents patch <tt>p</tt> with name
--   <tt>info</tt>. <tt>deps</tt> is a list of dependencies added at the
--   named patch level, compared with the unnamed level (ie, dependencies
--   added with <tt>darcs record --ask-deps</tt>).
data Named p wX wY
type ApplyState p :: (* -> *) -> *
rmfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
addfile :: PrimConstruct prim => AnchoredPath -> prim wX wY
rmdir :: PrimConstruct prim => AnchoredPath -> prim wX wY
adddir :: PrimConstruct prim => AnchoredPath -> prim wX wY
move :: PrimConstruct prim => AnchoredPath -> AnchoredPath -> prim wX wY
hunk :: PrimConstruct prim => AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY
tokreplace :: PrimConstruct prim => AnchoredPath -> String -> String -> String -> prim wX wY
anonymous :: FromPrim p => FL (PrimOf p) wX wY -> IO (Named p wX wY)
binary :: PrimConstruct prim => AnchoredPath -> ByteString -> ByteString -> prim wX wY
description :: ShowPatch p => p wX wY -> Doc

-- | Like <a>showPatchWithContextAndApply</a> but without applying the
--   patch in the monad <tt>m</tt>.
showPatchWithContext :: (ApplyMonadTrans (ApplyState p) m, ShowContextPatch p) => ShowPatchFor -> ApplyState p m -> p wX wY -> m Doc
data ShowPatchFor
ForDisplay :: ShowPatchFor
ForStorage :: ShowPatchFor
showPatch :: ShowPatchBasic p => ShowPatchFor -> p wX wY -> Doc
displayPatch :: ShowPatchBasic p => p wX wY -> Doc
content :: ShowPatch p => p wX wY -> Doc
infopatch :: forall p wX wY. FromPrim p => PatchInfo -> FL (PrimOf p) wX wY -> Named p wX wY
changepref :: PrimConstruct prim => String -> String -> String -> prim wX wY
thing :: ShowPatch p => p wX wY -> String
things :: ShowPatch p => p wX wY -> String
merge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY
commute :: Commute p => (p :> p) wX wY -> Maybe ((p :> p) wX wY)
listTouchedFiles :: PatchInspect p => p wX wY -> [AnchoredPath]
hunkMatches :: PatchInspect p => (ByteString -> Bool) -> p wX wY -> Bool

-- | <tt>forceTokReplace tokChars old new input</tt> replaces all
--   occurrences of the <tt>old</tt> token with the <tt>new</tt> one,
--   throughout the <tt>input</tt>.
forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString
type PrimPatch prim = (Annotate prim, Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCoalesce prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim)

-- | The first parameter is a context containing all patches preceding the
--   ones for which we want to calculate the conflict resolution, which is
--   the second parameter. Each element of the result list represents the
--   resolution of one maximal set of transitively conflicting
--   alternatives, in other words, a connected subset of the conflict
--   graph. But the elements themselves must not conflict with each other,
--   guaranteeing that they can be cleanly merged into a single <a>FL</a>
--   of prims.
resolveConflicts :: Conflict p => RL p wO wX -> RL p wX wY -> [ConflictDetails (PrimOf p) wY]

-- | Patches whose concrete effect can be expressed as a list of primitive
--   patches.
--   
--   A minimal definition would be either of <tt>effect</tt> or
--   <tt>effectRL</tt>.
class Effect p
effect :: Effect p => p wX wY -> FL (PrimOf p) wX wY
invert :: Invert p => p wX wY -> p wY wX
invertFL :: Invert p => FL p wX wY -> RL p wY wX
invertRL :: Invert p => RL p wX wY -> FL p wY wX

-- | <a>commuteFL</a> commutes a single element past a FL.
commuteFL :: Commute p => (p :> FL p) wX wY -> Maybe ((FL p :> p) wX wY)

-- | <a>commuteRL</a> commutes a RL past a single element.
commuteRL :: Commute p => (RL p :> p) wX wY -> Maybe ((p :> RL p) wX wY)
readPatch :: ReadPatch p => ByteString -> Either String (Sealed (p wX))
readPatchPartial :: ReadPatch p => ByteString -> Either String (Sealed (p wX), ByteString)

-- | Put a sequence of primitive patches into canonical form.
--   
--   Even if the patches are just hunk patches, this is not necessarily the
--   same set of results as you would get if you applied the sequence to a
--   specific tree and recalculated a diff.
--   
--   XXX Why not? How does it differ? The implementation for Prim.V1 does
--   sortCoalesceFL and then invokes the diff algorithm for each hunk. How
--   can that be any different to applying the sequence and then taking the
--   diff? Is this merely because diff does not sort by file path?
--   
--   Besides, diff and apply <i>must</i> be inverses in the sense that for
--   any two states {start, end}, we have
--   
--   <pre>
--   diff start (apply (diff start end)) == end
--   </pre>
canonizeFL :: (IsHunk prim, PrimCoalesce prim, PrimConstruct prim) => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY

-- | This is similar to <a>tryToShrink</a> but always gives back a result:
--   if the sequence could not be shrunk we merely give back a sorted
--   version.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultSortCoalesceFL</a>.
sortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY

-- | Try to shrink the input sequence by getting rid of self-cancellations
--   and identity patches or by coalescing patches. Also sort patches
--   according to some internally defined order (specific to the patch
--   type) as far as possible while respecting dependencies. A result of
--   <a>Nothing</a> means that we could not shrink the input.
--   
--   This method is included in the class for optimization. Instances are
--   free to use <a>defaultTryToShrink</a>.
tryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)
patchname :: Named p wX wY -> String
patchcontents :: Named p wX wY -> FL p wX wY
apply :: (Apply p, ApplyMonad (ApplyState p) m) => p wX wY -> m ()

-- | Apply a patch to a <a>Tree</a>, yielding a new <a>Tree</a>.
applyToTree :: (Apply p, MonadThrow m, ApplyState p ~ Tree) => p wX wY -> Tree m -> m (Tree m)

-- | Attempts to apply a given patch to a Tree. If the apply fails, we
--   return Nothing, otherwise we return the updated Tree.
maybeApplyToTree :: (Apply p, ApplyState p ~ Tree, MonadCatch m) => p wX wY -> Tree m -> m (Maybe (Tree m))
effectOnPaths :: (Apply p, ApplyState p ~ Tree) => p wX wY -> [AnchoredPath] -> [AnchoredPath]
patch2patchinfo :: Named p wX wY -> PatchInfo
summary :: ShowPatch p => p wX wY -> Doc
summaryFL :: ShowPatch p => FL p wX wY -> Doc
plainSummary :: (Summary e, PrimDetails (PrimOf e)) => e wX wY -> Doc
xmlSummary :: (Summary p, PrimDetails (PrimOf p)) => p wX wY -> Doc
plainSummaryPrims :: PrimDetails prim => Bool -> FL prim wX wY -> Doc
adddeps :: Named p wX wY -> [PatchInfo] -> Named p wX wY
getdeps :: HasDeps p => p wX wY -> [PatchInfo]
listConflictedFiles :: (Summary p, PatchInspect (PrimOf p)) => p wX wY -> [AnchoredPath]
isInconsistent :: Check p => p wX wY -> Maybe Doc
type RepoPatch p = (AnnotateRP p, Apply p, ApplyState p ~ ApplyState (PrimOf p), Check p, Commute p, Conflict p, Effect p, Eq2 p, FromPrim p, IsHunk p, IsHunk (PrimOf p), Merge p, PatchInspect p, PatchListFormat p, PrimPatchBase p, ReadPatch p, RepairToFL p, ShowContextPatch p, ShowPatch p, Summary p, ToPrim p, Unwind p)
type PatchInfoAnd p = PatchInfoAndG (Named p)

-- | <tt><a>hopefully</a> hp</tt> tries to get a patch from a
--   <a>PatchInfoAnd</a> value. If it fails, it outputs an error "failed to
--   read patch: &lt;description of the patch&gt;". We get the description
--   of the patch from the info part of <tt>hp</tt>
hopefully :: PatchInfoAndG p wA wB -> p wA wB
info :: PatchInfoAndG p wA wB -> PatchInfo

module Darcs.Repository.Unrevert
finalizeTentativeUnrevert :: IO ()
revertTentativeUnrevert :: IO ()
writeUnrevert :: (RepoPatch p, ApplyState p ~ Tree) => PatchSet p Origin wR -> FL (PrimOf p) wR wX -> IO ()
readUnrevert :: RepoPatch p => PatchSet p Origin wR -> IO (SealedPatchSet p Origin)
removeFromUnrevertContext :: forall p wR wX. (RepoPatch p, ApplyState p ~ Tree) => PatchSet p Origin wR -> FL (PatchInfoAnd p) wX wR -> IO ()

module Darcs.Repository.Pending

-- | Read the contents of pending.
readPending :: RepoPatch p => Repository rt p wU wR -> IO (Sealed (FL (PrimOf p) wR))

-- | Read the contents of tentative pending.
readTentativePending :: RepoPatch p => Repository 'RW p wU wR -> IO (Sealed (FL (PrimOf p) wR))

-- | Write the contents of tentative pending.
writeTentativePending :: RepoPatch p => Repository 'RW p wU wR -> FL (PrimOf p) wR wP -> IO ()

-- | Simplify the candidate pending patch through a combination of looking
--   for self-cancellations (sequences of patches followed by their
--   inverses), coalescing, and getting rid of any hunk or binary patches
--   we can commute out the back.
--   
--   More abstractly, for an argument <tt>p</tt>, pristine state
--   <tt>R</tt>, and working state <tt>U</tt>, define
--   
--   <pre>
--   unrecorded p = p +&gt;+ diff (pureApply p R) U
--   </pre>
--   
--   Then the resulting sequence <tt>p'</tt> must maintain that equality,
--   i.e.
--   
--   <pre>
--   unrecorded p = unrecorded (siftForPending p)
--   </pre>
--   
--   while trying to "minimize" <tt>p</tt>.
siftForPending :: (PrimCoalesce prim, PrimSift prim) => FL prim wX wY -> Sealed (FL prim wX)

-- | Remove as much as possible of the given list of prim patches from the
--   pending patch. It is used by record and amend to update pending.
--   
--   The "as much as possible" is due to --look-for-* options which cause
--   changes that normally must be explicitly done by the user (such as
--   add, move, and replace) to be inferred from the the diff between
--   pristine and working. Also, before we present prims to the user to
--   select for recording, we coalesce prims from pending and working,
--   which is reason we have to use decoalescing.
tentativelyRemoveFromPW :: forall p wR wO wP wU. RepoPatch p => Repository 'RW p wU wR -> FL (PrimOf p) wO wR -> FL (PrimOf p) wO wP -> FL (PrimOf p) wP wU -> IO ()

-- | Copy the pending patch to the tentative pending, or write a new empty
--   tentative pending if regular pending does not exist.
revertPending :: RepoPatch p => Repository 'RO p wU wR -> IO ()

-- | Replace the pending patch with the tentative pending
finalizePending :: Repository 'RW p wU wR -> IO ()

-- | Overwrites the pending patch with a new one, starting at the tentative
--   state.
setTentativePending :: forall p wU wR wP. RepoPatch p => Repository 'RW p wU wR -> FL (PrimOf p) wR wP -> IO ()
instance Darcs.Patch.Read.ReadPatch p => Darcs.Patch.Read.ReadPatch (Darcs.Repository.Pending.FLM p)
instance Darcs.Patch.Show.ShowPatchBasic p => Darcs.Patch.Show.ShowPatchBasic (Darcs.Repository.Pending.FLM p)


-- | The patch-index stores additional information that is extracted from
--   the PatchSet for the repository to speed up certain commands (namely
--   <tt>log</tt> and <tt>annotate</tt>). More precisely, for every file
--   tracked by the repository, it stores the list of patches that touch
--   it.
--   
--   When created, patch-index lives in <tt>_darcs/patch_index/</tt>, and
--   it should be automatically maintained each time the set of patches of
--   the repository is updated.
--   
--   Patch-index can also be explicitely disabled by creating a file
--   <tt>_darcs/no_patch_index</tt>. "Explicitely disabed" means that no
--   command should attempt to automatically create the patch-index.
--   
--   See <a>http://darcs.net/Internals/PatchIndex</a> for more information.
module Darcs.Repository.PatchIndex

-- | Read-only. Checks if patch-index exists for this repository it works
--   by checking if:
--   
--   <ol>
--   <li><tt>_darcs/patch_index/</tt> and its corresponding files are all
--   present</li>
--   <li>patch index version is the one handled by this version of
--   Darcs</li>
--   </ol>
doesPatchIndexExist :: FilePath -> IO Bool

-- | Read-only. Checks if <tt>_darcs/noPatchIndex</tt> exists, that is, if
--   patch-index is explicitely disabled.
isPatchIndexDisabled :: FilePath -> IO Bool

-- | Checks if patch-index exists and is in sync with repository. That is,
--   checks if patch-index can be used as it is now.
isPatchIndexInSync :: Repository rt p wU wR -> IO Bool

-- | Read-only. Checks the two following things:
--   
--   <ol>
--   <li><a>doesPatchIndexExist</a></li>
--   <li><a>isPatchIndexDisabled</a></li>
--   </ol>
--   
--   Then only if it exists and it is not explicitely disabled, returns
--   <tt>True</tt>, else returns <tt>False</tt> (or an error if it exists
--   and is explicitely disabled at the same time).
canUsePatchIndex :: Repository rt p wU wR -> IO Bool

-- | Creates patch-index (ignoring whether it is explicitely disabled). If
--   it is ctrl-c'ed, then aborts, delete patch-index and mark it as
--   disabled.
createPIWithInterrupt :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> PatchSet p Origin wR -> IO ()

-- | Create or update patch index
--   
--   <ol>
--   <li>if <tt>_darcs/no_patch_index</tt> exists, delete it</li>
--   <li>if patch index exists, update it</li>
--   <li>if not, create it from scratch</li>
--   </ol>
createOrUpdatePatchIndexDisk :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> PatchSet p Origin wR -> IO ()

-- | Deletes patch-index (<tt>_darcs/patch_index/</tt> and its contents)
--   and mark repository as disabled (creates
--   <tt>_darcs/no_patch_index</tt>).
deletePatchIndex :: FilePath -> IO ()

-- | Checks if patch index can be created and build it with interrupt.
attemptCreatePatchIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> PatchSet p Origin wR -> IO ()
type PatchFilter p = [AnchoredPath] -> [Sealed2 (PatchInfoAnd p)] -> IO [Sealed2 (PatchInfoAnd p)]

-- | If a patch index is available, returns a filter that takes a list of
--   files and returns a <tt>PatchFilter</tt> that only keeps patches that
--   modify the given list of files. If patch-index cannot be used, return
--   the original input. If patch-index does not exist and is not
--   explicitely disabled, silently create it. (Also, if it is out-of-sync,
--   which should not happen, silently update it).
maybeFilterPatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> PatchSet p Origin wR -> PatchFilter p

-- | Returns an RL in which the order of patches matters. Useful for the
--   <tt>annotate</tt> command. If patch-index does not exist and is not
--   explicitely disabled, silently create it. (Also, if it is out-of-sync,
--   which should not happen, silently update it).
getRelevantSubsequence :: (RepoPatch p, ApplyState p ~ Tree, a ~ PatchInfoAnd p) => Sealed (RL a wK) -> Repository rt p wU wR -> PatchSet p Origin wR -> [AnchoredPath] -> IO (Sealed (RL a Origin))

-- | Dump information in patch index. Patch-index should be checked to
--   exist beforehand. Read-only.
dumpPatchIndex :: FilePath -> IO ()

-- | Read-only sanity check on patch-index. Patch-index should be checked
--   to exist beforehand. It may not be in sync with repository.
piTest :: FilePath -> IO ()
instance GHC.Classes.Ord Darcs.Repository.PatchIndex.FileIdSpan
instance GHC.Classes.Eq Darcs.Repository.PatchIndex.FileIdSpan
instance GHC.Show.Show Darcs.Repository.PatchIndex.FileIdSpan
instance GHC.Classes.Ord Darcs.Repository.PatchIndex.FilePathSpan
instance GHC.Classes.Eq Darcs.Repository.PatchIndex.FilePathSpan
instance GHC.Show.Show Darcs.Repository.PatchIndex.FilePathSpan
instance GHC.Classes.Ord Darcs.Repository.PatchIndex.FileInfo
instance GHC.Classes.Eq Darcs.Repository.PatchIndex.FileInfo
instance GHC.Show.Show Darcs.Repository.PatchIndex.FileInfo

module Darcs.Repository.Old
readOldRepo :: RepoPatch p => String -> IO (SealedPatchSet p Origin)
oldRepoFailMsg :: String

module Darcs.Repository.Inventory

-- | Read a <a>PatchSet</a> starting with a specific inventory inside a
--   <a>Repository</a>.
readPatchesFromInventoryFile :: (PatchListFormat p, ReadPatch p) => FilePath -> Repository rt p wU wR -> IO (PatchSet p Origin wS)

-- | Read a complete <a>PatchSet</a> from a <a>Cache</a>, by following the
--   chain of <a>Inventory</a>s, starting with the given one.
readPatchesFromInventory :: (PatchListFormat p, ReadPatch p) => Cache -> Inventory -> IO (SealedPatchSet p Origin)

-- | Read a single patch from a <a>Cache</a>, given its <a>PatchInfo</a>
--   and <a>PatchHash</a>. Fails with an error message if the patch file
--   cannot be parsed.
readSinglePatch :: ReadPatch p => Cache -> PatchInfo -> PatchHash -> IO (Sealed (p wX))
readOneInventory :: ReadPatch p => Cache -> FilePath -> IO (Sealed (RL (PatchInfoAndG p) wX))
writeInventory :: RepoPatch p => String -> Cache -> PatchSet p Origin wX -> IO InventoryHash

-- | Write a <a>PatchInfoAnd</a> to disk and return an
--   <a>InventoryEntry</a> i.e. the patch info and hash. However, if we
--   patch already contains a hash, assume it has already been written to
--   disk at some point and merely return the info and hash.
writePatchIfNecessary :: RepoPatch p => Cache -> PatchInfoAnd p wX wY -> IO InventoryEntry

-- | Wrapper around <a>writeFileUsingCache</a> that takes a <a>Doc</a>
--   instead of a <tt>ByteString</tt>.
writeHashFile :: ValidHash h => Cache -> Doc -> IO h

module Darcs.Repository.Traverse
cleanRepository :: Repository 'RW p wU wR -> IO ()
cleanPristineDir :: Cache -> [PristineHash] -> IO ()

-- | Return a list of the inventories hashes. This function attempts to
--   retrieve missing inventory files from the cache.
listInventories :: IO [String]

-- | Return a list of the inventories hashes. The argument <tt>repoDir</tt>
--   is the directory of the repository from which we are going to read the
--   head inventory file. The rest of hashed files are read from the global
--   cache.
listInventoriesRepoDir :: String -> IO [String]

-- | listPatchesLocalBucketed is similar to listPatchesLocal, but it read
--   the inventory directory under <tt>darcsDir</tt> in bucketed format.
listPatchesLocalBucketed :: String -> String -> IO [String]

-- | List of special patch files that may exist in the directory
--   _darcs<i>patches</i>. We must not clean those.
specialPatches :: [FilePath]

module Darcs.Repository.Pristine

-- | Apply an <a>FL</a> of <a>Invertible</a> patches tentative pristine
--   tree, and update the tentative pristine hash. The patches need to be
--   <a>Invertible</a> so that we can use it when removing patches from the
--   repository, too.
applyToTentativePristine :: (ApplyState p ~ Tree, RepoPatch p) => Repository 'RW p wU wR -> Invertible (FL (PatchInfoAnd p)) wR wY -> IO ()
readHashedPristineRoot :: Repository rt p wU wR -> IO PristineHash

-- | Replace the pristine hash at the start of a raw, unparsed
--   <a>HeadInventory</a> or add it if none is present.
pokePristineHash :: PristineHash -> ByteString -> Doc
peekPristineHash :: ByteString -> PristineHash

-- | Write the pristine tree into a plain directory at the given path.
createPristineDirectoryTree :: Repository rt p wU wR -> FilePath -> WithWorkingDir -> IO ()

-- | Obtains a Tree corresponding to the "recorded" state of the
--   repository: this is the same as the pristine cache, which is the same
--   as the result of applying all the repository's patches to an empty
--   directory.
readPristine :: Repository rt p wU wR -> IO (Tree IO)

-- | Replace the existing pristine with a new one (loaded up in a Tree
--   object). Warning: If <tt>rt ~ 'RO</tt> this overwrites the recorded
--   state, use only when creating a new repo!
writePristine :: Repository rt p wU wR -> Tree IO -> IO PristineHash
convertSizePrefixedPristine :: Cache -> PristineHash -> IO PristineHash


module Darcs.Repository.Diff
treeDiff :: forall m w prim. (Monad m, Gap w, PrimPatch prim) => DiffAlgorithm -> (FilePath -> FileType) -> Tree m -> Tree m -> m (w (FL prim))

module Darcs.Repository.State

-- | From a repository and a list of AnchoredPath's, construct a filter
--   that can be used on a Tree (recorded or unrecorded state) of this
--   repository. This constructed filter will take pending into account, so
--   the subpaths will be translated correctly relative to pending move
--   patches.
restrictSubpaths :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> [AnchoredPath] -> IO (TreeFilter m)

-- | Construct a <a>TreeFilter</a> that removes any boring files that are
--   not also contained in the argument <a>Tree</a>.
--   
--   The standard use case is for the argument to be the recorded state,
--   possibly with further patches applied, so as not to discard any files
--   already known to darcs. The result is usually applied to the full
--   working state.
restrictBoring :: Tree m -> IO (TreeFilter m)
newtype TreeFilter m
TreeFilter :: (forall tr. FilterTree tr m => tr m -> tr m) -> TreeFilter m
[applyTreeFilter] :: TreeFilter m -> forall tr. FilterTree tr m => tr m -> tr m

-- | Construct a Tree filter that removes any darcs metadata files the Tree
--   might have contained.
restrictDarcsdir :: TreeFilter m

-- | For a repository and an optional list of paths (when <a>Nothing</a>,
--   take everything) compute a (forward) list of prims (i.e. a patch)
--   going from the recorded state of the repository (pristine) to the
--   unrecorded state of the repository (the working tree + pending). When
--   a list of paths is given, at least the files that live under any of
--   these paths in either recorded or unrecorded will be included in the
--   resulting patch. NB. More patches may be included in this list, eg.
--   the full contents of the pending patch. This is usually not a problem,
--   since selectChanges will properly filter the results anyway.
--   
--   This also depends on the options given:
--   
--   <ul>
--   <li>-look-for-moves: Detect pending file moves using the index. The
--   resulting patches are added to pending and taken into consideration,
--   when filtering the tree according to the given path list.</li>
--   <li>-look-for-adds: Include files in the working state that do not
--   exist in the recorded + pending state.</li>
--   <li>-include-boring: Include even boring files.</li>
--   <li>-look-for-replaces: Detect pending replace patches. Like detected
--   moves, these are added to the pending patch. Note that, like detected
--   moves, these are mere proposals for the user to consider or
--   reject.</li>
--   <li>-ignore-times: Disables index usage completely -- for each file,
--   we read both the unrecorded and the recorded copy and run a diff on
--   them. This is very inefficient, although in extremely rare cases, the
--   index could go out of sync (file is modified, index is updated and
--   file is modified again within a single second).</li>
--   </ul>
--   
--   Note that use of the index is also disabled when we detect moves or
--   replaces, since this implies that the index is out of date.
unrecordedChanges :: (RepoPatch p, ApplyState p ~ Tree) => DiffOpts -> Repository rt p wU wR -> Maybe [AnchoredPath] -> IO (FL (PrimOf p) wR wU)

-- | Obtains a Tree corresponding to the "recorded" state of the
--   repository: this is the same as the pristine cache, which is the same
--   as the result of applying all the repository's patches to an empty
--   directory.
readPristine :: Repository rt p wU wR -> IO (Tree IO)

-- | Obtains a Tree corresponding to the "unrecorded" state of the
--   repository: the modified files of the working tree plus the "pending"
--   patch. The optional list of paths allows to restrict the query to a
--   subtree.
--   
--   Limiting the query may be more efficient, since hashes on the
--   uninteresting parts of the index do not need to go through an
--   up-to-date check (which involves a relatively expensive lstat(2) per
--   file.
readUnrecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> UseIndex -> Maybe [AnchoredPath] -> IO (Tree IO)

-- | Obtains the recorded <a>Tree</a> with the pending patch applied.
readPristineAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> IO (Tree IO)

-- | Obtains the relevant (according to the given filter) part of the
--   working tree.
readWorking :: TreeFilter IO -> IO (Tree IO)
readPendingAndWorking :: (RepoPatch p, ApplyState p ~ Tree) => DiffOpts -> Repository rt p wU wR -> Maybe [AnchoredPath] -> IO ((FL (PrimOf p) :> FL (PrimOf p)) wR wU)

-- | A variant of <a>readUnrecorded</a> that takes the UseIndex and
--   LookForAdds options into account, similar to
--   <a>readPendingAndWorking</a>. We are only interested in the resulting
--   tree, not the patch, so the <a>DiffAlgorithm</a> option is irrelevant.
readUnrecordedFiltered :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> UseIndex -> LookForAdds -> LookForMoves -> Maybe [AnchoredPath] -> IO (Tree IO)

-- | Open the index or re-create it in case it is invalid or non-existing.
readIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> IO Index

-- | Update the index so that it matches pristine+pending. If the index
--   does not exist or is invalid, create a new one.
--   
--   This has to be called whenever the listing of pristine+pending
--   changes. Note that this only concerns files added and removed or
--   renamed: changes to file content in either pristine or working are
--   handled transparently by the index reading code.
updateIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> IO ()

-- | Remove any patches (+dependencies) from a sequence that conflict with
--   the recorded or unrecorded changes in a repo
filterOutConflicts :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> UseIndex -> FL (PatchInfoAnd p) wX wR -> FL (PatchInfoAnd p) wX wZ -> IO (Bool, Sealed (FL (PatchInfoAnd p) wX))

-- | Add an <a>FL</a> of patches started from the pending state to the
--   pending patch.
unsafeAddToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> FreeLeft (FL (PrimOf p)) -> IO ()

-- | Add an <a>FL</a> of patches starting from the working state to the
--   pending patch, including as much extra context as is necessary
--   (context meaning dependencies), by commuting the patches to be added
--   past as much of the changes between pending and working as is
--   possible, and including anything that doesn't commute, and the patch
--   itself in the new pending patch.
addToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> DiffOpts -> FL (PrimOf p) wU wY -> IO ()

module Darcs.Repository.Resolution
standardResolution :: RepoPatch p => RL (PatchInfoAnd p) wO wX -> RL (PatchInfoAnd p) wX wY -> StandardResolution (PrimOf p) wY

-- | Like <a>standardResolution</a> but it doesn't use the <tt>instance
--   (Named p)</tt> because the traling list of patches may contain "fake"
--   conflictors.
rebaseResolution :: (Conflict p, PrimPatch (PrimOf p)) => RL (PatchInfoAnd p) wO wX -> RL (Named p) wX wY -> StandardResolution (PrimOf p) wY
externalResolution :: forall p wX wY wZ wA. (RepoPatch p, ApplyState p ~ Tree) => DiffAlgorithm -> Tree IO -> String -> WantGuiPause -> FL (PrimOf p) wX wY -> FL (PrimOf p) wX wZ -> FL p wY wA -> IO (Sealed (FL (PrimOf p) wA))
patchsetConflictResolutions :: RepoPatch p => PatchSet p Origin wX -> StandardResolution (PrimOf p) wX
data StandardResolution prim wX
StandardResolution :: Mangled prim wX -> [Unravelled prim wX] -> [AnchoredPath] -> StandardResolution prim wX
[mangled] :: StandardResolution prim wX -> Mangled prim wX
[unmangled] :: StandardResolution prim wX -> [Unravelled prim wX]
[conflictedPaths] :: StandardResolution prim wX -> [AnchoredPath]
announceConflicts :: PrimPatch prim => String -> AllowConflicts -> StandardResolution prim wX -> IO Bool
warnUnmangled :: PrimPatch prim => Maybe [AnchoredPath] -> StandardResolution prim wX -> IO ()
showUnmangled :: PrimPatch prim => Maybe [AnchoredPath] -> [Unravelled prim wX] -> Doc
showUnravelled :: PrimPatch prim => Doc -> Unravelled prim wX -> Doc


-- | <i>First matcher, Second matcher and Nonrange matcher</i>
--   
--   When we match for patches, we have a PatchSet, of which we want a
--   subset. This subset is formed by the patches in a given interval which
--   match a given criterion. If we represent time going left to right,
--   then we have (up to) three <a>Matcher</a>s:
--   
--   <ul>
--   <li>the <a>firstMatcher</a> is the left bound of the interval,</li>
--   <li>the <a>secondMatcher</a> is the right bound, and</li>
--   <li>the <a>nonrangeMatcher</a> is the criterion we use to select among
--   patches in the interval.</li>
--   </ul>
module Darcs.Patch.Match

-- | The string that is emitted when the user runs <tt>darcs help
--   patterns</tt>.
helpOnMatchers :: [String]

-- | <tt>matchFirstPatchset fs ps</tt> returns the part of <tt>ps</tt>
--   before its first matcher, ie the one that comes first dependencywise.
--   Hence, patches in <tt>matchFirstPatchset fs ps</tt> are the context
--   for the ones we want.
matchFirstPatchset :: MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart)

-- | <tt>matchSecondPatchset fs ps</tt> returns the part of <tt>ps</tt>
--   before its second matcher, ie the one that comes last dependencywise.
matchSecondPatchset :: MatchableRP p => [MatchFlag] -> PatchSet p wStart wX -> Maybe (SealedPatchSet p wStart)

-- | Split on the second matcher. Note that this picks up the first match
--   starting from the earliest patch in a sequence, as opposed to
--   <a>matchSecondPatchset</a> which picks up the first match starting
--   from the latest patch
splitSecondFL :: Matchable p => (forall wA wB. q wA wB -> Sealed2 p) -> [MatchFlag] -> FL q wX wY -> (FL q :> FL q) wX wY

-- | Whether a patch matches the given <a>MatchFlag</a>s. This should be
--   invariant under inversion:
--   
--   <pre>
--   matchAPatch (invert p) = matchAPatch p
--   </pre>
matchAPatch :: Matchable p => [MatchFlag] -> p wX wY -> Bool

-- | Rollback (i.e. apply the inverse) of what remains of a <a>PatchSet</a>
--   after we extract a <a>PatchSetMatch</a>. This is the counterpart of
--   <tt>getOnePatchset</tt> and is used to create a matching state. In
--   particular, if the match is --index=n then rollback the last (n-1)
--   patches; if the match is --tag, then rollback patches that are not
--   depended on by the tag; otherwise rollback patches that follow the
--   latest matching patch.
rollbackToPatchSetMatch :: (ApplyMonad (ApplyState p) m, MatchableRP p, ApplyState p ~ Tree) => PatchSetMatch -> PatchSet p Origin wX -> m ()

-- | <tt>firstMatch fs</tt> tells whether <tt>fs</tt> implies a "first
--   match", that is if we match against patches from a point in the past
--   on, rather than against all patches since the creation of the
--   repository.
firstMatch :: [MatchFlag] -> Bool

-- | <tt>secondMatch fs</tt> tells whether <tt>fs</tt> implies a "second
--   match", that is if we match against patches up to a point in the past
--   on, rather than against all patches until now.
secondMatch :: [MatchFlag] -> Bool

-- | <tt>haveNonrangeMatch flags</tt> tells whether there is a flag in
--   <tt>flags</tt> which corresponds to a match that is "non-range". Thus,
--   <tt>--match</tt>, <tt>--patch</tt>, and <tt>--hash</tt> make
--   <tt>haveNonrangeMatch</tt> true, but not <tt>--from-patch</tt> or
--   <tt>--to-patch</tt>.
haveNonrangeMatch :: [MatchFlag] -> Bool
data PatchSetMatch
IndexMatch :: Int -> PatchSetMatch
PatchMatch :: Matcher -> PatchSetMatch
TagMatch :: Matcher -> PatchSetMatch
ContextMatch :: AbsolutePath -> PatchSetMatch
patchSetMatch :: [MatchFlag] -> Maybe PatchSetMatch
checkMatchSyntax :: [MatchFlag] -> IO ()
hasIndexRange :: [MatchFlag] -> Maybe (Int, Int)

-- | <tt>getMatchingTag m ps</tt>, where <tt>m</tt> is a <a>Matcher</a>
--   which matches tags returns a <a>SealedPatchSet</a> containing all
--   patches in the last tag which matches <tt>m</tt>. Last tag means the
--   most recent tag in repository order, i.e. the last one you'd see if
--   you ran darcs log -t <tt>m</tt>. Calls <a>error</a> if there is no
--   matching tag.
getMatchingTag :: MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart

-- | <tt>matchAPatchset m ps</tt> returns a prefix of <tt>ps</tt> ending in
--   a patch matching <tt>m</tt>, and calls <a>error</a> if there is none.
matchAPatchset :: MatchableRP p => Matcher -> PatchSet p wStart wX -> SealedPatchSet p wStart
data MatchFlag
OnePattern :: String -> MatchFlag
SeveralPattern :: String -> MatchFlag
AfterPattern :: String -> MatchFlag
UpToPattern :: String -> MatchFlag
OnePatch :: String -> MatchFlag
SeveralPatch :: String -> MatchFlag
AfterPatch :: String -> MatchFlag
UpToPatch :: String -> MatchFlag
OneHash :: String -> MatchFlag
AfterHash :: String -> MatchFlag
UpToHash :: String -> MatchFlag
OneTag :: String -> MatchFlag
SeveralTag :: String -> MatchFlag
AfterTag :: String -> MatchFlag
UpToTag :: String -> MatchFlag
LastN :: Int -> MatchFlag
OneIndex :: Int -> MatchFlag
IndexRange :: Int -> Int -> MatchFlag
Context :: AbsolutePath -> MatchFlag

-- | matchingHead returns the repository up to some tag. The tag t is the
--   last tag such that there is a patch after t that is matched by the
--   user's query.
matchingHead :: forall p wR. MatchableRP p => [MatchFlag] -> PatchSet p Origin wR -> (PatchSet p :> FL (PatchInfoAnd p)) Origin wR

-- | Patches that can be matched.
type Matchable p = (Apply p, PatchInspect p, Ident p, PatchId p ~ PatchInfo)

-- | Constraint for a patch type <tt>p</tt> that ensures
--   <tt><a>PatchInfoAnd</a> p</tt> is <a>Matchable</a>.
type MatchableRP p = (Apply p, Commute p, PatchInspect p)
instance GHC.Show.Show Darcs.Patch.Match.MatchFlag
instance GHC.Exception.Type.Exception Darcs.Patch.Match.MatchFailure
instance GHC.Show.Show Darcs.Patch.Match.MatchFailure
instance GHC.Show.Show Darcs.Patch.Match.Matcher


-- | Patch matching options.
--   
--   These are all of the same type <a>MatchOption</a> defined below.
--   
--   Multiple flags per option are allowed and do not raise a conflict
--   error. This is how Darcs currently operates, even though I suspect
--   that it ignores all but the first <a>MatchFlag</a> (since it does so
--   for many other options).
--   
--   Given a suitable semantics (and documentation thereof), for instance
--   "all the given patterns must match", this could be turned into a
--   useful feature.
module Darcs.UI.Options.Matching
data MatchFlag
OnePattern :: String -> MatchFlag
SeveralPattern :: String -> MatchFlag
AfterPattern :: String -> MatchFlag
UpToPattern :: String -> MatchFlag
OnePatch :: String -> MatchFlag
SeveralPatch :: String -> MatchFlag
AfterPatch :: String -> MatchFlag
UpToPatch :: String -> MatchFlag
OneHash :: String -> MatchFlag
AfterHash :: String -> MatchFlag
UpToHash :: String -> MatchFlag
OneTag :: String -> MatchFlag
SeveralTag :: String -> MatchFlag
AfterTag :: String -> MatchFlag
UpToTag :: String -> MatchFlag
LastN :: Int -> MatchFlag
OneIndex :: Int -> MatchFlag
IndexRange :: Int -> Int -> MatchFlag
Context :: AbsolutePath -> MatchFlag
matchUpToOne :: MatchOption

-- | Used by: clone
matchOneContext :: MatchOption

-- | Used by: amend
matchOneNontag :: MatchOption

-- | Used by: rebase pull/apply, send, push, pull, apply, fetch
matchSeveral :: MatchOption

-- | Used by: rebase unsuspend/reify
matchSeveralOrFirst :: MatchOption

-- | Used by: unrecord, obliterate, rebase suspend, rollback
matchSeveralOrLast :: MatchOption

-- | Used by: show dependencies
matchRange :: MatchOption

-- | Used by: diff
matchOneOrRange :: MatchOption

-- | Used by: log
matchSeveralOrRange :: MatchOption
context :: MatchOption
matchLast :: MatchOption
matchFrom :: MatchOption
matchAny :: MatchOption


-- | All the concrete options.
--   
--   Notes:
--   
--   <ul>
--   <li>The term "option" refers to a flag or combination of flags that
--   together form a part of a command's configuration. Ideally, options
--   should be orthogonal to each other, so we can freely combine
--   them.</li>
--   <li>A primitive (indivisible) option has an associate value type.</li>
--   <li>An option named "xyzActions" represents a set of flags that act as
--   mutually exclusive sub-commands. They typically have a dedicated value
--   type named "XyzAction".</li>
--   <li>This module is probably best imported qualified. This is in
--   contrast to the current practice of using subtly differing names to
--   avoid name clashes for closely related items. For instance, the data
--   constructors for an option's value type and the corresponding data
--   constructors in <a>DarcsFlag</a> may coincide. This is also why we
--   import <a>Darcs.UI.Flags</a> qualified here.</li>
--   <li>When the new options system is finally in place, no code other
--   than the one for constructing options should directly refer to
--   <a>DarcsFlag</a> constructors.</li>
--   </ul>
module Darcs.UI.Options.All

-- | <a>DarcsOption</a> instantiates the first two type parameters of
--   <a>OptSpec</a> to what we need in darcs.
type DarcsOption = OptSpec DarcsOptDescr Flag
class YesNo a
yes :: YesNo a => a -> Bool
no :: YesNo a => a -> Bool

-- | Options for darcs iself that act like sub-commands.
data RootAction
RootHelp :: RootAction
Version :: RootAction
ExactVersion :: RootAction
ListCommands :: RootAction
rootActions :: PrimDarcsOption (Maybe RootAction)
data StdCmdAction
Help :: StdCmdAction
ListOptions :: StdCmdAction
Disable :: StdCmdAction
stdCmdActions :: PrimDarcsOption (Maybe StdCmdAction)
debug :: PrimDarcsOption Bool
data Verbosity
Quiet :: Verbosity
NormalVerbosity :: Verbosity
Verbose :: Verbosity
verbosity :: PrimDarcsOption Verbosity
timings :: PrimDarcsOption Bool
debugging :: DarcsOption a (Bool -> Bool -> a)
data HooksConfig
HooksConfig :: HookConfig -> HookConfig -> HooksConfig
[pre] :: HooksConfig -> HookConfig
[post] :: HooksConfig -> HookConfig
data HookConfig
HookConfig :: Maybe String -> Bool -> HookConfig
[cmd] :: HookConfig -> Maybe String
[prompt] :: HookConfig -> Bool
preHook :: DarcsOption a (HookConfig -> a)
postHook :: DarcsOption a (HookConfig -> a)
hooks :: DarcsOption a (HooksConfig -> a)
data UseCache
YesUseCache :: UseCache
NoUseCache :: UseCache
useCache :: PrimDarcsOption UseCache
data XmlOutput
NoXml :: XmlOutput
YesXml :: XmlOutput
xmlOutput :: PrimDarcsOption XmlOutput
data DryRun
YesDryRun :: DryRun
NoDryRun :: DryRun

-- | TODO someone wrote here long ago that any time --dry-run is a
--   possibility automated users should be able to examine the results more
--   easily with --xml. See also issue2397. dryRun w/o xml is currently
--   used in add, pull, and repair.
dryRun :: PrimDarcsOption DryRun
dryRunXml :: DarcsOption a (DryRun -> XmlOutput -> a)
interactive :: PrimDarcsOption (Maybe Bool)
pipe :: PrimDarcsOption Bool
data WantGuiPause
YesWantGuiPause :: WantGuiPause
NoWantGuiPause :: WantGuiPause
pauseForGui :: PrimDarcsOption WantGuiPause
askDeps :: PrimDarcsOption Bool
data SelectDeps
NoDeps :: SelectDeps
AutoDeps :: SelectDeps
PromptDeps :: SelectDeps
selectDeps :: PrimDarcsOption SelectDeps
changesReverse :: PrimDarcsOption Bool
maxCount :: PrimDarcsOption (Maybe Int)
repoDir :: PrimDarcsOption (Maybe String)
possiblyRemoteRepo :: PrimDarcsOption (Maybe String)

-- | This option is for when a new repo gets created. Used for clone,
--   convert import, convert darcs-2, and initialize. For clone and
--   initialize it has the same effect as giving the name as a normal
--   argument.
--   
--   The <tt>--repodir</tt> alias is there for compatibility, should be
--   removed eventually.
--   
--   TODO We need a way to deprecate options / option names.
newRepo :: PrimDarcsOption (Maybe String)
data NotInRemote
NotInDefaultRepo :: NotInRemote
NotInRemotePath :: String -> NotInRemote
notInRemote :: PrimDarcsOption [NotInRemote]
notInRemoteFlagName :: String
data RepoCombinator
Intersection :: RepoCombinator
Union :: RepoCombinator
Complement :: RepoCombinator
repoCombinator :: PrimDarcsOption RepoCombinator
allowUnrelatedRepos :: PrimDarcsOption Bool
justThisRepo :: PrimDarcsOption Bool
data WithWorkingDir
WithWorkingDir :: WithWorkingDir
NoWorkingDir :: WithWorkingDir

-- | convert, clone, init
withWorkingDir :: PrimDarcsOption WithWorkingDir
data SetDefault
YesSetDefault :: Bool -> SetDefault
NoSetDefault :: Bool -> SetDefault
setDefault :: PrimDarcsOption (Maybe Bool)
data InheritDefault
YesInheritDefault :: InheritDefault
NoInheritDefault :: InheritDefault
inheritDefault :: PrimDarcsOption InheritDefault
data WithPrefsTemplates
WithPrefsTemplates :: WithPrefsTemplates
NoPrefsTemplates :: WithPrefsTemplates
withPrefsTemplates :: PrimDarcsOption WithPrefsTemplates
patchname :: PrimDarcsOption (Maybe String)
author :: PrimDarcsOption (Maybe String)
data AskLongComment
NoEditLongComment :: AskLongComment
YesEditLongComment :: AskLongComment
PromptLongComment :: AskLongComment
askLongComment :: PrimDarcsOption (Maybe AskLongComment)
keepDate :: PrimDarcsOption Bool
data Logfile
Logfile :: Maybe AbsolutePath -> Bool -> Logfile
[_logfile] :: Logfile -> Maybe AbsolutePath
[_rmlogfile] :: Logfile -> Bool
logfile :: PrimDarcsOption Logfile
data UseIndex
UseIndex :: UseIndex
IgnoreIndex :: UseIndex
includeBoring :: PrimDarcsOption Bool
data LookForAdds
NoLookForAdds :: LookForAdds
YesLookForAdds :: LookForAdds
EvenLookForBoring :: LookForAdds
data LookForMoves
YesLookForMoves :: LookForMoves
NoLookForMoves :: LookForMoves
data LookForReplaces
YesLookForReplaces :: LookForReplaces
NoLookForReplaces :: LookForReplaces
data DiffOpts
DiffOpts :: UseIndex -> LookForAdds -> LookForReplaces -> LookForMoves -> DiffAlgorithm -> DiffOpts
[withIndex] :: DiffOpts -> UseIndex
[lookForAdds] :: DiffOpts -> LookForAdds
[lookForReplaces] :: DiffOpts -> LookForReplaces
[lookForMoves] :: DiffOpts -> LookForMoves
[diffAlg] :: DiffOpts -> DiffAlgorithm
lookforadds :: PrimDarcsOption LookForAdds
maybelookforadds :: LookForAdds -> PrimDarcsOption LookForAdds
lookforreplaces :: PrimDarcsOption LookForReplaces
lookformoves :: PrimDarcsOption LookForMoves
allowProblematicFilenames :: DarcsOption a (Bool -> Bool -> a)
allowCaseDifferingFilenames :: PrimDarcsOption Bool
allowWindowsReservedFilenames :: PrimDarcsOption Bool

-- | TODO: see issue2395
onlyToFiles :: PrimDarcsOption Bool
useIndex :: PrimDarcsOption UseIndex
recursive :: PrimDarcsOption Bool
data DiffAlgorithm
PatienceDiff :: DiffAlgorithm
MyersDiff :: DiffAlgorithm
diffAlgorithm :: PrimDarcsOption DiffAlgorithm
data WithContext
NoContext :: WithContext
YesContext :: WithContext
withContext :: PrimDarcsOption WithContext
data ExternalDiff
ExternalDiff :: Maybe String -> [String] -> Bool -> ExternalDiff
[diffCmd] :: ExternalDiff -> Maybe String
[diffOptions] :: ExternalDiff -> [String]
[diffUnified] :: ExternalDiff -> Bool
extDiff :: PrimDarcsOption ExternalDiff
data TestChanges
NoTestChanges :: TestChanges
YesTestChanges :: LeaveTestDir -> TestChanges
testChanges :: PrimDarcsOption TestChanges
data RunTest
YesRunTest :: RunTest
NoRunTest :: RunTest
data LeaveTestDir
YesLeaveTestDir :: LeaveTestDir
NoLeaveTestDir :: LeaveTestDir
leaveTestDir :: PrimDarcsOption LeaveTestDir
data HeaderFields
HeaderFields :: [String] -> Maybe String -> HeaderFields
[_to, _cc] :: HeaderFields -> [String]
[_from, _subject, _inReplyTo] :: HeaderFields -> Maybe String
headerFields :: PrimDarcsOption HeaderFields
sendToContext :: PrimDarcsOption (Maybe AbsolutePath)
mail :: PrimDarcsOption Bool
sendmailCmd :: PrimDarcsOption (Maybe String)
charset :: PrimDarcsOption (Maybe String)
editDescription :: PrimDarcsOption Bool
applyAs :: PrimDarcsOption (Maybe String)
data Sign
NoSign :: Sign
Sign :: Sign
SignAs :: String -> Sign
SignSSL :: String -> Sign
sign :: PrimDarcsOption Sign
data Verify
NoVerify :: Verify
VerifyKeyring :: AbsolutePath -> Verify
VerifySSL :: AbsolutePath -> Verify
verify :: PrimDarcsOption Verify
data AllowConflicts
NoAllowConflicts :: AllowConflicts
YesAllowConflicts :: ResolveConflicts -> AllowConflicts

-- | push, apply, rebase apply: default to <a>NoAllowConflicts</a>
conflictsNo :: PrimDarcsOption (Maybe AllowConflicts)

-- | pull, rebase pull: default to <a>YesAllowConflicts</a>
--   <a>MarkConflicts</a>
conflictsYes :: PrimDarcsOption (Maybe AllowConflicts)
data ResolveConflicts
NoResolveConflicts :: ResolveConflicts
MarkConflicts :: ResolveConflicts
ExternalMerge :: String -> ResolveConflicts

-- | pull, apply, rebase pull, rebase apply
reorder :: PrimDarcsOption Reorder

-- | push; same as <a>reorder</a> but with help descriptions swapped
reorderPush :: PrimDarcsOption Reorder
data Compression
NoCompression :: Compression
GzipCompression :: Compression

-- | push
compress :: PrimDarcsOption Compression
usePacks :: PrimDarcsOption Bool
data WithPatchIndex
YesPatchIndex :: WithPatchIndex
NoPatchIndex :: WithPatchIndex
patchIndexNo :: PrimDarcsOption WithPatchIndex
patchIndexYes :: PrimDarcsOption WithPatchIndex
data Reorder
NoReorder :: Reorder
Reorder :: Reorder
minimize :: PrimDarcsOption Bool
storeInMemory :: PrimDarcsOption Bool
data OptimizeDeep
OptimizeShallow :: OptimizeDeep
OptimizeDeep :: OptimizeDeep
optimizeDeep :: PrimDarcsOption OptimizeDeep
data Output
Output :: AbsolutePathOrStd -> Output
OutputAutoName :: AbsolutePath -> Output
output :: PrimDarcsOption (Maybe Output)
data WithSummary
NoSummary :: WithSummary
YesSummary :: WithSummary
withSummary :: PrimDarcsOption WithSummary
maybeSummary :: Maybe WithSummary -> PrimDarcsOption (Maybe WithSummary)
data RemoteDarcs
RemoteDarcs :: String -> RemoteDarcs
DefaultRemoteDarcs :: RemoteDarcs
remoteDarcs :: PrimDarcsOption RemoteDarcs
data UMask
YesUMask :: String -> UMask
NoUMask :: UMask
umask :: PrimDarcsOption UMask
data SetScriptsExecutable
YesSetScriptsExecutable :: SetScriptsExecutable
NoSetScriptsExecutable :: SetScriptsExecutable
setScriptsExecutable :: PrimDarcsOption SetScriptsExecutable
amendUnrecord :: PrimDarcsOption Bool
selectAuthor :: PrimDarcsOption Bool
machineReadable :: PrimDarcsOption Bool
data CloneKind

-- | Just copy pristine and inventories
LazyClone :: CloneKind

-- | First do a lazy clone then copy everything
NormalClone :: CloneKind

-- | Same as Normal but omit telling user they can interrumpt
CompleteClone :: CloneKind
cloneKind :: PrimDarcsOption CloneKind
distname :: PrimDarcsOption (Maybe String)
distzip :: PrimDarcsOption Bool
marks :: DarcsOption a (Maybe AbsolutePath -> Maybe AbsolutePath -> a)
readMarks :: PrimDarcsOption (Maybe AbsolutePath)
writeMarks :: PrimDarcsOption (Maybe AbsolutePath)
data PatchFormat
PatchFormat1 :: PatchFormat
PatchFormat2 :: PatchFormat
PatchFormat3 :: PatchFormat
patchFormat :: PrimDarcsOption PatchFormat

-- | Deprecated flag, still present to output an error message.
hashed :: PrimDarcsOption ()
data ChangesFormat
HumanReadable :: ChangesFormat
MachineReadable :: ChangesFormat
GenContext :: ChangesFormat
GenXml :: ChangesFormat
NumberPatches :: ChangesFormat
CountPatches :: ChangesFormat
changesFormat :: PrimDarcsOption (Maybe ChangesFormat)
tokens :: PrimDarcsOption (Maybe String)
forceReplace :: PrimDarcsOption Bool
data TestStrategy
Once :: TestStrategy
Linear :: TestStrategy
Backoff :: TestStrategy
Bisect :: TestStrategy
testStrategy :: PrimDarcsOption TestStrategy
data ShrinkFailure
ShrinkFailure :: ShrinkFailure
NoShrinkFailure :: ShrinkFailure
shrinkFailure :: PrimDarcsOption ShrinkFailure
files :: PrimDarcsOption Bool
directories :: PrimDarcsOption Bool
pending :: PrimDarcsOption Bool
nullFlag :: PrimDarcsOption Bool
data EnumPatches
NoEnumPatches :: EnumPatches
YesEnumPatches :: EnumPatches
enumPatches :: PrimDarcsOption EnumPatches
data GzcrcsAction
GzcrcsCheck :: GzcrcsAction
GzcrcsRepair :: GzcrcsAction
gzcrcsActions :: PrimDarcsOption (Maybe GzcrcsAction)
siblings :: PrimDarcsOption [AbsolutePath]
instance GHC.Show.Show Darcs.UI.Options.All.EnumPatches
instance GHC.Classes.Eq Darcs.UI.Options.All.EnumPatches
instance GHC.Show.Show Darcs.UI.Options.All.RootAction
instance GHC.Classes.Eq Darcs.UI.Options.All.RootAction
instance GHC.Show.Show Darcs.UI.Options.All.StdCmdAction
instance GHC.Classes.Eq Darcs.UI.Options.All.StdCmdAction
instance GHC.Show.Show Darcs.UI.Options.All.XmlOutput
instance GHC.Classes.Eq Darcs.UI.Options.All.XmlOutput
instance GHC.Show.Show Darcs.UI.Options.All.SelectDeps
instance GHC.Classes.Eq Darcs.UI.Options.All.SelectDeps
instance GHC.Show.Show Darcs.UI.Options.All.RepoCombinator
instance GHC.Classes.Eq Darcs.UI.Options.All.RepoCombinator
instance GHC.Show.Show Darcs.UI.Options.All.AskLongComment
instance GHC.Classes.Eq Darcs.UI.Options.All.AskLongComment
instance GHC.Show.Show Darcs.UI.Options.All.WithContext
instance GHC.Classes.Eq Darcs.UI.Options.All.WithContext
instance GHC.Show.Show Darcs.UI.Options.All.ExternalDiff
instance GHC.Classes.Eq Darcs.UI.Options.All.ExternalDiff
instance GHC.Classes.Eq Darcs.UI.Options.All.TestChanges
instance GHC.Show.Show Darcs.UI.Options.All.Sign
instance GHC.Classes.Eq Darcs.UI.Options.All.Sign
instance GHC.Show.Show Darcs.UI.Options.All.Verify
instance GHC.Classes.Eq Darcs.UI.Options.All.Verify
instance GHC.Show.Show Darcs.UI.Options.All.Compression
instance GHC.Classes.Eq Darcs.UI.Options.All.Compression
instance GHC.Show.Show Darcs.UI.Options.All.Output
instance GHC.Classes.Eq Darcs.UI.Options.All.Output
instance GHC.Show.Show Darcs.UI.Options.All.WithSummary
instance GHC.Classes.Eq Darcs.UI.Options.All.WithSummary
instance GHC.Show.Show Darcs.UI.Options.All.ChangesFormat
instance GHC.Classes.Eq Darcs.UI.Options.All.ChangesFormat
instance GHC.Show.Show Darcs.UI.Options.All.TestStrategy
instance GHC.Classes.Eq Darcs.UI.Options.All.TestStrategy
instance GHC.Show.Show Darcs.UI.Options.All.ShrinkFailure
instance GHC.Classes.Eq Darcs.UI.Options.All.ShrinkFailure
instance GHC.Show.Show Darcs.UI.Options.All.GzcrcsAction
instance GHC.Classes.Eq Darcs.UI.Options.All.GzcrcsAction
instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.WithSummary
instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.Compression
instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.WithContext
instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.XmlOutput
instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.EnumPatches
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.WithPatchIndex
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.Reorder
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.UseCache
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.DryRun
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.LookForAdds
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.LookForReplaces
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.LookForMoves
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.RunTest
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.SetScriptsExecutable
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.LeaveTestDir
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.UseIndex
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.WantGuiPause
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.WithWorkingDir
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.InheritDefault
instance Darcs.UI.Options.All.YesNo Darcs.Repository.Flags.WithPrefsTemplates

module Darcs.UI.RunHook
runPosthook :: HookConfig -> Verbosity -> AbsolutePath -> IO ExitCode
runPrehook :: HookConfig -> Verbosity -> AbsolutePath -> IO ExitCode

module Darcs.UI.Options

-- | <a>DarcsOption</a> instantiates the first two type parameters of
--   <a>OptSpec</a> to what we need in darcs.
type DarcsOption = OptSpec DarcsOptDescr Flag

-- | This is <a>PrimOptSpec</a> instantiated with <a>DarcsOptDescr</a> and
--   <a>Flag</a>.
type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v

-- | We do not instantiate the <tt>d</tt> in <tt><a>OptSpec</a> d f</tt>
--   directly with <a>OptDescr</a>. Instead we (post-) compose it with
--   <tt>(-&gt;) <a>AbsolutePath</a></tt>. Modulo newtype noise, this is
--   the same as
--   
--   <pre>
--   type <a>DarcsOptDescr</a> f = <a>OptDescr</a> (<a>AbsolutePath</a> -&gt; f)
--   </pre>
--   
--   This is so we can pass a directory relative to which an option
--   argument is interpreted (if it has the form of a relative path).
type DarcsOptDescr = Compose OptDescr ((->) AbsolutePath)

-- | Instantiate a <a>DarcsOptDescr</a> with an <a>AbsolutePath</a>
optDescr :: AbsolutePath -> DarcsOptDescr f -> OptDescr f
type Config = [Flag]
withDashes :: [Char] -> [String] -> [String]


-- | Helper functions to access option contents. Some of them are here only
--   to ease the transition from the legacy system where we manually parsed
--   the flag list to the new(er) option system. At some point this module
--   should be renamed and the re-exports from <a>Darcs.UI.Options.All</a>
--   removed.
module Darcs.UI.Flags

-- | The <a>DarcsFlag</a> type is a list of all flags that can ever be
--   passed to darcs, or to one of its commands.
data DarcsFlag
diffingOpts :: Config -> DiffOpts

-- | This will become dis-entangled as soon as we inline these functions.
wantGuiPause :: Config -> WantGuiPause

-- | Non-trivial interaction between options. Explicit <tt>-i</tt> or
--   <tt>-a</tt> dominates, else <tt>--count</tt>, <tt>--xml</tt>, or
--   <tt>--dry-run</tt> imply <tt>-a</tt>, else use the def argument.
isInteractive :: Bool -> Config -> Bool
willRemoveLogFile :: Config -> Bool
setDefault :: Bool -> Config -> SetDefault
allowConflicts :: Config -> AllowConflicts
hasXmlOutput :: Config -> Bool
hasLogfile :: Config -> Maybe AbsolutePath
quiet :: Config -> Bool
verbose :: Config -> Bool
enumeratePatches :: Config -> Bool

-- | The first argument is an <a>AbsolutePath</a>, the second a
--   <a>String</a> that may be a file path or a URL. It returns either the
--   URL, or an absolute version of the path, interpreted relative to the
--   first argument.
fixUrl :: AbsolutePath -> String -> IO String

-- | Used by commands that expect arguments to be paths in the current
--   repo. Invalid paths are dropped and a warning is issued. This may
--   leave no valid paths to return. Although these commands all fail if
--   there are no remaining valid paths, they do so in various different
--   ways, issuing error messages tailored to the command.
pathsFromArgs :: (AbsolutePath, AbsolutePath) -> [String] -> IO [AnchoredPath]

-- | Used by commands that interpret a set of optional path arguments as
--   "restrict to these paths", which affects patch selection (e.g. in log
--   command) or selection of subtrees (e.g. in record). Because of the
--   special meaning of "no arguments", we must distinguish it from "no
--   valid arguments". A result of <a>Nothing</a> here means "no
--   restriction to the set of paths". If <a>Just</a> is returned, the set
--   is guaranteed to be non-empty.
pathSetFromArgs :: (AbsolutePath, AbsolutePath) -> [String] -> IO (Maybe [AnchoredPath])

-- | <a>getRepourl</a> takes a list of flags and returns the url of the
--   repository specified by <tt>Repodir "directory"</tt> in that list of
--   flags, if any. This flag is present if darcs was invoked with
--   <tt>--repodir=DIRECTORY</tt>
getRepourl :: Config -> Maybe String

-- | <a>getAuthor</a> takes a list of flags and returns the author of the
--   change specified by <tt>Author "Leo Tolstoy"</tt> in that list of
--   flags, if any. Otherwise, if <tt>Pipe</tt> is present, asks the user
--   who is the author and returns the answer. If neither are present, try
--   to guess the author, from repository or global preference files or
--   environment variables, and if it's not possible, ask the user.
getAuthor :: Maybe String -> Bool -> IO String

-- | <a>promptAuthor</a> try to guess the author, from repository or global
--   preference files or environment variables, and if it's not possible or
--   alwaysAsk parameter is true, ask the user. If store parameter is true,
--   the new author is added into <tt>_darcs/prefs</tt>.
promptAuthor :: Bool -> Bool -> IO String

-- | <a>getEasyAuthor</a> tries to get the author name first from the
--   repository preferences, then from global preferences, then from
--   environment variables. Returns <tt>[]</tt> if it could not get it.
--   Note that it may only return multiple possibilities when reading from
--   global preferences.
getEasyAuthor :: IO [String]

-- | <a>getSendmailCmd</a> takes a list of flags and returns the sendmail
--   command to be used by <tt>darcs send</tt>. Looks for a command
--   specified by <tt>SendmailCmd "command"</tt> in that list of flags, if
--   any. This flag is present if darcs was invoked with
--   <tt>--sendmail-command=COMMAND</tt> Alternatively the user can set
--   <tt>$S</tt><tt>ENDMAIL</tt> which will be used as a fallback if
--   present.
getSendmailCmd :: Config -> IO (Maybe String)
fileHelpAuthor :: [String]
environmentHelpEmail :: ([String], [String])

-- | <a>getSubject</a> takes a list of flags and returns the subject of the
--   mail to be sent by <tt>darcs send</tt>. Looks for a subject specified
--   by <tt>Subject "subject"</tt> in that list of flags, if any. This flag
--   is present if darcs was invoked with <tt>--subject=SUBJECT</tt>
getSubject :: Config -> Maybe String
getInReplyTo :: Config -> Maybe String

-- | <a>getCc</a> takes a list of flags and returns the addresses to send a
--   copy of the patch bundle to when using <tt>darcs send</tt>. looks for
--   a cc address specified by <tt>Cc "address"</tt> in that list of flags.
--   Returns the addresses as a comma separated string.
getCc :: Config -> String
environmentHelpSendmail :: ([String], [String])

-- | Accessor for output option. Takes and returns IO actions so that the
--   default value is only calculated if needed, as it might involve
--   filesystem actions that can fail.
getOutput :: Config -> IO FilePath -> Maybe (IO AbsolutePathOrStd)
getDate :: Bool -> IO String
workRepo :: Config -> WorkRepo
withNewRepo :: String -> Config -> Config
diffAlgorithm :: PrimDarcsOption DiffAlgorithm

-- | pull, apply, rebase pull, rebase apply
reorder :: PrimDarcsOption Reorder
minimize :: PrimDarcsOption Bool
editDescription :: PrimDarcsOption Bool
maxCount :: PrimDarcsOption (Maybe Int)
matchAny :: MatchOption
withContext :: PrimDarcsOption WithContext
allowCaseDifferingFilenames :: PrimDarcsOption Bool
allowWindowsReservedFilenames :: PrimDarcsOption Bool
changesReverse :: PrimDarcsOption Bool
usePacks :: PrimDarcsOption Bool

-- | TODO: see issue2395
onlyToFiles :: PrimDarcsOption Bool
amendUnrecord :: PrimDarcsOption Bool
verbosity :: PrimDarcsOption Verbosity
useCache :: PrimDarcsOption UseCache
useIndex :: PrimDarcsOption UseIndex
umask :: PrimDarcsOption UMask

-- | TODO someone wrote here long ago that any time --dry-run is a
--   possibility automated users should be able to examine the results more
--   easily with --xml. See also issue2397. dryRun w/o xml is currently
--   used in add, pull, and repair.
dryRun :: PrimDarcsOption DryRun
testChanges :: PrimDarcsOption TestChanges
setScriptsExecutable :: PrimDarcsOption SetScriptsExecutable

-- | convert, clone, init
withWorkingDir :: PrimDarcsOption WithWorkingDir
leaveTestDir :: PrimDarcsOption LeaveTestDir
cloneKind :: PrimDarcsOption CloneKind
patchIndexNo :: PrimDarcsOption WithPatchIndex
patchIndexYes :: PrimDarcsOption WithPatchIndex
xmlOutput :: PrimDarcsOption XmlOutput
selectDeps :: PrimDarcsOption SelectDeps
author :: PrimDarcsOption (Maybe String)
patchFormat :: PrimDarcsOption PatchFormat
charset :: PrimDarcsOption (Maybe String)
siblings :: PrimDarcsOption [AbsolutePath]
applyAs :: PrimDarcsOption (Maybe String)
enumPatches :: PrimDarcsOption EnumPatches

module Darcs.UI.External
sendEmail :: String -> String -> String -> String -> Maybe String -> String -> IO ()
generateEmail :: Handle -> String -> String -> String -> String -> Doc -> IO ()

-- | Send an email, optionally containing a patch bundle (more precisely,
--   its description and the bundle itself)
sendEmailDoc :: String -> String -> String -> String -> Maybe String -> Maybe (Doc, Doc) -> Doc -> IO ()
signString :: Sign -> Doc -> IO Doc
verifyPS :: Verify -> ByteString -> IO (Maybe ByteString)
execDocPipe :: String -> [String] -> Doc -> IO Doc
pipeDoc :: String -> [String] -> Doc -> IO ExitCode
pipeDocSSH :: Compression -> SshFilePath -> [String] -> Doc -> IO ExitCode
viewDoc :: Doc -> IO ()
viewDocWith :: Printers -> Doc -> IO ()
checkDefaultSendmail :: IO ()
diffProgram :: IO String

-- | Get the name of the darcs executable (as supplied by
--   <tt>getExecutablePath</tt>)
darcsProgram :: IO String
editText :: String -> ByteString -> IO ByteString

-- | <tt>editFile f</tt> lets the user edit a file which could but does not
--   need to already exist. This function returns the exit code from the
--   text editor and a flag indicating if the user made any changes.
editFile :: FilePathLike p => p -> IO (ExitCode, Bool)

-- | On Posix systems, GHC by default uses the user's locale encoding to
--   determine how to decode/encode the raw byte sequences in the Posix API
--   to/from <a>String</a>. It also uses certain special variants of this
--   encoding to determine how to handle encoding errors.
--   
--   See <a>GHC.IO.Encoding</a> for details.
--   
--   In particular, the default variant used for command line arguments and
--   environment variables is /<i>ROUNDTRIP, which means that </i>any/ byte
--   sequence can be decoded and re-encoded w/o failure or loss of
--   information. To enable this, GHC uses code points that are outside the
--   range of the regular unicode set. This is what you get with
--   <a>getFileSystemEncoding</a>.
--   
--   We need to preserve the raw bytes e.g. for file names passed in by the
--   user and also when reading file names from disk; also when
--   re-generating files from patches, and when we display them to the
--   user.
--   
--   So we want to use this encoding variant for *all* IO and for (almost)
--   all conversions between raw bytes and <a>String</a>s. The encoding
--   used for IO from and to handles is controlled by
--   <a>setLocaleEncoding</a> which we use here to make it equal to the
--   //ROUNDTRIP variant.
--   
--   <tt>setDarcsEncoding</tt> should be called before the first time any
--   darcs operation is run, and again if anything else might have set
--   those encodings to different values.
--   
--   Note that it isn't thread-safe and has a global effect on your
--   program.
--   
--   On Windows, this function does (and should) not do anything.
setDarcsEncodings :: IO ()

module Darcs.UI.PrintPatch

-- | Print a patch, together with its context, on standard output, using a
--   pager.
contextualPrintPatchWithPager :: (ApplyMonadTrans (ApplyState p) IO, ShowContextPatch p) => ApplyState p IO -> p wX wY -> IO ()
printContent :: ShowPatch p => p wX wY -> IO ()
printContentWithPager :: ShowPatch p => p wX wY -> IO ()

-- | <tt><a>printFriendly</a> opts patch</tt> prints <tt>patch</tt> in
--   accordance with the flags in opts, ie, whether <tt>--verbose</tt> or
--   <tt>--summary</tt> were passed at the command-line.
printFriendly :: ShowPatch p => Verbosity -> WithSummary -> p wX wY -> IO ()
printSummary :: ShowPatch p => p wX wY -> IO ()

-- | <tt><a>showFriendly</a> flags patch</tt> returns a <a>Doc</a>
--   representing the right way to show <tt>patch</tt> given the list
--   <tt>flags</tt> of flags darcs was invoked with.
showFriendly :: ShowPatch p => Verbosity -> WithSummary -> p wX wY -> Doc
showWithSummary :: ShowPatch p => p wX wY -> Doc

module Darcs.UI.SelectChanges

-- | When asking about patches, we either ask about them in oldest-first or
--   newest first (with respect to the current ordering of the repository),
--   and we either want an initial segment or a final segment of the poset
--   of patches.
--   
--   <a>First</a>: ask for an initial segment, first patches first (default
--   for all pull-like commands)
--   
--   <a>FirstReversed</a>: ask for an initial segment, last patches first
--   (used to ask about dependencies in record, and for pull-like commands
--   with the <tt>--reverse</tt> flag).
--   
--   <a>LastReversed</a>: ask for a final segment, last patches first.
--   (default for unpull-like commands, except for selecting *primitive*
--   patches in rollback)
--   
--   <a>Last</a>: ask for a final segment, first patches first. (used for
--   selecting primitive patches in rollback, and for unpull-like commands
--   with the <tt>--reverse</tt> flag
--   
--   IOW: First = initial segment Last = final segment Reversed = start
--   with the newest patch instead of oldest As usual, terminology is not,
--   ahem, very intuitive.
data WhichChanges
Last :: WhichChanges
LastReversed :: WhichChanges
First :: WhichChanges
FirstReversed :: WhichChanges

-- | The equivalent of <a>runSelection</a> for the <tt>darcs log</tt>
--   command
viewChanges :: (ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => PatchSelectionOptions -> [Sealed2 p] -> IO ()

-- | The function for selecting a patch to amend record. Read at your own
--   risks.
withSelectedPatchFromList :: (Commute p, Matchable p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => String -> RL p wX wY -> PatchSelectionOptions -> ((RL p :> p) wX wY -> IO ()) -> IO ()

-- | Run a <tt>PatchSelection</tt> action in the given
--   <a>SelectionConfig</a>, without assuming that patches are invertible.
runSelection :: (MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree, ApplyState p ~ ApplyState (PrimOf p)) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY)

-- | Run a <tt>PatchSelection</tt> action in the given
--   <a>SelectionConfig</a>, assuming patches are invertible.
runInvertibleSelection :: forall p wX wY. (Invert p, MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY)

-- | A <a>SelectionConfig</a> for selecting <tt>Prim</tt> patches.
selectionConfigPrim :: WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter prim) -> Maybe [AnchoredPath] -> SelectionConfig prim

-- | A generic <a>SelectionConfig</a>.
selectionConfigGeneric :: Matchable p => (forall wX wY. q wX wY -> Sealed2 p) -> WhichChanges -> String -> PatchSelectionOptions -> Maybe [AnchoredPath] -> SelectionConfig q

-- | A <a>SelectionConfig</a> for selecting full (<a>Matchable</a>) patches
selectionConfig :: Matchable p => WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter p) -> Maybe [AnchoredPath] -> SelectionConfig p

-- | All the static settings for selecting patches.
data SelectionConfig p
data PatchSelectionOptions
PatchSelectionOptions :: Verbosity -> [MatchFlag] -> Bool -> SelectDeps -> WithSummary -> PatchSelectionOptions
[verbosity] :: PatchSelectionOptions -> Verbosity
[matchFlags] :: PatchSelectionOptions -> [MatchFlag]
[interactive] :: PatchSelectionOptions -> Bool
[selectDeps] :: PatchSelectionOptions -> SelectDeps
[withSummary] :: PatchSelectionOptions -> WithSummary
type InteractiveSelectionM p wX wY a = StateT (InteractiveSelectionState p wX wY) (PatchSelectionM p IO) a

-- | The dynamic parameters for interactive selection of patches.
data InteractiveSelectionState p wX wY
ISC :: Int -> Int -> FZipper (LabelledPatch p) wX wY -> PatchChoices p wX wY -> InteractiveSelectionState p wX wY

-- | total number of patches
[total] :: InteractiveSelectionState p wX wY -> Int

-- | number of already-seen patches
[current] :: InteractiveSelectionState p wX wY -> Int

-- | the patches we offer
[lps] :: InteractiveSelectionState p wX wY -> FZipper (LabelledPatch p) wX wY

-- | the user's choices
[choices] :: InteractiveSelectionState p wX wY -> PatchChoices p wX wY
initialSelectionState :: FL (LabelledPatch p) wX wY -> PatchChoices p wX wY -> InteractiveSelectionState p wX wY

-- | Returns a <a>Sealed2</a> version of the patch we are asking the user
--   about.
currentPatch :: InteractiveSelectionM p wX wY (Maybe (Sealed2 (LabelledPatch p)))

-- | Skips patches we should not ask the user about
skipMundane :: (Commute p, ShowPatch p) => InteractiveSelectionM p wX wY ()

-- | Focus the next patch.
skipOne :: InteractiveSelectionM p wX wY ()

-- | Focus the previous patch.
backOne :: InteractiveSelectionM p wX wY ()
backAll :: InteractiveSelectionM p wX wY ()

-- | <tt>decide True</tt> selects the current patch, and <tt>decide
--   False</tt> deselects it.
decide :: Commute p => Bool -> LabelledPatch p wA wB -> InteractiveSelectionM p wX wY ()

-- | like <a>decide</a>, but for all patches touching <tt>file</tt>
decideWholeFile :: (Commute p, PatchInspect p) => AnchoredPath -> Bool -> InteractiveSelectionM p wX wY ()
isSingleFile :: PatchInspect p => p wX wY -> Bool

-- | returns <tt>Just f</tt> if the <a>currentPatch</a> only modifies
--   <tt>f</tt>, <tt>Nothing</tt> otherwise.
currentFile :: PatchInspect p => InteractiveSelectionM p wX wY (Maybe AnchoredPath)

-- | Asks the user about one patch, returns their answer.
promptUser :: ShowPatch p => Bool -> Char -> InteractiveSelectionM p wX wY Char

-- | The question to ask about one patch.
prompt :: ShowPatch p => InteractiveSelectionM p wX wY String

-- | The type of the answers to a "shall I [wiggle] that [foo]?" question
--   They are found in a [[KeyPress]] bunch, each list representing a set
--   of answers which belong together
data KeyPress
KeyPress :: Char -> String -> KeyPress
[kp] :: KeyPress -> Char
[kpHelp] :: KeyPress -> String

-- | The keys used by a list of <tt>keyPress</tt> groups.
keysFor :: [[KeyPress]] -> [Char]

-- | Generates the help for a set of basic and advanced <a>KeyPress</a>
--   groups.
helpFor :: String -> [[KeyPress]] -> [[KeyPress]] -> String

-- | For a given sequence of preceding patches to choose from, and a
--   sequence of prims which will become a new named patch, let the user
--   select a subset such that the new patch will explicitly depend on
--   them. The patches offered include only those that the new patch does
--   not already depend on. To support amend, we pass in the old
--   dependencies, too.
askAboutDepends :: (RepoPatch p, ApplyState p ~ Tree) => RL (PatchInfoAnd p) wX wR -> FL (PrimOf p) wR wT -> PatchSelectionOptions -> [PatchInfo] -> IO [PatchInfo]
instance GHC.Show.Show Darcs.UI.SelectChanges.WhichChanges
instance GHC.Classes.Eq Darcs.UI.SelectChanges.WhichChanges

module Darcs.UI.PatchHeader

-- | Get the patch name and long description from one of
--   
--   <ul>
--   <li>the configuration (flags, defaults, hard-coded)</li>
--   <li>an existing log file</li>
--   <li>stdin (e.g. a pipe)</li>
--   <li>a text editor</li>
--   </ul>
--   
--   It ensures the patch name is not empty nor starts with the prefix TAG.
--   
--   The last result component is a possible path to a temporary file that
--   should be removed later.
getLog :: Maybe String -> Bool -> Logfile -> Maybe AskLongComment -> Maybe (String, [String]) -> Doc -> IO (String, [String], Maybe String)

-- | <tt>getAuthor</tt> tries to return the updated author for the patch.
--   There are two different scenarios:
--   
--   <ul>
--   <li>[explicit] Either we want to override the patch author, be it by
--   prompting the user (<tt>select</tt>) or having them pass it in from
--   the UI (<tt>new_author</tt>), or</li>
--   <li>[implicit] We want to keep the original author, in which case we
--   also double-check that we are not inadvertently "hijacking" somebody
--   else's patch (if the patch author is not the same as the repository
--   author, we give them a chance to abort the whole operation)</li>
--   </ul>
getAuthor :: String -> Bool -> Maybe String -> PatchInfo -> HijackT IO String
editLog :: Named prim wX wY -> IO (Named prim wX wY)

-- | Update the metadata for a patch. This potentially involves a bit of
--   interactivity, so we may return <tt>Nothing</tt> if there is cause to
--   abort what we're doing along the way
updatePatchHeader :: forall p wX wY wZ. (RepoPatch p, ApplyState p ~ Tree) => String -> AskAboutDeps p wX -> PatchSelectionOptions -> PatchHeaderConfig -> Named (PrimOf p) wX wY -> FL (PrimOf p) wY wZ -> HijackT IO (Maybe String, PatchInfoAnd p wX wZ)

-- | Specify whether to ask about dependencies with respect to a particular
--   <tt>PatchSet</tt>, or not
data AskAboutDeps p wX
[AskAboutDeps] :: RL (PatchInfoAnd p) w wX -> AskAboutDeps p wX
[NoAskAboutDeps] :: AskAboutDeps p wX
data PatchHeaderConfig
patchHeaderConfig :: Config -> PatchHeaderConfig

-- | Transformer for interactions with a hijack warning state that we need
--   to thread through
type HijackT = StateT HijackOptions

-- | Options for how to deal with the situation where we are somehow
--   modifying a patch that is not our own
data HijackOptions

-- | accept all hijack requests
IgnoreHijack :: HijackOptions

-- | prompt once, accepting subsequent hijacks if yes
RequestHijackPermission :: HijackOptions

-- | always prompt
AlwaysRequestHijackPermission :: HijackOptions

-- | Run a job that involves a hijack confirmation prompt.
--   
--   See <a>RequestHijackPermission</a> for initial values
runHijackT :: Monad m => HijackOptions -> HijackT m a -> m a

module Darcs.UI.Commands.Convert.Util
type Marks = IntMap ByteString
emptyMarks :: Marks
addMark :: Marks -> Int -> ByteString -> Marks
getMark :: Marks -> Int -> Maybe ByteString
lastMark :: Marks -> Int
readMarks :: FilePath -> IO Marks
writeMarks :: FilePath -> Marks -> IO ()
patchHash :: PatchInfoAnd p cX cY -> ByteString
updatePending :: [DarcsFlag] -> UpdatePending


-- | Generic wrapper for prim patches to give them an identity.
module Darcs.Patch.Prim.WithName

-- | A <a>PrimWithName</a> is a general way of associating an identity with
--   an underlying (presumably unnamed) primitive type. This is required,
--   for example, for V3 patches. Normally the members of the <tt>name</tt>
--   type will be generated in some way when a patch is initially created,
--   to guarantee global unqiueness across all repositories.
data PrimWithName name p wX wY
PrimWithName :: !name -> !p wX wY -> PrimWithName name p wX wY
[wnName] :: PrimWithName name p wX wY -> !name
[wnPatch] :: PrimWithName name p wX wY -> !p wX wY
instance Darcs.Patch.Ident.SignedId name => Darcs.Patch.Ident.Ident (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (GHC.Classes.Eq name, Darcs.Patch.Witnesses.Eq.Eq2 p) => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Invert.Invert p, Darcs.Patch.Ident.SignedId name) => Darcs.Patch.Invert.Invert (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Witnesses.Show.Show2 p, GHC.Show.Show name) => GHC.Show.Show (Darcs.Patch.Prim.WithName.PrimWithName name p wX wY)
instance (Darcs.Patch.Witnesses.Show.Show2 p, GHC.Show.Show name) => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Prim.WithName.PrimWithName name p wX)
instance (Darcs.Patch.Witnesses.Show.Show2 p, GHC.Show.Show name) => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Repair.RepairToFL (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Annotate.Class.Annotate p => Darcs.Patch.Annotate.Class.Annotate (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.FileHunk.IsHunk p => Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Prim.Class.PrimApply p => Darcs.Patch.Prim.Class.PrimApply (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance Darcs.Patch.Prim.Class.PrimDetails p => Darcs.Patch.Prim.Class.PrimDetails (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Commute.Commute p) => Darcs.Patch.Commute.Commute (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Merge.CleanMerge p) => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.StorableId name, Darcs.Patch.Read.ReadPatch p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.StorableId name, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimDetails p, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Prim.WithName.PrimWithName name p)
instance (Darcs.Patch.Ident.StorableId name, Darcs.Patch.Show.ShowContextPatch p) => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Prim.WithName.PrimWithName name p)


-- | <a>Conflictor</a>s a la camp.
--   
--   Similar to the camp paper, but with a few differences:
--   
--   <ul>
--   <li>no reverse conflictors and no Invert instance</li>
--   <li>instead we directly implement cleanMerge</li>
--   <li>minor details of merge and commute due to bug fixes</li>
--   </ul>
--   
--   The proofs in this module assume that whenever we create a conflictor
--   we maintain the following invariants:
--   
--   <ol>
--   <li>A conflictor reverts a patch in its context iff it is the first
--   patch that conflicts with it. This implies that any patch a conflictor
--   reverts exists in its context as an unconflicted Prim.</li>
--   <li>If v depends on u and p conflicts with u then it also conflicts
--   with v.</li>
--   </ol>
module Darcs.Patch.V3.Core
data RepoPatchV3 name prim wX wY
[Prim] :: PrimWithName name prim wX wY -> RepoPatchV3 name prim wX wY
[Conflictor] :: FL (PrimWithName name prim) wX wY -> Set (Contexted (PrimWithName name prim) wY) -> Contexted (PrimWithName name prim) wY -> RepoPatchV3 name prim wX wY
pattern PrimP :: TestOnly => PrimWithName name prim wX wY -> RepoPatchV3 name prim wX wY
pattern ConflictorP :: TestOnly => FL (PrimWithName name prim) wX wY -> Set (Contexted (PrimWithName name prim) wY) -> Contexted (PrimWithName name prim) wY -> RepoPatchV3 name prim wX wY

-- | A handy synonym for <a>insert</a>.
(+|) :: Ord a => a -> Set a -> Set a
infixr 9 +|

-- | A handy synonym for <a>delete</a>.
(-|) :: Ord a => a -> Set a -> Set a
infixr 9 -|
instance Darcs.Patch.Effect.Effect (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Ident.SignedId name => Darcs.Patch.Ident.Ident (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Merge.Merge (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.CommuteNoConflicts.CommuteNoConflicts (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Commute.Commute (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Inspect.PatchInspect prim => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Witnesses.Eq.Eq2 prim, Darcs.Patch.Commute.Commute prim) => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (GHC.Show.Show name, Darcs.Patch.Witnesses.Show.Show2 prim) => GHC.Show.Show (Darcs.Patch.V3.Core.RepoPatchV3 name prim wX wY)
instance (GHC.Show.Show name, Darcs.Patch.Witnesses.Show.Show2 prim) => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.V3.Core.RepoPatchV3 name prim wX)
instance (GHC.Show.Show name, Darcs.Patch.Witnesses.Show.Show2 prim) => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.FromPrim.ToPrim (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Debug.PatchDebug prim => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Apply.Apply (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.FileHunk.IsHunk prim => Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Summary.Summary (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Invert.Invert prim, Darcs.Patch.Commute.Commute prim, Darcs.Patch.Witnesses.Eq.Eq2 prim) => Darcs.Patch.Unwind.Unwind (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Repair.Check (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Repair.RepairToFL (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Show.ShowPatch (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.V3.Core.RepoPatchV3 name prim)
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.V3.Core.RepoPatchV3 name prim)


-- | Conflict resolution for <a>RepoPatchV3</a>
module Darcs.Patch.V3.Resolution
instance (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Ident.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Conflict.Conflict (Darcs.Patch.V3.Core.RepoPatchV3 name prim)


-- | Wrapper for prim patches to give them an identity derived from the
--   identity of the containined Named patch.
module Darcs.Patch.Prim.Named
type NamedPrim = PrimWithName PrimPatchId

-- | Signed patch identity. The <a>SHA1</a> hash of the non-inverted meta
--   data (<a>PatchInfo</a>) plus an <a>Int</a> for the sequence number
--   within the named patch, starting with 1. The <a>Int</a> gets inverted
--   together with the patch and must never be 0 else we could not
--   distinguish between the patch and its inverse.
data PrimPatchId
namedPrim :: PrimPatchId -> p wX wY -> NamedPrim p wX wY

-- | Create an infinite list of positive <a>PrimPatchId</a>s.
positivePrimPatchIds :: PatchInfo -> [PrimPatchId]
anonymousNamedPrim :: p wX wY -> NamedPrim p wX wY

-- | This should only be used for testing, as it exposes the internal
--   structure of a <a>PrimPatchId</a>.
unsafePrimPatchId :: TestOnly => Int -> SHA1 -> PrimPatchId
prop_primPatchIdNonZero :: PrimPatchId -> Bool
instance GHC.Show.Show Darcs.Patch.Prim.Named.PrimPatchId
instance GHC.Classes.Ord Darcs.Patch.Prim.Named.PrimPatchId
instance GHC.Classes.Eq Darcs.Patch.Prim.Named.PrimPatchId
instance Darcs.Patch.Ident.SignedId Darcs.Patch.Prim.Named.PrimPatchId
instance Darcs.Patch.Ident.StorableId Darcs.Patch.Prim.Named.PrimPatchId

module Darcs.Patch.V3
type RepoPatchV3 = RepoPatchV3 PrimPatchId
instance Darcs.Patch.FromPrim.FromPrim (Darcs.Patch.V3.RepoPatchV3 prim)

module Darcs.Patch.Rebase.Change
data RebaseChange prim wX wY
[RC] :: FL (RebaseFixup prim) wX wY -> Named prim wY wZ -> RebaseChange prim wX wZ

-- | Turn a selected rebase patch back into a patch we can apply to the
--   main repository, together with residual fixups that need to go back
--   into the rebase state (unless the rebase is now finished). Any fixups
--   associated with the patch will turn into conflicts.
extractRebaseChange :: forall p wX wY. RepoPatch p => DiffAlgorithm -> FL (RebaseChange (PrimOf p)) wX wY -> (FL (WDDNamed p) :> FL (RebaseFixup (PrimOf p))) wX wY

-- | Like <a>extractRebaseChange</a>, but any fixups are "reified" into a
--   separate patch.
reifyRebaseChange :: FromPrim p => String -> FL (RebaseChange (PrimOf p)) wX wY -> IO ((FL (WDDNamed p) :> FL (RebaseFixup (PrimOf p))) wX wY)

-- | Split a list of rebase patches into those that will have conflicts if
--   unsuspended and those that won't.
partitionUnconflicted :: Commute prim => FL (RebaseChange prim) wX wY -> (FL (RebaseChange prim) :> RL (RebaseChange prim)) wX wY

-- | Get hold of the <a>Named</a> patch inside a <a>RebaseChange</a> and
--   wrap it in a <a>PatchInfoAnd</a>.
rcToPia :: RebaseChange prim wX wY -> Sealed2 (PatchInfoAnd prim)

-- | A patch, together with a list of patch names that it used to depend
--   on, but were lost during the rebasing process. The UI can use this
--   information to report them to the user.
data WithDroppedDeps p wX wY
WithDroppedDeps :: p wX wY -> [PatchInfo] -> WithDroppedDeps p wX wY
[wddPatch] :: WithDroppedDeps p wX wY -> p wX wY
[wddDependedOn] :: WithDroppedDeps p wX wY -> [PatchInfo]
type WDDNamed p = WithDroppedDeps (Named p)
commuterIdWDD :: CommuteFn p q -> CommuteFn p (WithDroppedDeps q)

-- | Given a list of rebase items, try to push a new fixup as far as
--   possible into the list as possible, using both commutation and
--   coalescing. If the fixup commutes past all the <tt>ToEdit</tt> patches
--   then it is dropped entirely.
simplifyPush :: PrimPatch prim => DiffAlgorithm -> RebaseFixup prim wX wY -> FL (RebaseChange prim) wY wZ -> Sealed (FL (RebaseChange prim) wX)

-- | Like <a>simplifyPush</a> but for a list of fixups.
simplifyPushes :: PrimPatch prim => DiffAlgorithm -> FL (RebaseFixup prim) wX wY -> FL (RebaseChange prim) wY wZ -> Sealed (FL (RebaseChange prim) wX)
addNamedToRebase :: RepoPatch p => DiffAlgorithm -> Named p wX wY -> FL (RebaseChange (PrimOf p)) wY wZ -> Sealed (FL (RebaseChange (PrimOf p)) wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => GHC.Show.Show (Darcs.Patch.Rebase.Change.RebaseChange prim wX wY)
instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Rebase.Change.WithDroppedDeps p)
instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.Rebase.Change.WithDroppedDeps p)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Rebase.Change.RebaseChange prim wX)
instance Darcs.Patch.Witnesses.Show.Show2 prim => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Debug.PatchDebug prim => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Named.HasDeps (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Ident.Ident (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Apply.Apply prim => Darcs.Patch.Apply.Apply (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Commute.Commute prim => Darcs.Patch.Summary.Summary (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowPatch (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Prim.Class.PrimPatch prim => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance (Darcs.Patch.Read.ReadPatch prim, Darcs.Patch.Format.PatchListFormat prim) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Commute.Commute prim => Darcs.Patch.Commute.Commute (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Inspect.PatchInspect prim => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.Rebase.Change.RebaseChange prim)
instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Rebase.Change.RebaseChange prim)

module Darcs.Patch.Rebase.Legacy.Item

-- | A single item in the rebase state consists of either a patch that is
--   being edited, or a fixup that adjusts the context so that a subsequent
--   patch that is being edited "makes sense".
--   
--   <tt>ToEdit</tt> holds a patch that is being edited. The name
--   (<tt>PatchInfo</tt>) of the patch will typically be the name the patch
--   had before it was added to the rebase state; if it is moved back into
--   the repository it must be given a fresh name to account for the fact
--   that it will not necessarily have the same dependencies or content as
--   the original patch. This is typically done by changing the
--   <tt>Ignore-This</tt> junk.
--   
--   <tt>Fixup</tt> adjusts the context so that a subsequent
--   <tt>ToEdit</tt> patch is correct. Where possible, <tt>Fixup</tt>
--   changes are commuted as far as possible into the rebase state, so any
--   remaining ones will typically cause a conflict when the
--   <tt>ToEdit</tt> patch is moved back into the repository.
data RebaseItem p wX wY
[ToEdit] :: Named p wX wY -> RebaseItem p wX wY
[Fixup] :: RebaseFixup (PrimOf p) wX wY -> RebaseItem p wX wY
toRebaseChanges :: RepoPatch p => FL (RebaseItem p) wX wY -> Sealed (FL (RebaseChange (PrimOf p)) wX)
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => GHC.Show.Show (Darcs.Patch.Rebase.Legacy.Item.RebaseItem p wX wY)
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Rebase.Legacy.Item.RebaseItem p wX)
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Rebase.Legacy.Item.RebaseItem p)
instance (Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Read.ReadPatch p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Legacy.Item.RebaseItem p)

module Darcs.Patch.Rebase.Suspended

-- | A <tt>Suspended</tt> patch contains the entire rebase state, in the
--   form of <a>RebaseChange</a>s. The end state is existientially
--   quantified and thus hidden.
data Suspended p wX
[Items] :: FL (RebaseChange (PrimOf p)) wX wY -> Suspended p wX
countToEdit :: Suspended p wX -> Int
simplifyPush :: PrimPatchBase p => DiffAlgorithm -> RebaseFixup (PrimOf p) wX wY -> Suspended p wY -> Suspended p wX
simplifyPushes :: PrimPatchBase p => DiffAlgorithm -> FL (RebaseFixup (PrimOf p)) wX wY -> Suspended p wY -> Suspended p wX

-- | add fixups for the name and effect of a patch to a <a>Suspended</a>
addFixupsToSuspended :: (PrimPatchBase p, Effect p) => Named p wX wY -> Suspended p wY -> Suspended p wX

-- | Remove fixups (actually, add their inverse) for the name and effect of
--   a patch to a <a>Suspended</a>.
removeFixupsFromSuspended :: (PrimPatchBase p, Effect p) => Named p wX wY -> Suspended p wX -> Suspended p wY

-- | Add <a>Named</a> patches for editing to a <a>Suspended</a>. The
--   patches to be suspended are renamed by replacing the junk in their
--   <tt>Patchinfo</tt>.
--   
--   The reason we rename patches immediately when suspending them is that
--   the user may pull an identical copy from a clone, Which means we have
--   the same patch name twice, once in the normal repo and once suspended.
--   Furthermore, they can again suspend that copy, leaving us with
--   multiple copies of the same patch in the rebase state. This is bad
--   because it invalidates most of the invariants for RebaseName fixups.
--   See issue2445 and tests/rebase-repull.sh for examples which lead to
--   crashes when we don't do the renaming here.
addToEditsToSuspended :: RepoPatch p => DiffAlgorithm -> FL (Named p) wX wY -> Suspended p wY -> IO (Suspended p wX)
readSuspended :: forall p wX. RepoPatch p => Parser (Suspended p wX)
showSuspended :: PrimPatchBase p => ShowPatchFor -> Suspended p wX -> Doc
instance (Darcs.Patch.Witnesses.Show.Show2 p, Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.FromPrim.PrimOf p)) => GHC.Show.Show (Darcs.Patch.Rebase.Suspended.Suspended p wX)

module Darcs.Patch.Rebase.Legacy.Wrapped

-- | A patch that lives in a repository where an old-style rebase is in
--   progress. Such a repository will consist of <tt>Normal</tt> patches
--   along with exactly one <tt>Suspended</tt> patch.
--   
--   It is here only so that we can upgrade an old-style rebase.
--   
--   <tt>NormalP</tt> represents a normal patch within a respository where
--   a rebase is in progress. <tt>NormalP p</tt> is given the same on-disk
--   representation as <tt>p</tt>, so a repository can be switched into and
--   out of rebasing mode simply by adding or removing a <tt>RebaseP</tt>
--   patch and setting the appropriate format flag.
--   
--   Note that the witnesses are such that the <tt>RebaseP</tt> patch has
--   no effect on the context of the rest of the repository; in a sense the
--   patches within it are dangling off to one side from the main
--   repository.
data WrappedNamed p wX wY
[NormalP] :: !Named p wX wY -> WrappedNamed p wX wY
[RebaseP] :: (PrimPatchBase p, FromPrim p, Effect p) => !PatchInfo -> !Suspended p wX -> WrappedNamed p wX wX
fromRebasing :: WrappedNamed p wX wY -> Named p wX wY
instance Darcs.Patch.RepoPatch.RepoPatch p => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Legacy.Wrapped.WrappedNamed p)
instance Darcs.Patch.Format.PatchListFormat p => Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Rebase.Legacy.Wrapped.ReadRebasing p)
instance Darcs.Patch.RepoPatch.RepoPatch p => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Legacy.Wrapped.ReadRebasing p)

module Darcs.Repository.Rebase
readTentativeRebase :: RepoPatch p => Repository rt p wU wR -> IO (Suspended p wR)
writeTentativeRebase :: RepoPatch p => Repository rt p wU wR -> Suspended p wR -> IO ()
withTentativeRebase :: RepoPatch p => Repository rt p wU wR -> Repository rt p wU wR' -> (Suspended p wR -> Suspended p wR') -> IO ()
readRebase :: RepoPatch p => Repository rt p wU wR -> IO (Suspended p wR)
finalizeTentativeRebase :: IO ()
revertTentativeRebase :: RepoPatch p => Repository rt p wU wR -> IO ()
withManualRebaseUpdate :: RepoPatch p => Repository rt p wU wR -> (Repository rt p wU wR -> IO (Repository rt p wU wR', FL (RebaseFixup (PrimOf p)) wR' wR, x)) -> IO (Repository rt p wU wR', x)

-- | Fail unless we already have some suspended patches. Not essential,
--   since all rebase commands should be happy to work with an empty rebase
--   state.
checkHasRebase :: Repository rt p wU wR -> IO ()

-- | Report the rebase status if there is (still) a rebase in progress
--   after the command has finished running. To be called via
--   <tt>finally</tt> for every <tt>RepoJob</tt>.
displayRebaseStatus :: RepoPatch p => Repository rt p wU wR -> IO ()

-- | Rebase format update for all commands that modify the repo, except
--   rebase upgrade. This is called by <tt>finalizeRepositoryChanges</tt>.
updateRebaseFormat :: RepoPatch p => Repository 'RW p wU wR -> IO ()
extractOldStyleRebase :: forall p wA wB. RepoPatch p => RL (PiaW p) wA wB -> Maybe ((RL (PatchInfoAnd p) :> Dup (Suspended p)) wA wB)

-- | Fail if there is an old-style rebase present. To be called initially
--   for every command except rebase upgrade.
checkOldStyleRebaseStatus :: Repository rt p wU wR -> IO ()

module Darcs.Repository.Hashed

-- | revertTentativeChanges swaps the tentative and "real" hashed inventory
--   files, and then updates the tentative pristine with the "real"
--   inventory hash.
revertTentativeChanges :: Repository 'RO p wU wR -> IO ()

-- | finalizeTentativeChanges trys to atomically swap the tentative
--   inventory/pristine pointers with the "real" pointers; it first
--   re-reads the inventory to optimize it, presumably to take account of
--   any new tags, and then writes out the new tentative inventory, and
--   finally does the atomic swap. In general, we can't clean the pristine
--   cache at the same time, since a simultaneous get might be in progress.
finalizeTentativeChanges :: RepoPatch p => Repository 'RW p wU wR -> IO ()

-- | Add (append) a patch to the tentative inventory. Warning: this allows
--   to add any arbitrary patch! Used by convert import and
--   <a>tentativelyAddPatch_</a>.
addToTentativeInventory :: RepoPatch p => Cache -> PatchInfoAnd p wX wY -> IO ()

-- | Read inventories and patches from a <a>Repository</a> and return them
--   as a <a>PatchSet</a>. Note that patches and inventories are read
--   lazily.
readPatches :: RepoPatch p => Repository rt p wU wR -> IO (PatchSet p Origin wR)

-- | Read the tentative <a>PatchSet</a> of a (hashed) <a>Repository</a>.
readTentativePatches :: (PatchListFormat p, ReadPatch p) => Repository 'RW p wU wR -> IO (PatchSet p Origin wR)

-- | writeAndReadPatch makes a patch lazy, by writing it out to disk (thus
--   forcing it), and then re-reads the patch lazily.
writeAndReadPatch :: RepoPatch p => Cache -> PatchInfoAnd p wX wY -> IO (PatchInfoAnd p wX wY)

-- | Write a <a>PatchSet</a> to the tentative inventory.
writeTentativeInventory :: RepoPatch p => Repository 'RW p wU wR -> PatchSet p Origin wX -> IO ()

-- | Copy the hashed inventory from the given location to the given
--   repository, possibly using the given remote darcs binary.
copyHashedInventory :: Repository 'RO p wU wR -> RemoteDarcs -> String -> IO ()

-- | Write a <a>PatchInfoAnd</a> to disk and return an
--   <a>InventoryEntry</a> i.e. the patch info and hash. However, if we
--   patch already contains a hash, assume it has already been written to
--   disk at some point and merely return the info and hash.
writePatchIfNecessary :: RepoPatch p => Cache -> PatchInfoAnd p wX wY -> IO InventoryEntry
tentativelyAddPatch :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> PatchInfoAnd p wR wY -> IO (Repository 'RW p wU wY)
tentativelyRemovePatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wX wR -> IO (Repository 'RW p wU wX)
tentativelyRemovePatches_ :: (RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wX wR -> IO (Repository 'RW p wU wX)
tentativelyAddPatch_ :: (RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository 'RW p wU wR -> UpdatePending -> PatchInfoAnd p wR wY -> IO (Repository 'RW p wU wY)
tentativelyAddPatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wR wY -> IO (Repository 'RW p wU wY)
tentativelyAddPatches_ :: (RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wR wY -> IO (Repository 'RW p wU wY)

-- | Writes out a fresh copy of the inventory that minimizes the amount of
--   inventory that need be downloaded when people pull from the
--   repository. The exact beavior depends on the 3rd parameter:
--   
--   For <a>OptimizeShallow</a> it breaks up the inventory on the most
--   recent tag. This speeds up most commands when run remotely, both
--   because a smaller file needs to be transfered (only the most recent
--   inventory). It also gives a guarantee that all the patches prior to a
--   given tag are included in that tag, so less commutation and history
--   traversal is needed. This latter issue can become very important in
--   large repositories.
--   
--   For <a>OptimizeDeep</a>, the whole repo is traversed, from oldest to
--   newest patch. Every tag we encounter is made clean, but only if that
--   doesn't make any previous clean tag unclean. Every clean tags gets its
--   own inventory. This speeds up "deep" operations, too, such as cloning
--   a specific tag. It does not necessarily make the latest tag clean, but
--   the benefits are similar to the shallow case.
reorderInventory :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> OptimizeDeep -> IO ()
data UpdatePristine
UpdatePristine :: UpdatePristine
DontUpdatePristine :: UpdatePristine
DontUpdatePristineNorRevert :: UpdatePristine

-- | XOR of all hashes of the patches' metadata. It enables to quickly see
--   whether two repositories have the same patches, independently of their
--   order. It relies on the assumption that the same patch cannot be
--   present twice in a repository. This checksum is not cryptographically
--   secure, see <a>http://robotics.stanford.edu/~xb/crypto06b/</a> .
repoXor :: RepoPatch p => Repository rt p wU wR -> IO SHA1
instance GHC.Classes.Eq Darcs.Repository.Hashed.UpdatePristine

module Darcs.Repository.Transaction

-- | Slightly confusingly named: as well as throwing away any tentative
--   changes, revertRepositoryChanges also re-initialises the tentative
--   state. It's therefore used before makign any changes to the repo.
revertRepositoryChanges :: RepoPatch p => Repository 'RO p wU wR -> IO (Repository 'RW p wU wR)

-- | Atomically copy the tentative state to the recorded state, thereby
--   committing the tentative changes that were made so far. This includes
--   inventories, pending, rebase, and the index.
finalizeRepositoryChanges :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> DryRun -> IO (Repository 'RO p wU wR)

-- | Upgrade a possible old-style rebase in progress to the new style.
upgradeOldStyleRebase :: forall p wU wR. (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> IO ()

module Darcs.Repository.Repair
replayRepository :: (RepoPatch p, ApplyState p ~ Tree) => DiffAlgorithm -> Repository rt p wU wR -> Verbosity -> (RepositoryConsistency p wR -> IO a) -> IO a
checkIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> Bool -> IO Bool
replayRepositoryInTemp :: (RepoPatch p, ApplyState p ~ Tree) => DiffAlgorithm -> Repository rt p wU wR -> Verbosity -> IO (RepositoryConsistency p wR)
data RepositoryConsistency p wR
RepositoryConsistency :: Maybe (Tree IO, Sealed (FL (PrimOf p) wR)) -> Maybe (PatchSet p Origin wR) -> Maybe (Sealed (FL (PrimOf p) wR)) -> RepositoryConsistency p wR
[fixedPristine] :: RepositoryConsistency p wR -> Maybe (Tree IO, Sealed (FL (PrimOf p) wR))
[fixedPatches] :: RepositoryConsistency p wR -> Maybe (PatchSet p Origin wR)
[fixedPending] :: RepositoryConsistency p wR -> Maybe (Sealed (FL (PrimOf p) wR))


-- | Packs are an optimization that enable faster repository cloning over
--   HTTP. A pack is actually a <tt>tar.gz</tt> file that contains many
--   files that would otherwise have to be transfered one by one (which is
--   much slower over HTTP).
--   
--   Two packs are created at the same time by <a>createPacks</a>:
--   
--   <ol>
--   <li>The basic pack, contains the pristine tree.</li>
--   <li>The patches pack, contains the set of patches of the
--   repository.</li>
--   </ol>
--   
--   The paths of these files are <tt>_darcs/packs/basic.tar.gz</tt> and
--   <tt>_darcs/packs/patches.tar.gz</tt>. There is also
--   <tt>_darcs/packs/pristine</tt> which indicates the pristine hash at
--   the moment of the creation of the packs. This last file is useful to
--   determine whether the basic pack is in sync with the current pristine
--   of the repository.
module Darcs.Repository.Packs
fetchAndUnpackBasic :: Cache -> FilePath -> IO ()
fetchAndUnpackPatches :: [InventoryHash] -> [PatchHash] -> Cache -> FilePath -> IO ()
packsDir :: String

-- | Create packs from the current recorded version of the repository.
createPacks :: RepoPatch p => Repository 'RW p wU wR -> IO ()

module Darcs.Repository.Merge
tentativelyMergePatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> String -> AllowConflicts -> WantGuiPause -> Reorder -> DiffOpts -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU))
considerMergeToWorking :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> String -> AllowConflicts -> WantGuiPause -> Reorder -> DiffOpts -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU))
instance GHC.Classes.Eq Darcs.Repository.Merge.MakeChanges

module Darcs.Repository.Match

-- | Return the pristine tree up to the given <a>PatchSetMatch</a>. In the
--   typical case where the match is closer to the end of the repo than its
--   beginning, this is (a lot) more efficient than applying the result of
--   <a>getOnePatchset</a> to an empty tree.
getPristineUpToMatch :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> PatchSetMatch -> IO (Tree IO)

-- | Return the patches up to the given <a>PatchSetMatch</a>.
getOnePatchset :: RepoPatch p => Repository rt p wU wR -> PatchSetMatch -> IO (SealedPatchSet p Origin)

module Darcs.Repository.Working
applyToWorking :: (ApplyState p ~ Tree, RepoPatch p) => Repository rt p wU wR -> Verbosity -> FL (PrimOf p) wU wY -> IO (Repository rt p wY wR)
setAllScriptsExecutable :: IO ()
setScriptsExecutablePatches :: PatchInspect p => p wX wY -> IO ()


-- | A set of functions to identify and find Darcs repositories from a
--   given <tt>URL</tt> or a given filesystem path.
module Darcs.Repository.Identify

-- | Try to identify the repository at a given location, passed as a
--   <a>String</a>. If the lcation is ".", then we assume we are
--   identifying the local repository. Otherwise we assume we are dealing
--   with a remote repo, which could be a URL or an absolute path.
maybeIdentifyRepository :: UseCache -> String -> IO (IdentifyRepo 'RO p wU wR)

-- | identifyRepository identifies the repo at <tt>url</tt>. Warning: you
--   have to know what kind of patches are found in that repo.
identifyRepository :: UseCache -> String -> IO (Repository 'RO p wU wR)

-- | <tt>identifyRepositoryFor repo url</tt> identifies (and returns) the
--   repo at <tt>url</tt>, but fails if it is not compatible for reading
--   from and writing to.
identifyRepositoryFor :: ReadingOrWriting -> Repository rt p wU wR -> UseCache -> String -> IO (Repository 'RO p vR vU)

-- | The status of a given directory: is it a darcs repository?
data IdentifyRepo rt p wU wR

-- | looks like a repository with some error
BadRepository :: String -> IdentifyRepo rt p wU wR

-- | safest guess
NonRepository :: String -> IdentifyRepo rt p wU wR
GoodRepository :: Repository rt p wU wR -> IdentifyRepo rt p wU wR
data ReadingOrWriting
Reading :: ReadingOrWriting
Writing :: ReadingOrWriting
findRepository :: WorkRepo -> IO (Either String ())
amInRepository :: WorkRepo -> IO (Either String ())
amNotInRepository :: WorkRepo -> IO (Either String ())
amInHashedRepository :: WorkRepo -> IO (Either String ())

-- | hunt upwards for the darcs repository This keeps changing up one
--   parent directory, testing at each step if the current directory is a
--   repository or not. The result is: Nothing, if no repository found Just
--   (Left errorMessage), if bad repository found Just (Right ()), if good
--   repository found. WARNING this changes the current directory for good
--   if matchFn succeeds
seekRepo :: IO (Maybe (Either String ()))

module Darcs.Repository.Job

-- | A <tt>RepoJob</tt> wraps up an action to be performed with a
--   repository. Because repositories can contain different types of
--   patches, such actions typically need to be polymorphic in the kind of
--   patch they work on. <tt>RepoJob</tt> is used to wrap up the
--   polymorphism, and the various functions that act on a <tt>RepoJob</tt>
--   are responsible for instantiating the underlying action with the
--   appropriate patch type.
data RepoJob rt a

-- | The most common <a>RepoJob</a>; the underlying action can accept any
--   patch whose <a>ApplyState</a> is <a>Tree</a>.
RepoJob :: TreePatchJob rt a -> RepoJob rt a

-- | A job that only works on darcs 1 patches
V1Job :: V1PatchJob rt a -> RepoJob rt a

-- | A job that only works on darcs 2 patches
V2Job :: V2PatchJob rt a -> RepoJob rt a

-- | A job that works on any repository where the patch type <tt>p</tt> has
--   <a>PrimOf</a> <tt>p</tt> = <a>Prim</a>. This was added to support
--   darcsden, which inspects the internals of V1 prim patches. In future
--   it should be replaced with a more abstract inspection API as part of
--   <tt>PrimPatch</tt>.
PrimV1Job :: PrimV1PatchJob rt a -> RepoJob rt a

-- | A job that works even if there is an old-style rebase in progress.
OldRebaseJob :: TreePatchJob rt a -> RepoJob rt a
class IsPrimV1 p
toPrimV1 :: IsPrimV1 p => p wX wY -> Prim wX wY

-- | Apply a given RepoJob to a repository in the current working
--   directory. However, before doing the job, take the repo lock and
--   initializes a repo transaction.
withRepoLock :: UseCache -> UMask -> RepoJob 'RW a -> IO a

-- | run a lock-taking job in an old-fashion repository. only used by
--   `darcs optimize upgrade`.
withOldRepoLock :: RepoJob 'RW a -> IO a

-- | Apply a given RepoJob to a repository in the current working
--   directory, taking a lock. If lock not takeable, do nothing. If
--   old-fashioned repository, do nothing. The job must not touch pending
--   or pending.tentative, because there is no call to
--   revertRepositoryChanges. This entry point is currently only used for
--   attemptCreatePatchIndex.
withRepoLockCanFail :: UseCache -> RepoJob 'RO () -> IO ()

-- | apply a given RepoJob to a repository in the current working directory
withRepository :: UseCache -> RepoJob 'RO a -> IO a

-- | apply a given RepoJob to a repository in a given url
withRepositoryLocation :: UseCache -> String -> RepoJob 'RO a -> IO a
withUMaskFlag :: UMask -> IO a -> IO a
instance Darcs.Repository.Job.IsPrimV1 Darcs.Patch.V1.Prim.Prim
instance Darcs.Repository.Job.IsPrimV1 Darcs.Patch.V2.Prim.Prim


-- | How to complete arguments
module Darcs.UI.Completion

-- | Return all files available under the original working directory
--   regardless of their repo state.
fileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath]

-- | Return all files available under the original working directory that
--   are known to darcs (either recorded or pending).
knownFileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath]

-- | Return all files available under the original working directory that
--   are unknown to darcs but could be added.
unknownFileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath]

-- | Return all files available under the original working directory that
--   are modified (relative to the recorded state).
modifiedFileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath]

-- | Return an empty list.
noArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String]
data Pref
Author :: Pref
Binaries :: Pref
Boring :: Pref
Defaultrepo :: Pref
Defaults :: Pref
Email :: Pref
Motd :: Pref
Post :: Pref
Prefs :: Pref
Repos :: Pref
Sources :: Pref

-- | Return the available prefs of the given kind.
prefArgs :: Pref -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String]

module Darcs.Repository.Create
createRepository :: PatchFormat -> WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO EmptyRepository
createRepositoryV1 :: WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO (Repository 'RO (RepoPatchV1 Prim) Origin Origin)
createRepositoryV2 :: WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO (Repository 'RO (RepoPatchV2 Prim) Origin Origin)
data EmptyRepository
[EmptyRepository] :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RO p Origin Origin -> EmptyRepository

module Darcs.Repository.Clone
cloneRepository :: String -> String -> Verbosity -> UseCache -> CloneKind -> UMask -> RemoteDarcs -> SetScriptsExecutable -> SetDefault -> InheritDefault -> [MatchFlag] -> RepoFormat -> WithWorkingDir -> WithPatchIndex -> Bool -> ForgetParent -> WithPrefsTemplates -> IO ()

module Darcs.Repository

-- | A <tt>Repository</tt> is a token representing the state of a
--   repository on disk. It is parameterized by
--   
--   <ul>
--   <li><i><tt>rt</tt></i> the access type (whether we are in a
--   transaction or not),</li>
--   <li><i><tt>p</tt></i> the patch type,</li>
--   <li><i><tt>wU</tt></i> the witness for the unrecorded state (what's in
--   the working tree now).</li>
--   <li><i><tt>wR</tt></i> the witness for<ul><li>the recorded state when
--   outside a transaction, or</li><li>the tentative state when inside a
--   transaction.</li></ul></li>
--   </ul>
data Repository (rt :: AccessType) (p :: * -> * -> *) wU wR
data AccessType
RO :: AccessType
RW :: AccessType
repoLocation :: Repository rt p wU wR -> String
repoFormat :: Repository rt p wU wR -> RepoFormat
repoPristineType :: Repository rt p wU wR -> PristineType
repoCache :: Repository rt p wU wR -> Cache
data PristineType
NoPristine :: PristineType
PlainPristine :: PristineType
HashedPristine :: PristineType

-- | Semantically, this is the type of hashed objects. Git has a type tag
--   inside the hashed file itself, whereas in Darcs the type is determined
--   by the subdirectory.
data HashedDir
HashedPristineDir :: HashedDir
HashedPatchesDir :: HashedDir
HashedInventoriesDir :: HashedDir

-- | Cache is an abstract type for hiding the underlying cache locations
data Cache
data CacheLoc
Cache :: !CacheType -> !WritableOrNot -> !String -> CacheLoc
[cacheType] :: CacheLoc -> !CacheType
[cacheWritable] :: CacheLoc -> !WritableOrNot
[cacheSource] :: CacheLoc -> !String
data CacheType
Repo :: CacheType
Directory :: CacheType
data WritableOrNot
Writable :: WritableOrNot
NotWritable :: WritableOrNot
cacheEntries :: Cache -> [CacheLoc]

-- | Smart constructor for <a>CacheLoc</a>.
mkCache :: [CacheLoc] -> Cache

-- | Prints an error message with a list of bad caches.
reportBadSources :: IO ()

-- | A <tt>RepoJob</tt> wraps up an action to be performed with a
--   repository. Because repositories can contain different types of
--   patches, such actions typically need to be polymorphic in the kind of
--   patch they work on. <tt>RepoJob</tt> is used to wrap up the
--   polymorphism, and the various functions that act on a <tt>RepoJob</tt>
--   are responsible for instantiating the underlying action with the
--   appropriate patch type.
data RepoJob rt a

-- | The most common <a>RepoJob</a>; the underlying action can accept any
--   patch whose <a>ApplyState</a> is <a>Tree</a>.
RepoJob :: TreePatchJob rt a -> RepoJob rt a

-- | A job that only works on darcs 1 patches
V1Job :: V1PatchJob rt a -> RepoJob rt a

-- | A job that only works on darcs 2 patches
V2Job :: V2PatchJob rt a -> RepoJob rt a

-- | A job that works on any repository where the patch type <tt>p</tt> has
--   <a>PrimOf</a> <tt>p</tt> = <a>Prim</a>. This was added to support
--   darcsden, which inspects the internals of V1 prim patches. In future
--   it should be replaced with a more abstract inspection API as part of
--   <tt>PrimPatch</tt>.
PrimV1Job :: PrimV1PatchJob rt a -> RepoJob rt a

-- | A job that works even if there is an old-style rebase in progress.
OldRebaseJob :: TreePatchJob rt a -> RepoJob rt a

-- | Try to identify the repository at a given location, passed as a
--   <a>String</a>. If the lcation is ".", then we assume we are
--   identifying the local repository. Otherwise we assume we are dealing
--   with a remote repo, which could be a URL or an absolute path.
maybeIdentifyRepository :: UseCache -> String -> IO (IdentifyRepo 'RO p wU wR)

-- | <tt>identifyRepositoryFor repo url</tt> identifies (and returns) the
--   repo at <tt>url</tt>, but fails if it is not compatible for reading
--   from and writing to.
identifyRepositoryFor :: ReadingOrWriting -> Repository rt p wU wR -> UseCache -> String -> IO (Repository 'RO p vR vU)
data ReadingOrWriting
Reading :: ReadingOrWriting
Writing :: ReadingOrWriting

-- | Apply a given RepoJob to a repository in the current working
--   directory. However, before doing the job, take the repo lock and
--   initializes a repo transaction.
withRepoLock :: UseCache -> UMask -> RepoJob 'RW a -> IO a

-- | Apply a given RepoJob to a repository in the current working
--   directory, taking a lock. If lock not takeable, do nothing. If
--   old-fashioned repository, do nothing. The job must not touch pending
--   or pending.tentative, because there is no call to
--   revertRepositoryChanges. This entry point is currently only used for
--   attemptCreatePatchIndex.
withRepoLockCanFail :: UseCache -> RepoJob 'RO () -> IO ()

-- | apply a given RepoJob to a repository in the current working directory
withRepository :: UseCache -> RepoJob 'RO a -> IO a

-- | apply a given RepoJob to a repository in a given url
withRepositoryLocation :: UseCache -> String -> RepoJob 'RO a -> IO a
withUMaskFlag :: UMask -> IO a -> IO a
findRepository :: WorkRepo -> IO (Either String ())
amInRepository :: WorkRepo -> IO (Either String ())
amNotInRepository :: WorkRepo -> IO (Either String ())
amInHashedRepository :: WorkRepo -> IO (Either String ())

-- | Replace the existing pristine with a new one (loaded up in a Tree
--   object). Warning: If <tt>rt ~ 'RO</tt> this overwrites the recorded
--   state, use only when creating a new repo!
writePristine :: Repository rt p wU wR -> Tree IO -> IO PristineHash

-- | Read inventories and patches from a <a>Repository</a> and return them
--   as a <a>PatchSet</a>. Note that patches and inventories are read
--   lazily.
readPatches :: RepoPatch p => Repository rt p wU wR -> IO (PatchSet p Origin wR)
prefsUrl :: String -> Pref -> String

-- | Add an <a>FL</a> of patches starting from the working state to the
--   pending patch, including as much extra context as is necessary
--   (context meaning dependencies), by commuting the patches to be added
--   past as much of the changes between pending and working as is
--   possible, and including anything that doesn't commute, and the patch
--   itself in the new pending patch.
addToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> DiffOpts -> FL (PrimOf p) wU wY -> IO ()

-- | Add an <a>FL</a> of patches started from the pending state to the
--   pending patch.
unsafeAddToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> FreeLeft (FL (PrimOf p)) -> IO ()
tentativelyAddPatch :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> PatchInfoAnd p wR wY -> IO (Repository 'RW p wU wY)
tentativelyAddPatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wR wY -> IO (Repository 'RW p wU wY)
tentativelyRemovePatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> UpdatePending -> FL (PatchInfoAnd p) wX wR -> IO (Repository 'RW p wU wX)

-- | Overwrites the pending patch with a new one, starting at the tentative
--   state.
setTentativePending :: forall p wU wR wP. RepoPatch p => Repository 'RW p wU wR -> FL (PrimOf p) wR wP -> IO ()

-- | Remove as much as possible of the given list of prim patches from the
--   pending patch. It is used by record and amend to update pending.
--   
--   The "as much as possible" is due to --look-for-* options which cause
--   changes that normally must be explicitly done by the user (such as
--   add, move, and replace) to be inferred from the the diff between
--   pristine and working. Also, before we present prims to the user to
--   select for recording, we coalesce prims from pending and working,
--   which is reason we have to use decoalescing.
tentativelyRemoveFromPW :: forall p wR wO wP wU. RepoPatch p => Repository 'RW p wU wR -> FL (PrimOf p) wO wR -> FL (PrimOf p) wO wP -> FL (PrimOf p) wP wU -> IO ()
withManualRebaseUpdate :: RepoPatch p => Repository rt p wU wR -> (Repository rt p wU wR -> IO (Repository rt p wU wR', FL (RebaseFixup (PrimOf p)) wR' wR, x)) -> IO (Repository rt p wU wR', x)
tentativelyMergePatches :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> String -> AllowConflicts -> WantGuiPause -> Reorder -> DiffOpts -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU))
considerMergeToWorking :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> String -> AllowConflicts -> WantGuiPause -> Reorder -> DiffOpts -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU))

-- | Slightly confusingly named: as well as throwing away any tentative
--   changes, revertRepositoryChanges also re-initialises the tentative
--   state. It's therefore used before makign any changes to the repo.
revertRepositoryChanges :: RepoPatch p => Repository 'RO p wU wR -> IO (Repository 'RW p wU wR)
data UpdatePending
YesUpdatePending :: UpdatePending
NoUpdatePending :: UpdatePending

-- | Atomically copy the tentative state to the recorded state, thereby
--   committing the tentative changes that were made so far. This includes
--   inventories, pending, rebase, and the index.
finalizeRepositoryChanges :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> DryRun -> IO (Repository 'RO p wU wR)
createRepository :: PatchFormat -> WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO EmptyRepository
createRepositoryV1 :: WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO (Repository 'RO (RepoPatchV1 Prim) Origin Origin)
createRepositoryV2 :: WithWorkingDir -> WithPatchIndex -> UseCache -> WithPrefsTemplates -> IO (Repository 'RO (RepoPatchV2 Prim) Origin Origin)
data EmptyRepository
[EmptyRepository] :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RO p Origin Origin -> EmptyRepository
cloneRepository :: String -> String -> Verbosity -> UseCache -> CloneKind -> UMask -> RemoteDarcs -> SetScriptsExecutable -> SetDefault -> InheritDefault -> [MatchFlag] -> RepoFormat -> WithWorkingDir -> WithPatchIndex -> Bool -> ForgetParent -> WithPrefsTemplates -> IO ()
applyToWorking :: (ApplyState p ~ Tree, RepoPatch p) => Repository rt p wU wR -> Verbosity -> FL (PrimOf p) wU wY -> IO (Repository rt p wY wR)

-- | Write the pristine tree into a plain directory at the given path.
createPristineDirectoryTree :: Repository rt p wU wR -> FilePath -> WithWorkingDir -> IO ()

-- | Writes out a fresh copy of the inventory that minimizes the amount of
--   inventory that need be downloaded when people pull from the
--   repository. The exact beavior depends on the 3rd parameter:
--   
--   For <a>OptimizeShallow</a> it breaks up the inventory on the most
--   recent tag. This speeds up most commands when run remotely, both
--   because a smaller file needs to be transfered (only the most recent
--   inventory). It also gives a guarantee that all the patches prior to a
--   given tag are included in that tag, so less commutation and history
--   traversal is needed. This latter issue can become very important in
--   large repositories.
--   
--   For <a>OptimizeDeep</a>, the whole repo is traversed, from oldest to
--   newest patch. Every tag we encounter is made clean, but only if that
--   doesn't make any previous clean tag unclean. Every clean tags gets its
--   own inventory. This speeds up "deep" operations, too, such as cloning
--   a specific tag. It does not necessarily make the latest tag clean, but
--   the benefits are similar to the shallow case.
reorderInventory :: (RepoPatch p, ApplyState p ~ Tree) => Repository 'RW p wU wR -> OptimizeDeep -> IO ()
cleanRepository :: Repository 'RW p wU wR -> IO ()

-- | The patches in a repository are stored in chunks broken up at "clean"
--   tags. A tag is clean if the only patches before it in the current
--   repository ordering are ones that the tag depends on (either directly
--   or indirectly). Each chunk is stored in a separate inventory file on
--   disk.
--   
--   A <a>PatchSet</a> represents a repo's history as the list of patches
--   since the last clean tag, and then a list of patch lists each
--   delimited by clean tags.
--   
--   Because the invariants about clean tags can only be maintained if a
--   <a>PatchSet</a> contains the whole history, the first witness is
--   always forced to be <a>Origin</a>. The type still has two witnesses so
--   it can easily be used with combinators like <a>:&gt;</a> and
--   <tt>Fork</tt>.
--   
--   The history is lazily loaded from disk so does not normally need to be
--   all kept in memory.
data PatchSet p wStart wY
type SealedPatchSet p wStart = Sealed ((PatchSet p) wStart)
type PatchInfoAnd p = PatchInfoAndG (Named p)
setAllScriptsExecutable :: IO ()
setScriptsExecutablePatches :: PatchInspect p => p wX wY -> IO ()
modifyCache :: (Cache -> Cache) -> Repository rt p wU wR -> Repository rt p wU wR

-- | Obtains a Tree corresponding to the "recorded" state of the
--   repository: this is the same as the pristine cache, which is the same
--   as the result of applying all the repository's patches to an empty
--   directory.
readPristine :: Repository rt p wU wR -> IO (Tree IO)

-- | Obtains a Tree corresponding to the "unrecorded" state of the
--   repository: the modified files of the working tree plus the "pending"
--   patch. The optional list of paths allows to restrict the query to a
--   subtree.
--   
--   Limiting the query may be more efficient, since hashes on the
--   uninteresting parts of the index do not need to go through an
--   up-to-date check (which involves a relatively expensive lstat(2) per
--   file.
readUnrecorded :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> UseIndex -> Maybe [AnchoredPath] -> IO (Tree IO)

-- | For a repository and an optional list of paths (when <a>Nothing</a>,
--   take everything) compute a (forward) list of prims (i.e. a patch)
--   going from the recorded state of the repository (pristine) to the
--   unrecorded state of the repository (the working tree + pending). When
--   a list of paths is given, at least the files that live under any of
--   these paths in either recorded or unrecorded will be included in the
--   resulting patch. NB. More patches may be included in this list, eg.
--   the full contents of the pending patch. This is usually not a problem,
--   since selectChanges will properly filter the results anyway.
--   
--   This also depends on the options given:
--   
--   <ul>
--   <li>-look-for-moves: Detect pending file moves using the index. The
--   resulting patches are added to pending and taken into consideration,
--   when filtering the tree according to the given path list.</li>
--   <li>-look-for-adds: Include files in the working state that do not
--   exist in the recorded + pending state.</li>
--   <li>-include-boring: Include even boring files.</li>
--   <li>-look-for-replaces: Detect pending replace patches. Like detected
--   moves, these are added to the pending patch. Note that, like detected
--   moves, these are mere proposals for the user to consider or
--   reject.</li>
--   <li>-ignore-times: Disables index usage completely -- for each file,
--   we read both the unrecorded and the recorded copy and run a diff on
--   them. This is very inefficient, although in extremely rare cases, the
--   index could go out of sync (file is modified, index is updated and
--   file is modified again within a single second).</li>
--   </ul>
--   
--   Note that use of the index is also disabled when we detect moves or
--   replaces, since this implies that the index is out of date.
unrecordedChanges :: (RepoPatch p, ApplyState p ~ Tree) => DiffOpts -> Repository rt p wU wR -> Maybe [AnchoredPath] -> IO (FL (PrimOf p) wR wU)
readPendingAndWorking :: (RepoPatch p, ApplyState p ~ Tree) => DiffOpts -> Repository rt p wU wR -> Maybe [AnchoredPath] -> IO ((FL (PrimOf p) :> FL (PrimOf p)) wR wU)

-- | Remove any patches (+dependencies) from a sequence that conflict with
--   the recorded or unrecorded changes in a repo
filterOutConflicts :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> UseIndex -> FL (PatchInfoAnd p) wX wR -> FL (PatchInfoAnd p) wX wZ -> IO (Bool, Sealed (FL (PatchInfoAnd p) wX))

-- | Obtains the recorded <a>Tree</a> with the pending patch applied.
readPristineAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> IO (Tree IO)

module Darcs.UI.Commands.Test.Impl

-- | An indexed monad that can be used to run tests. <a>TestingEnvIO</a> is
--   the only real implementation, the unit tests for testing are based on
--   mock implementations.
class Monad m => TestRunner m where {
    type ApplyPatchReqs m (p :: * -> * -> *) :: Constraint;
    type DisplayPatchReqs m (p :: * -> * -> *) :: Constraint;
}

-- | Output a message
writeMsg :: TestRunner m => String -> m wX wX ()

-- | Output a message containing the name of a patch
mentionPatch :: (TestRunner m, DisplayPatchReqs m p) => p wA wB -> m wX wX ()

-- | Apply a patch to the testing tree.
applyPatch :: (TestRunner m, ApplyPatchReqs m p) => p wX wY -> m wX wY ()

-- | Unapply a patch from the testing tree
unapplyPatch :: (TestRunner m, ApplyPatchReqs m p) => p wX wY -> m wY wX ()

-- | Get the current status (pass<i>skip</i>fail) of the testing tree, e.g.
--   by running the test command.
getCurrentTestResult :: TestRunner m => m wX wX (TestResult wX)

-- | Flag that all testing has completed.
finishedTesting :: TestRunner m => a -> m wX TestingDone a
runStrategy :: TestablePatch m p => TestStrategy -> ShrinkFailure -> RL p wOlder wNewer -> m wNewer TestingDone (StrategyResultSealed p)

-- | The result of running a test on state <tt>wX</tt> of the repository.
data TestResult wX

-- | We got a usable test result.
Testable :: TestResultValid wX -> TestResult wX

-- | The test result could not be identified as either pass or fail, for
--   example it might have been a build failure. External test scripts
--   report this by reporting exit code 125.
Untestable :: TestResult wX

-- | A usable test result, i.e. not an untestable state.
data TestResultValid wX

-- | The test passed.
Success :: TestResultValid wX

-- | The test failed with the given exit code.
Failure :: TestFailure wX -> TestResultValid wX
data TestFailure wX
TestFailure :: Int -> TestFailure wX

-- | Once we've finished tracking down a test failure, we no longer care
--   about tracking the actual state of the testing tree. This witness
--   constant is never used in any patch, so once we use it for the state
--   of the testing tree, in practice we can no longer do anything more
--   with that tree.
--   
--   We could also use some kind of existential or different monad type to
--   represent this, but it would make composing code with 'do' harder.
data TestingDone

-- | <a>PatchSeq</a> is a sequence of patches, implemented as a binary
--   tree, balanced in an arbitrary way depending on how it happened to be
--   constructed. In the 'darcs test' implementation it is used to wrap up
--   a single patch or group of patches that might be the cause of a
--   failure.
data PatchSeq p wX wY
[Single] :: p wX wY -> PatchSeq p wX wY
[Joined] :: PatchSeq p wX wY -> PatchSeq p wY wZ -> PatchSeq p wX wZ
patchTreeToFL :: PatchSeq p wX wY -> FL p wX wY
type StrategyResult p wSuccess wFailure = StrategyResultRaw (PatchSeq p wSuccess wFailure)

-- | The result of running a test strategy.
data StrategyResultRaw patches

-- | The chosen strategy didn't find any passing states in the repository.
NoPasses :: StrategyResultRaw patches

-- | The test didn't fail on head so there's no failure to track down.
NoFailureOnHead :: StrategyResultRaw patches

-- | The failure was tracked down to the given patches. these two are just
--   for oneTest
Blame :: patches -> StrategyResultRaw patches

-- | The single test run passed.
RunSuccess :: StrategyResultRaw patches

-- | The single test run failed with the given exit code.
RunFailed :: Int -> StrategyResultRaw patches
explanatoryTextFor :: TestStrategy -> String
runTestingEnv :: TestingParams -> TestingEnv m wA TestingDone a -> m a
exitCodeToTestResult :: ExitCode -> TestResult wX
mkTestCmd :: (forall (wX :: *). IO (TestResult wX)) -> TestCmd
runTestable :: (Commute p, TestRunner (TestingEnv m), TestRunnerPatchReqs (TestingEnv m) p) => SetScriptsExecutable -> TestCmd -> TestStrategy -> ShrinkFailure -> RL p wStart wA -> m (StrategyResultSealed p)
instance GHC.Base.Functor Darcs.UI.Commands.Test.Impl.StrategyResultRaw
instance GHC.Show.Show patches => GHC.Show.Show (Darcs.UI.Commands.Test.Impl.StrategyResultRaw patches)
instance GHC.Classes.Eq patches => GHC.Classes.Eq (Darcs.UI.Commands.Test.Impl.StrategyResultRaw patches)
instance GHC.Base.Monad m => Darcs.Util.IndexedMonad.Monad (Darcs.UI.Commands.Test.Impl.TestingEnv m)
instance GHC.Base.Monad m => Darcs.Util.IndexedMonad.MonadReader Darcs.UI.Commands.Test.Impl.TestingParams (Darcs.UI.Commands.Test.Impl.TestingEnv m)
instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.UI.Commands.Test.Impl.PatchSeq p wX wY)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.UI.Commands.Test.Impl.PatchSeq p wX)
instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.UI.Commands.Test.Impl.PatchSeq p)
instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.UI.Commands.Test.Impl.PatchSeq p)
instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.UI.Commands.Test.Impl.PatchSeq p)
instance Darcs.UI.Commands.Test.Impl.TestRunner Darcs.UI.Commands.Test.Impl.TestingEnvIO
instance Darcs.Util.IndexedMonad.LiftIx Darcs.UI.Commands.Test.Impl.TestingEnv
instance GHC.Base.Monad m => Darcs.Util.IndexedMonad.Monad (Darcs.UI.Commands.Test.Impl.Testing m)
instance Darcs.Util.IndexedMonad.LiftIx Darcs.UI.Commands.Test.Impl.Testing

module Darcs.UI.Commands
data CommandControl
CommandData :: DarcsCommand -> CommandControl
HiddenCommand :: DarcsCommand -> CommandControl
GroupName :: String -> CommandControl

-- | A <a>DarcsCommand</a> represents a command like add, record etc.
data DarcsCommand
DarcsCommand :: String -> Doc -> String -> Int -> [String] -> ((AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()) -> ([DarcsFlag] -> IO (Either String ())) -> ((AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String]) -> ([DarcsFlag] -> AbsolutePath -> [String] -> IO [String]) -> CommandOptions -> DarcsCommand
[commandProgramName, commandName] :: DarcsCommand -> String
[commandHelp] :: DarcsCommand -> Doc
[commandDescription] :: DarcsCommand -> String
[commandExtraArgs] :: DarcsCommand -> Int
[commandExtraArgHelp] :: DarcsCommand -> [String]
[commandCommand] :: DarcsCommand -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
[commandPrereq] :: DarcsCommand -> [DarcsFlag] -> IO (Either String ())
[commandCompleteArgs] :: DarcsCommand -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String]
[commandArgdefaults] :: DarcsCommand -> [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
[commandOptions] :: DarcsCommand -> CommandOptions
SuperCommand :: String -> Doc -> String -> ([DarcsFlag] -> IO (Either String ())) -> [CommandControl] -> DarcsCommand
[commandProgramName, commandName] :: DarcsCommand -> String
[commandHelp] :: DarcsCommand -> Doc
[commandDescription] :: DarcsCommand -> String
[commandPrereq] :: DarcsCommand -> [DarcsFlag] -> IO (Either String ())
[commandSubCommands] :: DarcsCommand -> [CommandControl]
commandAlias :: String -> Maybe DarcsCommand -> DarcsCommand -> DarcsCommand
commandStub :: String -> Doc -> String -> DarcsCommand -> DarcsCommand

-- | Construct <a>CommandOptions</a> from the command specific basic and
--   advanced <a>DarcsOption</a>s
withStdOpts :: DarcsOption (Maybe StdCmdAction -> Verbosity -> b) c -> DarcsOption (UseCache -> UseIndex -> HooksConfig -> Bool -> Bool -> [DarcsFlag]) b -> CommandOptions

-- | Option descriptions as required by <a>getOpt</a>, i.e. resolved with
--   the given <a>AbsolutePath</a>.
commandOptDescr :: AbsolutePath -> DarcsCommand -> [OptDescr DarcsFlag]

-- | Option descriptions split into basic and advanced options
commandAlloptions :: DarcsCommand -> ([DarcsOptDescr DarcsFlag], [DarcsOptDescr DarcsFlag])

-- | Built-in default values for all <a>DarcsFlag</a>s supported by the
--   given command
commandDefaults :: DarcsCommand -> [DarcsFlag]

-- | For the given <a>DarcsCommand</a> check the given <a>DarcsFlag</a>s
--   for consistency
commandCheckOptions :: DarcsCommand -> [DarcsFlag] -> [OptMsg]
disambiguateCommands :: [CommandControl] -> String -> [String] -> Either String (CommandArgs, [String])
data CommandArgs
CommandOnly :: DarcsCommand -> CommandArgs
SuperCommandOnly :: DarcsCommand -> CommandArgs
SuperCommandSub :: DarcsCommand -> DarcsCommand -> CommandArgs
getSubcommands :: DarcsCommand -> [CommandControl]
extractCommands :: [CommandControl] -> [DarcsCommand]
extractAllCommands :: [CommandControl] -> [DarcsCommand]
normalCommand :: DarcsCommand -> CommandControl
hiddenCommand :: DarcsCommand -> CommandControl
commandGroup :: String -> CommandControl
superName :: Maybe DarcsCommand -> String
nodefaults :: [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
putInfo :: [DarcsFlag] -> Doc -> IO ()
putVerbose :: [DarcsFlag] -> Doc -> IO ()
putWarning :: [DarcsFlag] -> Doc -> IO ()
putVerboseWarning :: [DarcsFlag] -> Doc -> IO ()
putFinished :: [DarcsFlag] -> String -> IO ()
abortRun :: [DarcsFlag] -> Doc -> IO ()

-- | Set the DARCS_PATCHES and DARCS_PATCHES_XML environment variables with
--   info about the given patches, for use in post-hooks.
setEnvDarcsPatches :: RepoPatch p => FL (PatchInfoAnd p) wX wY -> IO ()

-- | Set the DARCS_FILES environment variable to the files touched by the
--   given patch, one per line, for use in post-hooks.
setEnvDarcsFiles :: PatchInspect p => p wX wY -> IO ()

-- | To use for commandArgdefaults field.
defaultRepo :: [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
amInHashedRepository :: [DarcsFlag] -> IO (Either String ())
amInRepository :: [DarcsFlag] -> IO (Either String ())
amNotInRepository :: [DarcsFlag] -> IO (Either String ())
findRepository :: [DarcsFlag] -> IO (Either String ())

module Darcs.UI.Usage
getCommandHelp :: Maybe DarcsCommand -> DarcsCommand -> Doc
getSuperCommandHelp :: DarcsCommand -> Doc
getCommandMiniHelp :: Maybe DarcsCommand -> DarcsCommand -> String
usage :: [CommandControl] -> Doc
subusage :: DarcsCommand -> Doc

module Darcs.UI.TestChanges
testTree :: Config -> Tree IO -> IO ExitCode

module Darcs.UI.Commands.Util
announceFiles :: Verbosity -> Maybe [AnchoredPath] -> String -> IO ()

-- | Given a repository and two common command options, classify the given
--   list of paths according to whether they exist in the pristine or
--   working tree. Paths which are neither in working nor pristine are
--   reported and dropped. The result is a pair of path lists: those that
--   exist only in the working tree, and those that exist in pristine or
--   working.
filterExistingPaths :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wU wR -> Verbosity -> DiffOpts -> [AnchoredPath] -> IO ([AnchoredPath], [AnchoredPath])
testTentativeAndMaybeExit :: Tree IO -> [DarcsFlag] -> String -> String -> Maybe String -> IO ()

-- | <tt><a>printDryRunMessageAndExit</a> action flags patches</tt> prints
--   a string representing the action that would be taken if the
--   <tt>--dry-run</tt> option had not been passed to darcs. Then darcs
--   exits successfully. <tt>action</tt> is the name of the action being
--   taken, like <tt>"push"</tt> <tt>flags</tt> is the list of flags which
--   were sent to darcs <tt>patches</tt> is the sequence of patches which
--   would be touched by <tt>action</tt>.
printDryRunMessageAndExit :: RepoPatch p => String -> Verbosity -> WithSummary -> DryRun -> XmlOutput -> Bool -> FL (PatchInfoAnd p) wX wY -> IO ()
getUniqueRepositoryName :: Bool -> FilePath -> IO FilePath
getUniqueDPatchName :: FilePath -> IO FilePath
doesDirectoryReallyExist :: FilePath -> IO Bool
checkUnrelatedRepos :: RepoPatch p => Bool -> PatchSet p Origin wX -> PatchSet p Origin wY -> IO ()
preselectPatches :: RepoPatch p => [DarcsFlag] -> Repository rt p wU wR -> IO ((PatchSet p :> FL (PatchInfoAnd p)) Origin wR)
getLastPatches :: RepoPatch p => [MatchFlag] -> PatchSet p Origin wR -> (PatchSet p :> FL (PatchInfoAnd p)) Origin wR
matchRange :: MatchableRP p => [MatchFlag] -> PatchSet p Origin wY -> Sealed2 (FL (PatchInfoAnd p))
historyEditHelp :: Doc
commonHelpWithPrefsTemplates :: Doc

module Darcs.UI.Commands.WhatsNew
whatsnew :: DarcsCommand

-- | An alias for <a>whatsnew</a>, with implicit <tt>-l</tt> (and thus
--   implicit <tt>-s</tt>) flags. We override the default description, to
--   include these flags.
status :: DarcsCommand

module Darcs.UI.Commands.Unrevert
unrevert :: DarcsCommand

module Darcs.UI.Commands.Unrecord
unrecord :: DarcsCommand
unpull :: DarcsCommand
obliterate :: DarcsCommand

module Darcs.UI.Commands.TransferMode
transferMode :: DarcsCommand

module Darcs.UI.Commands.Test
test :: DarcsCommand

module Darcs.UI.Commands.Tag
tag :: DarcsCommand

module Darcs.UI.Commands.ShowTags
showTags :: DarcsCommand

module Darcs.UI.Commands.ShowRepo
showRepo :: DarcsCommand

module Darcs.UI.Commands.ShowPatchIndex
showPatchIndex :: DarcsCommand

module Darcs.UI.Commands.ShowIndex
showIndex :: DarcsCommand
showPristine :: DarcsCommand

module Darcs.UI.Commands.ShowFiles
showFiles :: DarcsCommand

module Darcs.UI.Commands.ShowDependencies
showDeps :: DarcsCommand

module Darcs.UI.Commands.ShowContents
showContents :: DarcsCommand

module Darcs.UI.Commands.ShowAuthors
showAuthors :: DarcsCommand
data Spelling
compiledAuthorSpellings :: [DarcsFlag] -> IO [Spelling]
canonizeAuthor :: [Spelling] -> String -> String
rankAuthors :: [Spelling] -> [String] -> [String]

module Darcs.UI.Commands.Show
showCommand :: DarcsCommand

module Darcs.UI.Commands.SetPref
setpref :: DarcsCommand

module Darcs.UI.Commands.Rollback
rollback :: DarcsCommand

module Darcs.UI.Commands.Revert
revert :: DarcsCommand

-- | An alias for 'revert -l' i.e. remove every (non-boring) file or change
--   that is not in pristine.
clean :: DarcsCommand

module Darcs.UI.Commands.Replace
replace :: DarcsCommand
defaultToks :: String

module Darcs.UI.Commands.Repair
repair :: DarcsCommand

-- | check is an alias for repair, with implicit DryRun flag.
check :: DarcsCommand

module Darcs.UI.Commands.Remove
remove :: DarcsCommand
rm :: DarcsCommand
unadd :: DarcsCommand

module Darcs.UI.Commands.Record
record :: DarcsCommand

-- | commit is an alias for record
commit :: DarcsCommand

module Darcs.UI.Commands.Optimize
optimize :: DarcsCommand

module Darcs.UI.Commands.Move
move :: DarcsCommand
mv :: DarcsCommand
instance GHC.Classes.Eq Darcs.UI.Commands.Move.FileKind
instance GHC.Show.Show Darcs.UI.Commands.Move.FileKind
instance GHC.Show.Show Darcs.UI.Commands.Move.FileStatus

module Darcs.UI.Commands.MarkConflicts
markconflicts :: DarcsCommand
instance GHC.Show.Show a => GHC.Show.Show (Darcs.UI.Commands.MarkConflicts.Only a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Darcs.UI.Commands.MarkConflicts.Only a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Darcs.UI.Commands.MarkConflicts.Only a)
instance GHC.Base.Functor Darcs.UI.Commands.MarkConflicts.Only
instance Data.Foldable.Foldable Darcs.UI.Commands.MarkConflicts.Only
instance Data.Traversable.Traversable Darcs.UI.Commands.MarkConflicts.Only

module Darcs.UI.Commands.Log

-- | changes is an alias for log
changes :: DarcsCommand
log :: DarcsCommand
changelog :: forall p wStart wX. (ShowPatch p, PatchListFormat p, Summary p, HasDeps p, PrimDetails (PrimOf p)) => [DarcsFlag] -> RL (PatchInfoAndG p) wStart wX -> LogInfo (PatchInfoAndG p) -> Doc
logInfoFL :: FL p wX wY -> LogInfo p
simpleLogInfo :: (MatchableRP p, ApplyState p ~ Tree) => AnchoredPath -> PatchFilter p -> PatchSet p Origin wY -> IO [Sealed2 (PatchInfoAnd p)]

module Darcs.UI.Commands.Init
initialize :: DarcsCommand
initializeCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()

module Darcs.UI.Commands.GZCRCs
gzcrcs :: DarcsCommand

-- | This is designed for use in an atexit handler, e.g. in
--   Darcs.RunCommand
doCRCWarnings :: Bool -> IO ()


module Darcs.UI.Commands.Dist
dist :: DarcsCommand
doFastZip :: [DarcsFlag] -> IO ()
doFastZip' :: [DarcsFlag] -> FilePath -> (ByteString -> IO a) -> IO a

module Darcs.UI.Commands.Diff
diffCommand :: DarcsCommand

module Darcs.UI.Commands.Convert.Import
convertImport :: DarcsCommand
instance GHC.Show.Show Darcs.UI.Commands.Convert.Import.RefId
instance GHC.Show.Show Darcs.UI.Commands.Convert.Import.CopyRenameNames
instance GHC.Show.Show Darcs.UI.Commands.Convert.Import.Object
instance GHC.Show.Show (Darcs.UI.Commands.Convert.Import.State p)

module Darcs.UI.Commands.Convert.Export
convertExport :: DarcsCommand
cleanPatchAuthor :: String -> String
cleanPatchAuthorTestCases :: [(String, String)]

module Darcs.UI.Commands.Convert.Darcs2
convertDarcs2 :: DarcsCommand

module Darcs.UI.Commands.Convert
convert :: DarcsCommand

module Darcs.UI.Commands.Clone
get :: DarcsCommand
put :: DarcsCommand
clone :: DarcsCommand
makeRepoName :: Bool -> [DarcsFlag] -> FilePath -> IO String
cloneToSSH :: [DarcsFlag] -> Maybe String
otherHelpInheritDefault :: Doc

module Darcs.UI.Commands.Send
send :: DarcsCommand

module Darcs.UI.Commands.Push
push :: DarcsCommand

module Darcs.UI.Commands.Annotate
annotate :: DarcsCommand


module Darcs.UI.Commands.Amend
amend :: DarcsCommand
amendrecord :: DarcsCommand


module Darcs.UI.Commands.Add
add :: DarcsCommand

module Darcs.UI.ApplyPatches

-- | This class is a hack to abstract over pull<i>apply and rebase
--   pull</i>apply.
class PatchApplier pa
repoJob :: PatchApplier pa => pa -> (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => PatchProxy p -> Repository 'RW p wU wR -> IO ()) -> RepoJob 'RW ()
applyPatches :: forall p wR wU wZ. (PatchApplier pa, RepoPatch p, ApplyState p ~ Tree) => pa -> PatchProxy p -> String -> [DarcsFlag] -> Repository 'RW p wU wR -> Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR wZ -> IO ()
data PatchProxy (p :: * -> * -> *)
PatchProxy :: PatchProxy (p :: * -> * -> *)
data StandardPatchApplier
StandardPatchApplier :: StandardPatchApplier
applyPatchesStart :: (RepoPatch p, ApplyState p ~ Tree) => String -> [DarcsFlag] -> FL (PatchInfoAnd p) wX wY -> IO ()
applyPatchesFinish :: (RepoPatch p, ApplyState p ~ Tree) => String -> [DarcsFlag] -> Repository 'RW p wU wR -> FL (PrimOf p) wU wY -> Bool -> IO ()
instance Darcs.UI.ApplyPatches.PatchApplier Darcs.UI.ApplyPatches.StandardPatchApplier

module Darcs.UI.Commands.Pull
pull :: DarcsCommand
fetch :: DarcsCommand
pullCmd :: PatchApplier pa => pa -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
data StandardPatchApplier
fetchPatches :: (RepoPatch p, ApplyState p ~ Tree) => AbsolutePath -> [DarcsFlag] -> [String] -> String -> Repository 'RW p wU wR -> IO (Sealed (Fork (PatchSet p) (FL (PatchInfoAnd p)) (FL (PatchInfoAnd p)) Origin wR))

module Darcs.UI.Commands.Apply
apply :: DarcsCommand
applyCmd :: PatchApplier pa => pa -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
getPatchBundle :: RepoPatch p => [DarcsFlag] -> PatchSet p Origin wR -> ByteString -> IO (Either String (SealedPatchSet p Origin))

module Darcs.UI.Commands.Rebase
rebase :: DarcsCommand
instance Darcs.UI.ApplyPatches.PatchApplier Darcs.UI.Commands.Rebase.RebasePatchApplier

module Darcs.UI.TheCommands

-- | The commands that darcs knows about (e.g. whatsnew, record), organized
--   into thematic groups. Note that hidden commands are also listed here.
commandControlList :: [CommandControl]

module Darcs.UI.Defaults

-- | Apply defaults from all sources to a list of <a>DarcsFlag</a>s (e.g.
--   from the command line), given the command (and possibly super command)
--   name, and a list of all options for the command.
--   
--   Sources for defaults are
--   
--   <ul>
--   <li>the builtin (hard-coded) defaults,</li>
--   <li>the defaults file in the user's configuration, and</li>
--   <li>the defaults file in the current repository.</li>
--   </ul>
--   
--   Note that the pseudo command <tt>ALL</tt> is allowed in defaults files
--   to specify that an option should be the default for all commands to
--   which it applies.
--   
--   The order of precedence for conflicting options (i.e. those belonging
--   to same group of mutually exclusive options) is from less specific to
--   more specific. In other words, options from the command line override
--   all defaults, per-repo defaults override per-user defaults, which in
--   turn override the built-in defaults. Inside the options from a
--   defaults file, options for the given command override options for the
--   <tt>ALL</tt> pseudo command.
--   
--   Conflicting options at the same level of precedence are not allowed.
--   
--   Errors encountered during processing of command line or defaults flags
--   are formatted and added as (separate) strings to the list of error
--   messages that are returned together with the resulting flag list.
applyDefaults :: Maybe String -> DarcsCommand -> AbsolutePath -> [String] -> [String] -> [DarcsFlag] -> ([DarcsFlag], ([String], [String]))


-- | This is the actual heavy lifter code, which is responsible for parsing
--   the arguments and then running the command itself.
module Darcs.UI.RunCommand
runTheCommand :: [CommandControl] -> String -> [String] -> IO ()
runWithHooks :: DarcsCommand -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()

module Darcs.UI.Commands.Help
helpCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
commandControlList :: [CommandControl]
printVersion :: IO ()
listAvailableCommands :: IO ()
