-- 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: -- -- @package darcs @version 2.16.2 module Darcs.Patch.RepoType -- | This type is intended to be used as a phantom type via the -- DataKinds extension. It tracks different types of -- repositories, e.g. to indicate when a rebase is in progress. data RepoType RepoType :: RebaseType -> RepoType [rebaseType] :: RepoType -> RebaseType class IsRepoType (rt :: RepoType) -- | Reflect RepoType to the value level so that code can explicitly -- switch on it. singletonRepoType :: IsRepoType rt => SRepoType rt -- | A reflection of RepoType at the value level so that code can -- explicitly switch on it. data SRepoType (repoType :: RepoType) [SRepoType] :: SRebaseType rebaseType -> SRepoType ( 'RepoType rebaseType) -- | This type is intended to be used as a phantom type via the -- DataKinds extension, normally as part of RepoType. -- Indicates whether or not a rebase is in progress. data RebaseType IsRebase :: RebaseType NoRebase :: RebaseType class IsRebaseType (rebaseType :: RebaseType) -- | Extract the RebaseType from a RepoType type family RebaseTypeOf (rt :: RepoType) :: RebaseType -- | A reflection of RebaseType at the value level so that code can -- explicitly switch on it. data SRebaseType (rebaseType :: RebaseType) [SIsRebase] :: SRebaseType 'IsRebase [SNoRebase] :: SRebaseType 'NoRebase instance Darcs.Patch.RepoType.IsRebaseType rebaseType => Darcs.Patch.RepoType.IsRepoType ('Darcs.Patch.RepoType.RepoType rebaseType) instance Darcs.Patch.RepoType.IsRebaseType 'Darcs.Patch.RepoType.IsRebase instance Darcs.Patch.RepoType.IsRebaseType 'Darcs.Patch.RepoType.NoRebase 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 -- | Append two lists, i.e., -- --
--   [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
--   [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
--   
-- -- If the first list is not finite, the result is the first list. (++) :: () => [a] -> [a] -> [a] infixr 5 ++ -- | The value of seq a b is bottom if a is bottom, and -- otherwise equal to b. In other words, it evaluates the first -- argument a to weak head normal form (WHNF). seq is -- usually introduced to improve performance by avoiding unneeded -- laziness. -- -- A note on evaluation order: the expression seq a b does -- not guarantee that a will be evaluated before -- b. The only guarantee given by seq is that the both -- a and b will be evaluated before seq -- returns a value. In particular, this means that b may be -- evaluated before a. If you need to guarantee a specific order -- of evaluation, you must use the function pseq from the -- "parallel" package. seq :: () => a -> b -> b -- | filter, applied to a predicate and a list, returns the list of -- those elements that satisfy the predicate; i.e., -- --
--   filter p xs = [ x | x <- xs, p x]
--   
filter :: () => (a -> Bool) -> [a] -> [a] -- | zip takes two lists and returns a list of corresponding pairs. -- --
--   zip [1, 2] ['a', 'b'] = [(1, 'a'), (2, 'b')]
--   
-- -- If one input list is short, excess elements of the longer list are -- discarded: -- --
--   zip [1] ['a', 'b'] = [(1, 'a')]
--   zip [1, 2] ['a'] = [(1, 'a')]
--   
-- -- zip is right-lazy: -- --
--   zip [] _|_ = []
--   zip _|_ [] = _|_
--   
zip :: () => [a] -> [b] -> [(a, b)] -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- --
--   main = print ([(n, 2^n) | n <- [0..19]])
--   
print :: Show a => a -> IO () -- | Extract the first component of a pair. fst :: () => (a, b) -> a -- | Extract the second component of a pair. snd :: () => (a, b) -> b -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
--   f x | x < 0     = ...
--       | otherwise = ...
--   
otherwise :: Bool -- | map f xs is the list obtained by applying f -- to each element of xs, i.e., -- --
--   map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
--   map f [x1, x2, ...] == [f x1, f x2, ...]
--   
map :: () => (a -> b) -> [a] -> [b] -- | Application operator. This operator is redundant, since ordinary -- application (f x) means the same as (f $ x). -- However, $ has low, right-associative binding precedence, so it -- sometimes allows parentheses to be omitted; for example: -- --
--   f $ g $ h x  =  f (g (h x))
--   
-- -- It is also useful in higher-order situations, such as map -- ($ 0) xs, or zipWith ($) fs xs. -- -- Note that ($) is levity-polymorphic in its result type, so -- that foo $ True where foo :: Bool -> Int# is well-typed ($) :: () => (a -> b) -> a -> b infixr 0 $ -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- -- -- --
--   enumFrom     x   = enumFromTo     x maxBound
--   enumFromThen x y = enumFromThenTo x y bound
--     where
--       bound | fromEnum y >= fromEnum x = maxBound
--             | otherwise                = minBound
--   
class Enum a -- | the successor of a value. For numeric types, succ adds 1. succ :: Enum a => a -> a -- | Convert from an Int. toEnum :: Enum a => Int -> a -- | Convert to an Int. It is implementation-dependent what -- fromEnum returns when applied to a value that is too large to -- fit in an Int. fromEnum :: Enum a => a -> Int -- | Used in Haskell's translation of [n..] with [n..] = -- enumFrom n, a possible implementation being enumFrom n = n : -- enumFrom (succ n). For example: -- -- enumFrom :: Enum a => a -> [a] -- | Used in Haskell's translation of [n,n'..] with [n,n'..] = -- enumFromThen n n', a possible implementation being -- enumFromThen n n' = n : n' : worker (f x) (f x n'), -- worker s v = v : worker s (s v), x = fromEnum n' - -- fromEnum n and f n y | n > 0 = f (n - 1) (succ y) | n < -- 0 = f (n + 1) (pred y) | otherwise = y For example: -- -- enumFromThen :: Enum a => a -> a -> [a] -- | Used in Haskell's translation of [n..m] with [n..m] = -- enumFromTo n m, a possible implementation being enumFromTo n -- m | n <= m = n : enumFromTo (succ n) m | otherwise = []. For -- example: -- -- enumFromTo :: Enum a => a -> a -> [a] -- | Used in Haskell's translation of [n,n'..m] with [n,n'..m] -- = enumFromThenTo n n' m, a possible implementation being -- enumFromThenTo n n' m = worker (f x) (c x) n m, x = -- fromEnum n' - fromEnum n, c x = bool (>=) ((x -- 0) f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + -- 1) (pred y) | otherwise = y and worker s c v m | c v m = v : -- worker s c (s v) m | otherwise = [] For example: -- -- enumFromThenTo :: Enum a => a -> a -> a -> [a] -- | The Eq class defines equality (==) and inequality -- (/=). All the basic datatypes exported by the Prelude -- are instances of Eq, and Eq may be derived for any -- datatype whose constituents are also instances of Eq. -- -- The Haskell Report defines no laws for Eq. However, == -- is customarily expected to implement an equivalence relationship where -- two values comparing equal are indistinguishable by "public" -- functions, with a "public" function being one not allowing to see -- implementation details. For example, for a type representing -- non-normalised natural numbers modulo 100, a "public" function doesn't -- make the difference between 1 and 201. It is expected to have the -- following properties: -- -- -- -- Minimal complete definition: either == or /=. class Eq a (==) :: Eq a => a -> a -> Bool (/=) :: Eq a => a -> a -> Bool infix 4 == infix 4 /= -- | Trigonometric and hyperbolic functions and related functions. -- -- The Haskell Report defines no laws for Floating. However, -- '(+)', '(*)' and exp are customarily expected to define an -- exponential field and have the following properties: -- -- 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 infixr 8 ** -- | Fractional numbers, supporting real division. -- -- The Haskell Report defines no laws for Fractional. However, -- '(+)' and '(*)' are customarily expected to define a division ring and -- have the following properties: -- -- -- -- Note that it isn't customarily expected that a type instance of -- Fractional implement a field. However, all instances in -- base do. class Num a => Fractional a -- | fractional division (/) :: Fractional a => a -> a -> a -- | reciprocal fraction recip :: Fractional a => a -> a -- | Conversion from a Rational (that is Ratio -- Integer). A floating literal stands for an application of -- fromRational to a value of type Rational, so such -- literals have type (Fractional a) => a. fromRational :: Fractional a => Rational -> a infixl 7 / -- | Integral numbers, supporting integer division. -- -- The Haskell Report defines no laws for Integral. However, -- Integral instances are customarily expected to define a -- Euclidean domain and have the following properties for the 'div'/'mod' -- and 'quot'/'rem' pairs, given suitable Euclidean functions f -- and g: -- -- -- -- An example of a suitable Euclidean function, for Integer's -- instance, is abs. class (Real a, Enum a) => Integral a -- | integer division truncated toward zero quot :: Integral a => a -> a -> a -- | integer remainder, satisfying -- --
--   (x `quot` y)*y + (x `rem` y) == x
--   
rem :: Integral a => a -> a -> a -- | integer division truncated toward negative infinity div :: Integral a => a -> a -> a -- | integer modulus, satisfying -- --
--   (x `div` y)*y + (x `mod` y) == x
--   
mod :: Integral a => a -> a -> a -- | simultaneous quot and rem quotRem :: Integral a => a -> a -> (a, a) -- | simultaneous div and mod divMod :: Integral a => a -> a -> (a, a) -- | conversion to Integer toInteger :: Integral a => a -> Integer infixl 7 `quot` infixl 7 `rem` infixl 7 `div` infixl 7 `mod` -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following laws: -- -- -- -- Furthermore, the Monad and Applicative operations should -- relate as follows: -- -- -- -- The above laws imply: -- -- -- -- and that pure and (<*>) satisfy the applicative -- functor laws. -- -- The instances of Monad for lists, Maybe and IO -- defined in the Prelude satisfy these laws. class Applicative m => Monad (m :: Type -> Type) -- | Sequentially compose two actions, passing any value produced by the -- first as an argument to the second. (>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. (>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a -- | Fail with a message. This operation is not part of the mathematical -- definition of a monad, but is invoked on pattern-match failure in a -- do expression. -- -- As part of the MonadFail proposal (MFP), this function is moved to its -- own class MonadFail (see Control.Monad.Fail for more -- details). The definition here will be removed in a future release. fail :: Monad m => String -> m a infixl 1 >>= infixl 1 >> -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- --
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
-- -- The instances of Functor for lists, Maybe and IO -- satisfy these laws. class Functor (f :: Type -> Type) fmap :: Functor f => (a -> b) -> f a -> f b -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. (<$) :: Functor f => a -> f b -> f a infixl 4 <$ -- | Basic numeric class. -- -- The Haskell Report defines no laws for Num. However, '(+)' and -- '(*)' are customarily expected to define a ring and have the following -- properties: -- -- -- -- Note that it isn't customarily expected that a type instance of -- both Num and Ord implement an ordered ring. Indeed, in -- base only Integer and Rational do. class Num a (+) :: Num a => a -> a -> a (-) :: Num a => a -> a -> a (*) :: Num a => a -> a -> a -- | Unary negation. negate :: Num a => a -> a -- | Absolute value. abs :: Num a => a -> a -- | Sign of a number. The functions abs and signum should -- satisfy the law: -- --
--   abs x * signum x == x
--   
-- -- For real numbers, the signum is either -1 (negative), -- 0 (zero) or 1 (positive). signum :: Num a => a -> a -- | Conversion from an Integer. An integer literal represents the -- application of the function fromInteger to the appropriate -- value of type Integer, so such literals have type -- (Num a) => a. fromInteger :: Num a => Integer -> a infixl 6 + infixl 7 * infixl 6 - -- | The Ord class is used for totally ordered datatypes. -- -- Instances of Ord can be derived for any user-defined datatype -- whose constituent types are in Ord. The declared order of the -- constructors in the data declaration determines the ordering in -- derived Ord instances. The Ordering datatype allows a -- single comparison to determine the precise ordering of two objects. -- -- The Haskell Report defines no laws for Ord. However, -- <= is customarily expected to implement a non-strict partial -- order and have the following properties: -- -- -- -- Note that the following operator interactions are expected to hold: -- --
    --
  1. x >= y = y <= x
  2. --
  3. x < y = x <= y && x /= y
  4. --
  5. x > y = y < x
  6. --
  7. x < y = compare x y == LT
  8. --
  9. x > y = compare x y == GT
  10. --
  11. x == y = compare x y == EQ
  12. --
  13. min x y == if x <= y then x else y = True
  14. --
  15. max x y == if x >= y then x else y = True
  16. --
-- -- Minimal complete definition: either compare or <=. -- Using compare can be more efficient for complex types. 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 infix 4 >= infix 4 > infix 4 < infix 4 <= -- | Parsing of Strings, producing values. -- -- Derived instances of Read make the following assumptions, which -- derived instances of Show obey: -- -- -- -- For example, given the declarations -- --
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
-- -- the derived instance of Read in Haskell 2010 is equivalent to -- --
--   instance (Read a) => Read (Tree a) where
--   
--           readsPrec d r =  readParen (d > app_prec)
--                            (\r -> [(Leaf m,t) |
--                                    ("Leaf",s) <- lex r,
--                                    (m,t) <- readsPrec (app_prec+1) s]) r
--   
--                         ++ readParen (d > up_prec)
--                            (\r -> [(u:^:v,w) |
--                                    (u,s) <- readsPrec (up_prec+1) r,
--                                    (":^:",t) <- lex s,
--                                    (v,w) <- readsPrec (up_prec+1) t]) r
--   
--             where app_prec = 10
--                   up_prec = 5
--   
-- -- Note that right-associativity of :^: is unused. -- -- The derived instance in GHC is equivalent to -- --
--   instance (Read a) => Read (Tree a) where
--   
--           readPrec = parens $ (prec app_prec $ do
--                                    Ident "Leaf" <- lexP
--                                    m <- step readPrec
--                                    return (Leaf m))
--   
--                        +++ (prec up_prec $ do
--                                    u <- step readPrec
--                                    Symbol ":^:" <- lexP
--                                    v <- step readPrec
--                                    return (u :^: v))
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--           readListPrec = readListPrecDefault
--   
-- -- Why do both readsPrec and readPrec exist, and why does -- GHC opt to implement readPrec in derived Read instances -- instead of readsPrec? The reason is that readsPrec is -- based on the ReadS type, and although ReadS is mentioned -- in the Haskell 2010 Report, it is not a very efficient parser data -- structure. -- -- readPrec, on the other hand, is based on a much more efficient -- ReadPrec datatype (a.k.a "new-style parsers"), but its -- definition relies on the use of the RankNTypes language -- extension. Therefore, readPrec (and its cousin, -- readListPrec) are marked as GHC-only. Nevertheless, it is -- recommended to use readPrec instead of readsPrec -- whenever possible for the efficiency improvements it brings. -- -- As mentioned above, derived Read instances in GHC will -- implement readPrec instead of readsPrec. The default -- implementations of readsPrec (and its cousin, readList) -- will simply use readPrec under the hood. If you are writing a -- Read instance by hand, it is recommended to write it like so: -- --
--   instance Read T where
--     readPrec     = ...
--     readListPrec = readListPrecDefault
--   
class Read a -- | attempts to parse a value from the front of the string, returning a -- list of (parsed value, remaining string) pairs. If there is no -- successful parse, the returned list is empty. -- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. readsPrec :: Read a => Int -> ReadS a -- | The method readList is provided to allow the programmer to give -- a specialised way of parsing lists of values. For example, this is -- used by the predefined Read instance of the Char type, -- where values of type String should be are expected to use -- double quotes, rather than square brackets. readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a -- | a constant function, returning the radix of the representation (often -- 2) floatRadix :: RealFloat a => a -> Integer -- | a constant function, returning the number of digits of -- floatRadix in the significand floatDigits :: RealFloat a => a -> Int -- | a constant function, returning the lowest and highest values the -- exponent may assume floatRange :: RealFloat a => a -> (Int, Int) -- | The function decodeFloat applied to a real floating-point -- number returns the significand expressed as an Integer and an -- appropriately scaled exponent (an Int). If -- decodeFloat x yields (m,n), then x -- is equal in value to m*b^^n, where b is the -- floating-point radix, and furthermore, either m and -- n are both zero or else b^(d-1) <= abs m < -- b^d, where d is the value of floatDigits -- x. In particular, decodeFloat 0 = (0,0). If the -- type contains a negative zero, also decodeFloat (-0.0) = -- (0,0). The result of decodeFloat x is -- unspecified if either of isNaN x or -- isInfinite x is True. decodeFloat :: RealFloat a => a -> (Integer, Int) -- | encodeFloat performs the inverse of decodeFloat in the -- sense that for finite x with the exception of -0.0, -- uncurry encodeFloat (decodeFloat x) = -- x. encodeFloat m n is one of the two closest -- representable floating-point numbers to m*b^^n (or -- ±Infinity if overflow occurs); usually the closer, but if -- m contains too many bits, the result may be rounded in the -- wrong direction. encodeFloat :: RealFloat a => Integer -> Int -> a -- | exponent corresponds to the second component of -- decodeFloat. exponent 0 = 0 and for finite -- nonzero x, exponent x = snd (decodeFloat x) -- + floatDigits x. If x is a finite floating-point -- number, it is equal in value to significand x * b ^^ -- exponent x, where b is the floating-point radix. -- The behaviour is unspecified on infinite or NaN values. exponent :: RealFloat a => a -> Int -- | The first component of decodeFloat, scaled to lie in the open -- interval (-1,1), either 0.0 or of absolute -- value >= 1/b, where b is the floating-point -- radix. The behaviour is unspecified on infinite or NaN -- values. significand :: RealFloat a => a -> a -- | multiplies a floating-point number by an integer power of the radix scaleFloat :: RealFloat a => Int -> a -> a -- | True if the argument is an IEEE "not-a-number" (NaN) value isNaN :: RealFloat a => a -> Bool -- | True if the argument is an IEEE infinity or negative infinity isInfinite :: RealFloat a => a -> Bool -- | True if the argument is too small to be represented in -- normalized format isDenormalized :: RealFloat a => a -> Bool -- | True if the argument is an IEEE negative zero isNegativeZero :: RealFloat a => a -> Bool -- | True if the argument is an IEEE floating point number isIEEE :: RealFloat a => a -> Bool -- | a version of arctangent taking two real floating-point arguments. For -- real floating x and y, atan2 y x -- computes the angle (from the positive x-axis) of the vector from the -- origin to the point (x,y). atan2 y x returns -- a value in the range [-pi, pi]. It follows the -- Common Lisp semantics for the origin when signed zeroes are supported. -- atan2 y 1, with y in a type that is -- RealFloat, should return the same value as atan -- y. A default definition of atan2 is provided, but -- implementors can provide a more accurate implementation. atan2 :: RealFloat a => a -> a -> a -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | The function properFraction takes a real fractional number -- x and returns a pair (n,f) such that x = -- n+f, and: -- -- -- -- The default definitions of the ceiling, floor, -- truncate and round functions are in terms of -- properFraction. properFraction :: (RealFrac a, Integral b) => a -> (b, a) -- | truncate x returns the integer nearest x -- between zero and x truncate :: (RealFrac a, Integral b) => a -> b -- | round x returns the nearest integer to x; the -- even integer if x is equidistant between two integers round :: (RealFrac a, Integral b) => a -> b -- | ceiling x returns the least integer not less than -- x ceiling :: (RealFrac a, Integral b) => a -> b -- | floor x returns the greatest integer not greater than -- x floor :: (RealFrac a, Integral b) => a -> b -- | Conversion of values to readable Strings. -- -- Derived instances of Show have the following properties, which -- are compatible with derived instances of Read: -- -- -- -- For example, given the declarations -- --
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
-- -- the derived instance of Show is equivalent to -- --
--   instance (Show a) => Show (Tree a) where
--   
--          showsPrec d (Leaf m) = showParen (d > app_prec) $
--               showString "Leaf " . showsPrec (app_prec+1) m
--            where app_prec = 10
--   
--          showsPrec d (u :^: v) = showParen (d > up_prec) $
--               showsPrec (up_prec+1) u .
--               showString " :^: "      .
--               showsPrec (up_prec+1) v
--            where up_prec = 5
--   
-- -- Note that right-associativity of :^: is ignored. For example, -- -- class Show a -- | Convert a value to a readable String. -- -- showsPrec should satisfy the law -- --
--   showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
--   
-- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. showsPrec :: Show a => Int -> a -> ShowS -- | A specialised variant of showsPrec, using precedence context -- zero, and returning an ordinary String. show :: Show a => a -> String -- | The method showList is provided to allow the programmer to give -- a specialised way of showing lists of values. For example, this is -- used by the predefined Show instance of the Char type, -- where values of type String should be shown in double quotes, -- rather than between square brackets. showList :: Show a => [a] -> ShowS -- | Data structures that can be folded. -- -- For example, given a data type -- --
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   
-- -- a suitable instance would be -- --
--   instance Foldable Tree where
--      foldMap f Empty = mempty
--      foldMap f (Leaf x) = f x
--      foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
--   
-- -- This is suitable even for abstract types, as the monoid is assumed to -- satisfy the monoid laws. Alternatively, one could define -- foldr: -- --
--   instance Foldable Tree where
--      foldr f z Empty = z
--      foldr f z (Leaf x) = f x z
--      foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
--   
-- -- Foldable instances are expected to satisfy the following -- laws: -- --
--   foldr f z t = appEndo (foldMap (Endo . f) t ) z
--   
-- --
--   foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
--   
-- --
--   fold = foldMap id
--   
-- --
--   length = getSum . foldMap (Sum . const  1)
--   
-- -- sum, product, maximum, and minimum -- should all be essentially equivalent to foldMap forms, such -- as -- --
--   sum = getSum . foldMap Sum
--   
-- -- but may be less defined. -- -- If the type is also a Functor instance, it should satisfy -- --
--   foldMap f = fold . fmap f
--   
-- -- which implies that -- --
--   foldMap f . fmap g = foldMap (f . g)
--   
class Foldable (t :: Type -> Type) -- | Map each element of the structure to a monoid, and combine the -- results. foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | Right-associative fold of a structure. -- -- In the case of lists, foldr, when applied to a binary operator, -- a starting value (typically the right-identity of the operator), and a -- list, reduces the list using the binary operator, from right to left: -- --
--   foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
--   
-- -- Note that, since the head of the resulting expression is produced by -- an application of the operator to the first element of the list, -- foldr can produce a terminating expression from an infinite -- list. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
--   foldr f z = foldr f z . toList
--   
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b -- | Left-associative fold of a structure. -- -- In the case of lists, foldl, when applied to a binary operator, -- a starting value (typically the left-identity of the operator), and a -- list, reduces the list using the binary operator, from left to right: -- --
--   foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
--   
-- -- Note that to produce the outermost application of the operator the -- entire input list must be traversed. This means that foldl' -- will diverge if given an infinite list. -- -- Also note that if you want an efficient left-fold, you probably want -- to use foldl' instead of foldl. The reason for this is -- that latter does not force the "inner" results (e.g. z f -- x1 in the above example) before applying them to the operator -- (e.g. to (f x2)). This results in a thunk chain -- O(n) elements long, which then must be evaluated from the -- outside-in. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
--   foldl f z = foldl f z . toList
--   
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | A variant of foldr that has no base case, and thus may only be -- applied to non-empty structures. -- --
--   foldr1 f = foldr1 f . toList
--   
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a -- | A variant of foldl that has no base case, and thus may only be -- applied to non-empty structures. -- --
--   foldl1 f = foldl1 f . toList
--   
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a -- | Test whether the structure is empty. The default implementation is -- optimized for structures that are similar to cons-lists, because there -- is no general way to do better. null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation is optimized for structures that are similar to -- cons-lists, because there is no general way to do better. length :: Foldable t => t a -> Int -- | Does the element occur in the structure? elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The largest element of a non-empty structure. maximum :: (Foldable t, Ord a) => t a -> a -- | The least element of a non-empty structure. minimum :: (Foldable t, Ord a) => t a -> a -- | The sum function computes the sum of the numbers of a -- structure. sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | Functors representing data structures that can be traversed from left -- to right. -- -- A definition of traverse must satisfy the following laws: -- -- -- -- A definition of sequenceA must satisfy the following laws: -- -- -- -- where an applicative transformation is a function -- --
--   t :: (Applicative f, Applicative g) => f a -> g a
--   
-- -- preserving the Applicative operations, i.e. -- -- -- -- and the identity functor Identity and composition of functors -- Compose are defined as -- --
--   newtype Identity a = Identity a
--   
--   instance Functor Identity where
--     fmap f (Identity x) = Identity (f x)
--   
--   instance Applicative Identity where
--     pure x = Identity x
--     Identity f <*> Identity x = Identity (f x)
--   
--   newtype Compose f g a = Compose (f (g a))
--   
--   instance (Functor f, Functor g) => Functor (Compose f g) where
--     fmap f (Compose x) = Compose (fmap (fmap f) x)
--   
--   instance (Applicative f, Applicative g) => Applicative (Compose f g) where
--     pure x = Compose (pure (pure x))
--     Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)
--   
-- -- (The naturality law is implied by parametricity.) -- -- Instances are similar to Functor, e.g. given a data type -- --
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   
-- -- a suitable instance would be -- --
--   instance Traversable Tree where
--      traverse f Empty = pure Empty
--      traverse f (Leaf x) = Leaf <$> f x
--      traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r
--   
-- -- This is suitable even for abstract types, as the laws for -- <*> imply a form of associativity. -- -- The superclass instances should satisfy the following: -- -- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) -- | Evaluate each action in the structure from left to right, and collect -- the results. For a version that ignores the results see -- sequenceA_. sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) -- | Evaluate each monadic action in the structure from left to right, and -- collect the results. For a version that ignores the results see -- sequence_. sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) data Bool False :: Bool True :: Bool -- | The character type Char is an enumeration whose values -- represent Unicode (or equivalently ISO/IEC 10646) code points (i.e. -- characters, see http://www.unicode.org/ for details). This set -- extends the ISO 8859-1 (Latin-1) character set (the first 256 -- characters), which is itself an extension of the ASCII character set -- (the first 128 characters). A character literal in Haskell has type -- Char. -- -- To convert a Char to or from the corresponding Int value -- defined by Unicode, use toEnum and fromEnum from the -- Enum class respectively (or equivalently ord and -- chr). data Char -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double -- | Single-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- single-precision type. data Float -- | A fixed-precision integer type with at least the range [-2^29 .. -- 2^29-1]. The exact range for a given implementation can be -- determined by using minBound and maxBound from the -- Bounded class. data Int -- | Invariant: Jn# and Jp# are used iff value doesn't fit in -- S# -- -- Useful properties resulting from the invariants: -- -- data Integer -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). Using Maybe is a good way to deal with -- errors or exceptional cases without resorting to drastic measures such -- as error. -- -- The Maybe type is also a monad. It is a simple kind of error -- monad, where all errors are represented by Nothing. A richer -- error monad can be built using the Either type. data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Arbitrary-precision rational numbers, represented as a ratio of two -- Integer values. A rational number may be constructed using the -- % operator. type Rational = Ratio Integer -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= -- operations from the Monad class. data IO a -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). -- --

Examples

-- -- The type Either String Int is the type -- of values which can be either a String or an Int. The -- Left constructor can be used only on Strings, and the -- Right constructor can be used only on Ints: -- --
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> s
--   Left "foo"
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> n
--   Right 3
--   
--   >>> :type s
--   s :: Either String Int
--   
--   >>> :type n
--   n :: Either String Int
--   
-- -- The fmap from our Functor instance will ignore -- Left values, but will apply the supplied function to values -- contained in a Right: -- --
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> fmap (*2) s
--   Left "foo"
--   
--   >>> fmap (*2) n
--   Right 6
--   
-- -- The Monad instance for Either allows us to chain -- together multiple actions which may fail, and fail overall if any of -- the individual steps failed. First we'll write a function that can -- either parse an Int from a Char, or fail. -- --
--   >>> import Data.Char ( digitToInt, isDigit )
--   
--   >>> :{
--       let parseEither :: Char -> Either String Int
--           parseEither c
--             | isDigit c = Right (digitToInt c)
--             | otherwise = Left "parse error"
--   
--   >>> :}
--   
-- -- The following should work, since both '1' and '2' -- can be parsed as Ints. -- --
--   >>> :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x <- parseEither '1'
--             y <- parseEither '2'
--             return (x + y)
--   
--   >>> :}
--   
-- --
--   >>> parseMultiple
--   Right 3
--   
-- -- But the following should fail overall, since the first operation where -- we attempt to parse 'm' as an Int will fail: -- --
--   >>> :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x <- parseEither 'm'
--             y <- parseEither '2'
--             return (x + y)
--   
--   >>> :}
--   
-- --
--   >>> parseMultiple
--   Left "parse error"
--   
data Either a b Left :: a -> Either a b Right :: b -> Either a b -- | const x is a unary function which evaluates to x for -- all inputs. -- --
--   >>> const 42 "hello"
--   42
--   
-- --
--   >>> map (const 42) [0..3]
--   [42,42,42,42]
--   
const :: () => a -> b -> a -- | Function composition. (.) :: () => (b -> c) -> (a -> b) -> a -> c infixr 9 . -- | Identity function. -- --
--   id x = x
--   
id :: () => a -> a -- | A String is a list of characters. String constants in Haskell -- are values of type String. type String = [Char] -- | The read function reads input from a string, which must be -- completely consumed by the input process. read fails with an -- error if the parse is unsuccessful, and it is therefore -- discouraged from being used in real applications. Use readMaybe -- or readEither for safe alternatives. -- --
--   >>> read "123" :: Int
--   123
--   
-- --
--   >>> read "hello" :: Int
--   *** Exception: Prelude.read: no parse
--   
read :: Read a => String -> a -- | The readIO function is similar to read except that it -- signals parse failure to the IO monad instead of terminating -- the program. readIO :: Read a => String -> IO a -- | The readLn function combines getLine and readIO. readLn :: Read a => IO a -- | The computation appendFile file str function appends -- the string str, to the file file. -- -- Note that writeFile and appendFile write a literal -- string to a file. To write a value of any printable type, as with -- print, use the show function to convert the value to a -- string first. -- --
--   main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
--   
appendFile :: FilePath -> String -> IO () -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | The interact function takes a function of type -- String->String as its argument. The entire input from the -- standard input device is passed to this function as its argument, and -- the resulting string is output on the standard output device. interact :: (String -> String) -> IO () -- | The getContents operation returns all user input as a single -- string, which is read lazily as it is needed (same as -- hGetContents stdin). getContents :: IO String -- | Read a line from the standard input device (same as hGetLine -- stdin). getLine :: IO String -- | Read a character from the standard input device (same as -- hGetChar stdin). getChar :: IO Char -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | Write a string to the standard output device (same as hPutStr -- stdout). putStr :: String -> IO () -- | Write a character to the standard output device (same as -- hPutChar stdout). putChar :: Char -> IO () -- | Raise an IOException in the IO monad. ioError :: () => IOError -> IO a -- | File and directory names are values of type String, whose -- precise meaning is operating system dependent. Files can be opened, -- yielding a handle which can then be used to operate on the contents of -- that file. type FilePath = String -- | Construct an IOException value with a string describing the -- error. The fail method of the IO instance of the -- Monad class raises a userError, thus: -- --
--   instance Monad IO where
--     ...
--     fail s = ioError (userError s)
--   
userError :: String -> IOError -- | The Haskell 2010 type for exceptions in the IO monad. Any I/O -- operation may raise an IOException instead of returning a -- result. For a more general type of exception, including also those -- that arise in pure code, see Exception. -- -- In Haskell 2010, this is an opaque type. type IOError = IOException -- | notElem is the negation of elem. notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | Determines whether all elements of the structure satisfy the -- predicate. all :: Foldable t => (a -> Bool) -> t a -> Bool -- | Determines whether any element of the structure satisfies the -- predicate. any :: Foldable t => (a -> Bool) -> t a -> Bool -- | or returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. or :: Foldable t => t Bool -> Bool -- | and returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. and :: Foldable t => t Bool -> Bool -- | Map a function over all the elements of a container and concatenate -- the resulting lists. concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | The concatenation of all the elements of a container of lists. concat :: Foldable t => t [a] -> [a] -- | Evaluate each monadic action in the structure from left to right, and -- ignore the results. For a version that doesn't ignore the results see -- sequence. -- -- As of base 4.8.0.0, sequence_ is just sequenceA_, -- specialized to Monad. sequence_ :: (Foldable t, Monad m) => t (m a) -> m () -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- As of base 4.8.0.0, mapM_ is just traverse_, specialized -- to Monad. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | unwords is an inverse operation to words. It joins words -- with separating spaces. -- --
--   >>> unwords ["Lorem", "ipsum", "dolor"]
--   "Lorem ipsum dolor"
--   
unwords :: [String] -> String -- | words breaks a string up into a list of words, which were -- delimited by white space. -- --
--   >>> words "Lorem ipsum\ndolor"
--   ["Lorem","ipsum","dolor"]
--   
words :: String -> [String] -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. -- --
--   >>> unlines ["Hello", "World", "!"]
--   "Hello\nWorld\n!\n"
--   
unlines :: [String] -> String -- | lines breaks a string up into a list of strings at newline -- characters. The resulting strings do not contain newlines. -- -- Note that after splitting the string at newline characters, the last -- part of the string is considered a line even if it doesn't end with a -- newline. For example, -- --
--   >>> lines ""
--   []
--   
-- --
--   >>> lines "\n"
--   [""]
--   
-- --
--   >>> lines "one"
--   ["one"]
--   
-- --
--   >>> lines "one\n"
--   ["one"]
--   
-- --
--   >>> lines "one\n\n"
--   ["one",""]
--   
-- --
--   >>> lines "one\ntwo"
--   ["one","two"]
--   
-- --
--   >>> lines "one\ntwo\n"
--   ["one","two"]
--   
-- -- Thus lines s contains at least as many elements as -- newlines in s. lines :: String -> [String] -- | equivalent to readsPrec with a precedence of 0. reads :: Read a => ReadS a -- | Case analysis for the Either type. If the value is -- Left a, apply the first function to a; if it -- is Right b, apply the second function to b. -- --

Examples

-- -- We create two values of type Either String -- Int, one using the Left constructor and another -- using the Right constructor. Then we apply "either" the -- length function (if we have a String) or the -- "times-two" function (if we have an Int): -- --
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> either length (*2) s
--   3
--   
--   >>> either length (*2) n
--   6
--   
either :: () => (a -> c) -> (b -> c) -> Either a b -> c -- | The lex function reads a single lexeme from the input, -- discarding initial white space, and returning the characters that -- constitute the lexeme. If the input string contains only white space, -- lex returns a single successful `lexeme' consisting of the -- empty string. (Thus lex "" = [("","")].) If there is -- no legal lexeme at the beginning of the input string, lex fails -- (i.e. returns []). -- -- This lexer is not completely faithful to the Haskell lexical syntax in -- the following respects: -- -- lex :: ReadS String -- | readParen True p parses what p parses, -- but surrounded with parentheses. -- -- readParen False p parses what p -- parses, but optionally surrounded with parentheses. readParen :: () => Bool -> ReadS a -> ReadS a -- | A parser for a type a, represented as a function that takes a -- String and returns a list of possible parses as -- (a,String) pairs. -- -- Note that this kind of backtracking parser is very inefficient; -- reading a large structure may be quite slow (cf ReadP). type ReadS a = String -> [(a, String)] -- | lcm x y is the smallest positive integer that both -- x and y divide. lcm :: Integral a => a -> a -> a -- | gcd x y is the non-negative factor of both x -- and y of which every common factor of x and -- y is also a factor; for example gcd 4 2 = 2, -- gcd (-4) 6 = 2, gcd 0 4 = 4. -- gcd 0 0 = 0. (That is, the common divisor -- that is "greatest" in the divisibility preordering.) -- -- Note: Since for signed fixed-width integer types, abs -- minBound < 0, the result may be negative if one of the -- arguments is minBound (and necessarily is if the other -- is 0 or minBound) for such types. gcd :: Integral a => a -> a -> a -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 ^^ odd :: Integral a => a -> Bool even :: Integral a => a -> Bool -- | utility function that surrounds the inner show function with -- parentheses when the Bool parameter is True. showParen :: Bool -> ShowS -> ShowS -- | utility function converting a String to a show function that -- simply prepends the string unchanged. showString :: String -> ShowS -- | utility function converting a Char to a show function that -- simply prepends the character unchanged. showChar :: Char -> ShowS -- | equivalent to showsPrec with a precedence of 0. shows :: Show a => a -> ShowS -- | The shows functions return a function that prepends the -- output String to an existing String. This allows -- constant-time concatenation of results using function composition. type ShowS = String -> String -- | The unzip3 function takes a list of triples and returns three -- lists, analogous to unzip. unzip3 :: () => [(a, b, c)] -> ([a], [b], [c]) -- | unzip transforms a list of pairs into a list of first -- components and a list of second components. unzip :: () => [(a, b)] -> ([a], [b]) -- | The zipWith3 function takes a function which combines three -- elements, as well as three lists and returns a list of their -- point-wise combination, analogous to zipWith. zipWith3 :: () => (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] -- | zipWith generalises zip by zipping with the function -- given as the first argument, instead of a tupling function. For -- example, zipWith (+) is applied to two lists to -- produce the list of corresponding sums. -- -- zipWith is right-lazy: -- --
--   zipWith f [] _|_ = []
--   
zipWith :: () => (a -> b -> c) -> [a] -> [b] -> [c] -- | zip3 takes three lists and returns a list of triples, analogous -- to zip. zip3 :: () => [a] -> [b] -> [c] -> [(a, b, c)] -- | List index (subscript) operator, starting from 0. It is an instance of -- the more general genericIndex, which takes an index of any -- integral type. (!!) :: () => [a] -> Int -> a infixl 9 !! -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. reverse :: () => [a] -> [a] -- | break, applied to a predicate p and a list -- xs, returns a tuple where first element is longest prefix -- (possibly empty) of xs of elements that do not satisfy -- p and second element is the remainder of the list: -- --
--   break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
--   break (< 9) [1,2,3] == ([],[1,2,3])
--   break (> 9) [1,2,3] == ([1,2,3],[])
--   
-- -- break p is equivalent to span (not . -- p). break :: () => (a -> Bool) -> [a] -> ([a], [a]) -- | span, applied to a predicate p and a list xs, -- returns a tuple where first element is longest prefix (possibly empty) -- of xs of elements that satisfy p and second element -- is the remainder of the list: -- --
--   span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
--   span (< 9) [1,2,3] == ([1,2,3],[])
--   span (< 0) [1,2,3] == ([],[1,2,3])
--   
-- -- span p xs is equivalent to (takeWhile p xs, -- dropWhile p xs) span :: () => (a -> Bool) -> [a] -> ([a], [a]) -- | splitAt n xs returns a tuple where first element is -- xs prefix of length n and second element is the -- remainder of the list: -- --
--   splitAt 6 "Hello World!" == ("Hello ","World!")
--   splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
--   splitAt 1 [1,2,3] == ([1],[2,3])
--   splitAt 3 [1,2,3] == ([1,2,3],[])
--   splitAt 4 [1,2,3] == ([1,2,3],[])
--   splitAt 0 [1,2,3] == ([],[1,2,3])
--   splitAt (-1) [1,2,3] == ([],[1,2,3])
--   
-- -- It is equivalent to (take n xs, drop n xs) when -- n is not _|_ (splitAt _|_ xs = _|_). -- splitAt is an instance of the more general -- genericSplitAt, in which n may be of any integral -- type. splitAt :: () => Int -> [a] -> ([a], [a]) -- | drop n xs returns the suffix of xs after the -- first n elements, or [] if n > length -- xs: -- --
--   drop 6 "Hello World!" == "World!"
--   drop 3 [1,2,3,4,5] == [4,5]
--   drop 3 [1,2] == []
--   drop 3 [] == []
--   drop (-1) [1,2] == [1,2]
--   drop 0 [1,2] == [1,2]
--   
-- -- It is an instance of the more general genericDrop, in which -- n may be of any integral type. drop :: () => Int -> [a] -> [a] -- | take n, applied to a list xs, returns the -- prefix of xs of length n, or xs itself if -- n > length xs: -- --
--   take 5 "Hello World!" == "Hello"
--   take 3 [1,2,3,4,5] == [1,2,3]
--   take 3 [1,2] == [1,2]
--   take 3 [] == []
--   take (-1) [1,2] == []
--   take 0 [1,2] == []
--   
-- -- It is an instance of the more general genericTake, in which -- n may be of any integral type. take :: () => Int -> [a] -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs: -- --
--   dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
--   dropWhile (< 9) [1,2,3] == []
--   dropWhile (< 0) [1,2,3] == [1,2,3]
--   
dropWhile :: () => (a -> Bool) -> [a] -> [a] -- | takeWhile, applied to a predicate p and a list -- xs, returns the longest prefix (possibly empty) of -- xs of elements that satisfy p: -- --
--   takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]
--   takeWhile (< 9) [1,2,3] == [1,2,3]
--   takeWhile (< 0) [1,2,3] == []
--   
takeWhile :: () => (a -> Bool) -> [a] -> [a] -- | cycle ties a finite list into a circular one, or equivalently, -- the infinite repetition of the original list. It is the identity on -- infinite lists. cycle :: () => [a] -> [a] -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general genericReplicate, in which n may be of any -- integral type. replicate :: () => Int -> a -> [a] -- | repeat x is an infinite list, with x the -- value of every element. repeat :: () => a -> [a] -- | iterate f x returns an infinite list of repeated -- applications of f to x: -- --
--   iterate f x == [x, f x, f (f x), ...]
--   
-- -- Note that iterate is lazy, potentially leading to thunk -- build-up if the consumer doesn't force each iterate. See 'iterate\'' -- for a strict variant of this function. iterate :: () => (a -> a) -> a -> [a] -- | scanr1 is a variant of scanr that has no starting value -- argument. scanr1 :: () => (a -> a -> a) -> [a] -> [a] -- | scanr is the right-to-left dual of scanl. Note that -- --
--   head (scanr f z xs) == foldr f z xs.
--   
scanr :: () => (a -> b -> b) -> b -> [a] -> [b] -- | scanl1 is a variant of scanl that has no starting value -- argument: -- --
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   
scanl1 :: () => (a -> a -> a) -> [a] -> [a] -- | scanl is similar to foldl, but returns a list of -- successive reduced values from the left: -- --
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   
-- -- Note that -- --
--   last (scanl f z xs) == foldl f z xs.
--   
scanl :: () => (b -> a -> b) -> b -> [a] -> [b] -- | Return all the elements of a list except the last one. The list must -- be non-empty. init :: () => [a] -> [a] -- | Extract the last element of a list, which must be finite and -- non-empty. last :: () => [a] -> a -- | Extract the elements after the head of a list, which must be -- non-empty. tail :: () => [a] -> [a] -- | Extract the first element of a list, which must be non-empty. head :: () => [a] -> a -- | The maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. -- --

Examples

-- -- Basic usage: -- --
--   >>> maybe False odd (Just 3)
--   True
--   
-- --
--   >>> maybe False odd Nothing
--   False
--   
-- -- Read an integer from a string using readMaybe. If we succeed, -- return twice the integer; that is, apply (*2) to it. If -- instead we fail to parse an integer, return 0 by default: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> maybe 0 (*2) (readMaybe "5")
--   10
--   
--   >>> maybe 0 (*2) (readMaybe "")
--   0
--   
-- -- Apply show to a Maybe Int. If we have Just -- n, we want to show the underlying Int n. But if -- we have Nothing, we return the empty string instead of (for -- example) "Nothing": -- --
--   >>> maybe "" show (Just 5)
--   "5"
--   
--   >>> maybe "" show Nothing
--   ""
--   
maybe :: () => b -> (a -> b) -> Maybe a -> b -- | uncurry converts a curried function to a function on pairs. -- --

Examples

-- --
--   >>> uncurry (+) (1,2)
--   3
--   
-- --
--   >>> uncurry ($) (show, 1)
--   "1"
--   
-- --
--   >>> map (uncurry max) [(1,2), (3,4), (6,8)]
--   [2,4,8]
--   
uncurry :: () => (a -> b -> c) -> (a, b) -> c -- | curry converts an uncurried function to a curried function. -- --

Examples

-- --
--   >>> curry fst 1 2
--   1
--   
curry :: () => ((a, b) -> c) -> a -> b -> c -- | the same as flip (-). -- -- Because - is treated specially in the Haskell grammar, -- (- e) is not a section, but an application of -- prefix negation. However, (subtract -- exp) is equivalent to the disallowed section. subtract :: Num a => a -> a -> a -- | asTypeOf is a type-restricted version of const. It is -- usually used as an infix operator, and its typing forces its first -- argument (which is usually overloaded) to have the same type as the -- second. asTypeOf :: () => a -> a -> a -- | until p f yields the result of applying f -- until p holds. until :: () => (a -> Bool) -> (a -> a) -> a -> a -- | Strict (call-by-value) application operator. It takes a function and -- an argument, evaluates the argument to weak head normal form (WHNF), -- then calls the function with that value. ($!) :: () => (a -> b) -> a -> b infixr 0 $! -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
--   >>> flip (++) "hello" "world"
--   "worldhello"
--   
flip :: () => (a -> b -> c) -> b -> a -> c -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | A special case of error. It is expected that compilers will -- recognize this and insert error messages which are more appropriate to -- the context in which undefined appears. undefined :: HasCallStack => a -- | A variant of error that does not produce a stack trace. errorWithoutStackTrace :: () => [Char] -> a -- | error stops execution and displays an error message. error :: HasCallStack => [Char] -> a -- | Boolean "and" (&&) :: Bool -> Bool -> Bool infixr 3 && -- | Boolean "or" (||) :: Bool -> Bool -> Bool infixr 2 || -- | Boolean "not" not :: Bool -> Bool -- | A functor with application, providing operations to -- -- -- -- A minimal complete definition must include implementations of -- pure and of either <*> or liftA2. If it -- defines both, then they must behave the same as their default -- definitions: -- --
--   (<*>) = liftA2 id
--   
-- --
--   liftA2 f x y = f <$> x <*> y
--   
-- -- Further, any definition must satisfy the following: -- -- -- -- The other methods have the following default definitions, which may be -- overridden with equivalent specialized implementations: -- -- -- -- As a consequence of these laws, the Functor instance for -- f will satisfy -- -- -- -- It may be useful to note that supposing -- --
--   forall x y. p (q x y) = f x . g y
--   
-- -- it follows from the above that -- --
--   liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v
--   
-- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. (<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. (*>) :: Applicative f => f a -> f b -> f b -- | Sequence actions, discarding the value of the second argument. (<*) :: Applicative f => f a -> f b -> f a infixl 4 <*> infixl 4 *> infixl 4 <* -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
-- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --

Examples

-- -- Convert from a Maybe Int to a -- Maybe String using show: -- --
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
-- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
-- -- Double each element of a list: -- --
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
-- -- Apply even to the second element of a pair: -- --
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following laws: -- -- -- -- The method names refer to the monoid of lists under concatenation, but -- there are many other instances. -- -- Some types can be viewed as a monoid in more than one way, e.g. both -- addition and multiplication on numbers. In such cases we often define -- newtypes and make those instances of Monoid, e.g. -- Sum and Product. -- -- NOTE: Semigroup is a superclass of Monoid since -- base-4.11.0.0. class Semigroup a => Monoid a -- | Identity of mappend mempty :: Monoid a => a -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = '(<>)' since -- base-4.11.0.0. mappend :: Monoid a => a -> a -> a -- | Fold a list using the monoid. -- -- For most types, the default definition for mconcat will be -- used, but the function is included in the class definition so that an -- optimized version can be provided for specific types. mconcat :: Monoid a => [a] -> a -- | The class of semigroups (types with an associative binary operation). -- -- Instances should satisfy the associativity law: -- -- class Semigroup a -- | An associative operation. (<>) :: Semigroup a => a -> a -> a -- | Reduce a non-empty list with <> -- -- The default definition should be sufficient, but this can be -- overridden for efficiency. sconcat :: Semigroup a => NonEmpty a -> a -- | Repeat a value n times. -- -- Given that this works on a Semigroup it is allowed to fail if -- you request 0 or fewer repetitions, and the default definition will do -- so. -- -- By making this a member of the class, idempotent semigroups and -- monoids can upgrade this to execute in O(1) by picking -- stimes = stimesIdempotent or stimes = -- stimesIdempotentMonoid respectively. stimes :: (Semigroup a, Integral b) => b -> a -> a infixr 6 <> -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) module Darcs.Patch.Witnesses.Eq -- | EqCheck 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 unsafeCompare, =\/= and =/\=. class Eq2 p -- | It is unsafe to define a class instance via this method, because if it -- returns True then the default implementations of =\/= and -- =/\= will coerce the equality of two witnesses. -- -- Calling this method is safe, although =\/= or =/\= 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 -- | regChars 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 -- - (dash), and it can also be specified as a complement set by -- prefixing with ^ (caret). The dash and caret, as well as the -- backslash, can all be escaped with a backslash to suppress their -- special meaning. -- -- NOTE: The . (dot) is allowed to be escaped. It has no special -- meaning if it is not escaped, but the default filename_toks -- in Darcs.Commands.Replace uses an escaped dot (WHY?). regChars :: String -> Char -> Bool module Darcs.Patch.TokenReplace -- | tryTokReplace tokChars old new input tries to find the token -- old and replace it with the token new everywhere in -- the input, returning Just the modified input, -- unless the token new is already in the input in -- which case Nothing is returned. A token is a sequence of bytes -- that match the class defined by tokChars. This function is -- supposed to work efficiently with large inputs i.e. whole -- files. tryTokReplace :: String -> ByteString -> ByteString -> ByteString -> Maybe ByteString -- | forceTokReplace tokChars old new input replaces all -- occurrences of the old token with the new one, -- throughout the input. forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString -- | Check if a token replace operation touches the given line. annotateReplace :: String -> ByteString -> ByteString -> ByteString -> Bool -- | Break a Bytestring into tokens, according to -- defaultToks, 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 ListFormat). -- 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 p are shown -- for a given Patch type p. It is needed to maintain -- backwards compatibility for V1 and V2 patches. data ListFormat (p :: (* -> * -> *)) -- | Show and read lists without braces. ListFormatDefault :: ListFormat -- | 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 -- | Show lists without braces. Read with arbitrary nested parens and -- flatten them out. ListFormatV2 :: ListFormat -- | Temporary hack to disable use of showContextSeries for darcs-3 -- patches, until I find out how to fix this. ListFormatV3 :: ListFormat 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 -- --
--   Iso fw bw :: Iso a b
--   
-- -- then fw and bw are supposed to satisfy -- --
--   fw . bw = id = bw . fw
--   
data Iso a b Iso :: (a -> b) -> (b -> a) -> Iso a b -- | Lift an isomorphism between a and b to one between -- f a and f b. Like Functor, 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 -- --
--   www.is.ocha.ac.jp/~asai/papers/tr08-2.pdf
--   
-- -- with additional inspiration provided by -- --
--   http://okmij.org/ftp/typed-formatting/FPrintScan.html#DSL-FIn
--   
-- -- which shows how the same format specifiers can be used for both -- sprintf and sscanf. -- -- The OptSpec type corresponds to the format specifiers for the -- sprintf and sscanf functions, which I called ounparse and -- oparse here; they no longer work on Strings 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 -- Cont, even with the recent additions of the shift and -- reset combinators, since Cont 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 OptSpec type contains two -- more members: odesc is the list of OptDescr that -- getOpt needs as input for parsing the command line and for -- generating the usage help, while ocheck 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 -- | 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 Maybe with default Nothing -- 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 OptSpec type is heavily parameterized. The type arguments -- are: -- -- -- -- Abstracting over these types is not technically necessary: for the -- intended application in Darcs, we could as well fix them as -- d=DarcsOptDescr, and f=DarcsFlag, -- 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 -- -- -- -- The ounparse and oparse 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 PrimOptSpec below). -- For a primitive option, b gets instantiated to v -> -- a, where v is the type of values associated with the -- option. The whole option spec then has type -- --
--   o :: 'OptSpec' d f a (v -> a)
--   
-- -- so that the oparse and ounparse members are instantiated -- to -- --
--   ounparse :: forall a. ([f] -> a) -> (x -> a)
--   oparse   :: forall a. (x -> a) -> ([f] -> a)
--   
-- -- which can be easily seen to be equivalent to -- --
--   ounparse :: x -> [f]
--   oparse   :: [f] -> x
--   
-- -- Chaining such options results in a combined option of type -- --
--   o1 ^ o2 ^ ... :: OptSpec d f a (v1 -> v2 -> ... -> a)
--   
-- -- that is, b gets instantiated to -- --
--   v1 -> v2 -> ... -> a
--   
-- -- To use such an option (primitive or combined), you pass in the -- consumer. A typical consumer of option values is a command -- implementation. Given -- --
--   cmd :: v1 -> v2 -> ... -> [String] -> IO ()
--   
-- -- we can parse the flags and pass the results to cmd: -- --
--   oparse (o1 ^ o2 ^ ...) cmd flags
--   
data OptSpec d f a b OptSpec :: (([f] -> a) -> b) -> (b -> [f] -> a) -> ([f] -> [String]) -> [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] -> [String] -- | Descriptions, one for each flag that makes up the option. [odesc] :: OptSpec d f a b -> [d f] -- | Identity OptSpec, unit for ^ oid :: OptSpec d f a a -- | OptSpec 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. -- --
--   onormalise opts = (oparse opts . ounparse opts) id
--   
onormalise :: OptSpec d f [f] b -> [f] -> [f] -- | The list of default flags for an OptSpec. -- --
--   defaultFlags opts = onormalise opts []
--   
defaultFlags :: OptSpec d f [f] b -> [f] -- | Lift an isomorphism between b and c to one between -- OptSpec d f a b and OptSpec d f a c. -- -- The forward component of the Iso is needed for ounparse, -- the backward component for oparse. 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 -- b gets instantiated to (v -> a), adding one -- argument of type v 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 (oparse), -- flags (ounparse), errors (ocheck), and descriptors -- (odesc), respectively, of the input options. oappend :: PrimOptSpec d f a [v] -> PrimOptSpec d f a [v] -> PrimOptSpec d f a [v] -- | Unit for oappend. 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. -- --
--   parseFlags o fs = oparse o id fs
--   
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 parseFlags -- --
--   opt ? flags = parseFlags opt flags
--   
(?) :: (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 "%<" 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 -- [(s,"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 -- | Get the current UTCTime from the system clock. getCurrentTime :: IO UTCTime toSeconds :: UTCTime -> Integer formatDateTime :: String -> UTCTime -> String fromClockTime :: ClockTime -> UTCTime parseDateTime :: String -> String -> Maybe UTCTime startOfTime :: UTCTime module Darcs.Util.Download.Request -- | A UrlRequest object contains a url to get, the file into which the -- contents at the given url should be written, the cachability of this -- request and the request's priority. data UrlRequest UrlRequest :: String -> FilePath -> Cachable -> Priority -> UrlRequest [url] :: UrlRequest -> String [file] :: UrlRequest -> FilePath [cachable] :: UrlRequest -> Cachable [priority] :: UrlRequest -> Priority data Cachable Cachable :: Cachable Uncachable :: Cachable MaxAge :: !CInt -> Cachable -- | A UrlState object contains a map of url -> InProgressStatus, a Q of -- urls waiting to be started, the current pipe length and the unique -- junk to create unique filenames. data UrlState UrlState :: Map String InProgressStatus -> Q String -> Int -> String -> UrlState [inProgress] :: UrlState -> Map String InProgressStatus [waitToStart] :: UrlState -> Q String [pipeLength] :: UrlState -> Int [randomJunk] :: UrlState -> String -- | Q represents a prioritised queue, with two-tier priority. The left -- list contains higher priority items than the right list. data Q a Q :: [a] -> [a] -> Q a -- | readQ will try and take an element from the Q, preferring -- elements from the high priority list. readQ :: Q a -> Maybe (a, Q a) -- | insertQ inserts a low priority item into a Q. insertQ :: a -> Q a -> Q a -- | pushQ inserts a high priority item into a Q. pushQ :: a -> Q a -> Q a -- | Return a function for adding an element based on the priority. addUsingPriority :: Priority -> a -> Q a -> Q a -- | deleteQ removes any instances of a given element from the Q. deleteQ :: Eq a => a -> Q a -> Q a -- | deleteQ checks for membership in a Q. elemQ :: Eq a => a -> Q a -> Bool -- | emptyQ is an empty Q. emptyQ :: Q a -- | nullQ checks if the Q contains no items. nullQ :: Q a -> Bool data Priority High :: Priority Low :: Priority -- | Data type to represent a connection error. The following are the codes -- from libcurl which map to each of the constructors: * 6 -> -- CouldNotResolveHost : The remote host was not resolved. * 7 -> -- CouldNotConnectToServer : Failed to connect() to host or proxy. * 28 -- -> OperationTimeout: the specified time-out period was reached. data ConnectionError CouldNotResolveHost :: ConnectionError CouldNotConnectToServer :: ConnectionError OperationTimeout :: ConnectionError instance GHC.Show.Show Darcs.Util.Download.Request.ConnectionError instance GHC.Read.Read Darcs.Util.Download.Request.ConnectionError instance GHC.Classes.Eq Darcs.Util.Download.Request.ConnectionError instance GHC.Classes.Eq Darcs.Util.Download.Request.Cachable instance GHC.Show.Show Darcs.Util.Download.Request.Cachable instance GHC.Classes.Eq Darcs.Util.Download.Request.Priority module Darcs.Util.Download setDebugHTTP :: IO () disableHTTPPipelining :: IO () maxPipelineLength :: IO Int data Cachable Cachable :: Cachable Uncachable :: Cachable MaxAge :: !CInt -> Cachable environmentHelpProxy :: ([String], [String]) environmentHelpProxyPassword :: ([String], [String]) -- | Data type to represent a connection error. The following are the codes -- from libcurl which map to each of the constructors: * 6 -> -- CouldNotResolveHost : The remote host was not resolved. * 7 -> -- CouldNotConnectToServer : Failed to connect() to host or proxy. * 28 -- -> OperationTimeout: the specified time-out period was reached. data ConnectionError module Darcs.Util.Encoding -- | Encode a String into a ByteString according to the -- user's locale with the ghc specific //ROUNDTRIP feature added. This -- means the argument is allowed to contain non-Unicode Chars as -- produced by decode. encode :: String -> IO ByteString -- | Decode a ByteString into a String according to the -- user's locale with the ghc specific //ROUNDTRIP feature added. This -- means the result may contain Chars 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 timingsMode :: Bool setTimingsMode :: IO () whenDebugMode :: IO () -> IO () withDebugMode :: (Bool -> IO a) -> IO a setDebugMode :: IO () debugMessage :: String -> IO () putTiming :: 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 ByteString. gzReadFilePS :: FilePath -> IO ByteString -- | Like readFilePS, this reads an entire file directly into a -- ByteString, 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 ByteString. 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 linesPS :: ByteString -> [ByteString] 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 -> ByteString fromPS2Hex :: ByteString -> ByteString -- | Return the B.ByteString between the two lines given, or Nothing if -- they do not appear. betweenLinesPS :: ByteString -> ByteString -> ByteString -> Maybe ByteString -- | O(n) The intercalate function takes a ByteString -- and a list of ByteStrings and concatenates the list after -- interspersing the first argument between each element of the list. intercalate :: ByteString -> [ByteString] -> ByteString -- | Test if a ByteString is made of ascii characters isAscii :: ByteString -> Bool -- | Decode a ByteString to a String according to the -- current locale, using lone surrogates for un-decodable bytes. decodeLocale :: ByteString -> String -- | Encode a String to a ByteString 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 setEnvCautiously. encodeLocale :: String -> ByteString -- | Decode a ByteString containing UTF-8 to a String. -- Decoding errors are flagged with the U+FFFD character. unpackPSFromUTF8 :: ByteString -> String -- | Encode a String to a ByteString 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 betweenLinesPS. 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.Paths makeDarcsdirPath :: String -> String -- | Location of the lock file. lockPath :: String -- | Location of the (one and only) head inventory. hashedInventory :: [Char] hashedInventoryPath :: String -- | Location of the (one and only) tentative head inventory. tentativeHashedInventory :: [Char] tentativeHashedInventoryPath :: String -- | Location of parent inventories. inventoriesDir :: [Char] inventoriesDirPath :: String -- | Location of pristine trees. tentativePristinePath :: String pristineDir :: [Char] pristineDirPath :: String -- | Location of patches. patchesDir :: [Char] 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 -- | Location of old style (unhashed) files and directories. oldPristineDirPath :: String oldCurrentDirPath :: String oldCheckpointDirPath :: String oldInventoryPath :: String oldTentativeInventoryPath :: String module Darcs.Repository.Flags data Compression NoCompression :: Compression GzipCompression :: Compression 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 YesLookForAdds :: LookForAdds NoLookForAdds :: LookForAdds data LookForReplaces YesLookForReplaces :: LookForReplaces NoLookForReplaces :: LookForReplaces data DiffAlgorithm PatienceDiff :: DiffAlgorithm MyersDiff :: DiffAlgorithm data LookForMoves YesLookForMoves :: LookForMoves NoLookForMoves :: LookForMoves data RunTest YesRunTest :: RunTest NoRunTest :: RunTest data SetScriptsExecutable YesSetScriptsExecutable :: SetScriptsExecutable NoSetScriptsExecutable :: SetScriptsExecutable data LeaveTestDir YesLeaveTestDir :: LeaveTestDir NoLeaveTestDir :: LeaveTestDir data RemoteRepos RemoteRepos :: [String] -> RemoteRepos data SetDefault YesSetDefault :: Bool -> SetDefault NoSetDefault :: Bool -> SetDefault data InheritDefault YesInheritDefault :: InheritDefault NoInheritDefault :: InheritDefault data UseIndex UseIndex :: UseIndex IgnoreIndex :: UseIndex data ScanKnown -- | Just files already known to darcs ScanKnown :: ScanKnown -- | All files, i.e. look for new ones ScanAll :: ScanKnown -- | All files, even boring ones ScanBoring :: ScanKnown 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 :: AllowConflicts YesAllowConflictsAndMark :: AllowConflicts data ExternalMerge YesExternalMerge :: String -> ExternalMerge NoExternalMerge :: ExternalMerge 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 IncludeBoring YesIncludeBoring :: IncludeBoring NoIncludeBoring :: IncludeBoring 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 instance GHC.Show.Show Darcs.Repository.Flags.PatchFormat instance GHC.Classes.Eq Darcs.Repository.Flags.PatchFormat instance GHC.Show.Show Darcs.Repository.Flags.ForgetParent instance GHC.Classes.Eq Darcs.Repository.Flags.ForgetParent instance GHC.Show.Show Darcs.Repository.Flags.WithWorkingDir instance GHC.Classes.Eq Darcs.Repository.Flags.WithWorkingDir instance GHC.Show.Show Darcs.Repository.Flags.WantGuiPause instance GHC.Classes.Eq Darcs.Repository.Flags.WantGuiPause instance GHC.Show.Show Darcs.Repository.Flags.WorkRepo instance GHC.Classes.Eq Darcs.Repository.Flags.WorkRepo instance GHC.Show.Show Darcs.Repository.Flags.ExternalMerge instance GHC.Classes.Eq Darcs.Repository.Flags.ExternalMerge instance GHC.Show.Show Darcs.Repository.Flags.AllowConflicts instance GHC.Classes.Eq Darcs.Repository.Flags.AllowConflicts instance GHC.Show.Show Darcs.Repository.Flags.CloneKind instance GHC.Classes.Eq Darcs.Repository.Flags.CloneKind instance GHC.Show.Show Darcs.Repository.Flags.ScanKnown instance GHC.Classes.Eq Darcs.Repository.Flags.ScanKnown instance GHC.Show.Show Darcs.Repository.Flags.UseIndex instance GHC.Classes.Eq Darcs.Repository.Flags.UseIndex instance GHC.Show.Show Darcs.Repository.Flags.InheritDefault instance GHC.Classes.Eq Darcs.Repository.Flags.InheritDefault instance GHC.Show.Show Darcs.Repository.Flags.SetDefault instance GHC.Classes.Eq Darcs.Repository.Flags.SetDefault instance GHC.Show.Show Darcs.Repository.Flags.RemoteRepos instance GHC.Classes.Eq Darcs.Repository.Flags.RemoteRepos instance GHC.Show.Show Darcs.Repository.Flags.LeaveTestDir instance GHC.Classes.Eq Darcs.Repository.Flags.LeaveTestDir instance GHC.Show.Show Darcs.Repository.Flags.SetScriptsExecutable instance GHC.Classes.Eq Darcs.Repository.Flags.SetScriptsExecutable instance GHC.Show.Show Darcs.Repository.Flags.RunTest instance GHC.Classes.Eq Darcs.Repository.Flags.RunTest instance GHC.Show.Show Darcs.Repository.Flags.IncludeBoring instance GHC.Classes.Eq Darcs.Repository.Flags.IncludeBoring instance GHC.Show.Show Darcs.Repository.Flags.LookForMoves instance GHC.Classes.Eq Darcs.Repository.Flags.LookForMoves instance GHC.Show.Show Darcs.Repository.Flags.LookForReplaces instance GHC.Classes.Eq Darcs.Repository.Flags.LookForReplaces instance GHC.Show.Show Darcs.Repository.Flags.LookForAdds instance GHC.Classes.Eq Darcs.Repository.Flags.LookForAdds instance GHC.Show.Show Darcs.Repository.Flags.UMask instance GHC.Classes.Eq Darcs.Repository.Flags.UMask instance GHC.Show.Show Darcs.Repository.Flags.DryRun instance GHC.Classes.Eq Darcs.Repository.Flags.DryRun instance GHC.Show.Show Darcs.Repository.Flags.UseCache instance GHC.Classes.Eq Darcs.Repository.Flags.UseCache instance GHC.Show.Show Darcs.Repository.Flags.UpdatePending instance GHC.Classes.Eq Darcs.Repository.Flags.UpdatePending instance GHC.Classes.Eq Darcs.Repository.Flags.Reorder instance GHC.Show.Show Darcs.Repository.Flags.RemoteDarcs instance GHC.Classes.Eq Darcs.Repository.Flags.RemoteDarcs instance GHC.Show.Show Darcs.Repository.Flags.WithPatchIndex instance GHC.Classes.Eq Darcs.Repository.Flags.WithPatchIndex instance GHC.Show.Show Darcs.Repository.Flags.Compression instance GHC.Classes.Eq Darcs.Repository.Flags.Compression instance GHC.Show.Show Darcs.Repository.Flags.Verbosity instance GHC.Classes.Eq Darcs.Repository.Flags.Verbosity module Darcs.Util.Graph -- | Undirected graph represented as a Vector of adjacency -- VertexSets. type Graph = Vector VertexSet -- | Vertices are represented as Int. 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 Component of a -- Graph. ltmis :: (Bool, Bool) -> Component -> [VertexSet] -- | The classic Bron-Kerbosch algorithm for determining the maximal -- independent sets in a Graph. bkmis :: Graph -> [VertexSet] -- | Split a Graph into connected components. For efficiency we -- don't represent the result as a list of Graphs, but rather of -- VertexSets. components :: Graph -> [Component] -- | Enumerate all (simple) graphs of a given size (number of vertices). genGraphs :: Int -> [Graph] genComponents :: Int -> [Component] -- | Whether ltmis is equivalent to bkmis. prop_ltmis_eq_bkmis :: Graph -> Bool -- | Whether ltmis generates only maximal independent sets. prop_ltmis_maximal_independent_sets :: Component -> Bool -- | Whether ltmis generates all maximal independent sets. prop_ltmis_all_maximal_independent_sets :: Component -> Bool -- | Complete specification of the components function. prop_components :: Graph -> Bool instance GHC.Show.Show Darcs.Util.Graph.Component module Darcs.Util.HTTP copyRemote :: String -> FilePath -> Cachable -> IO () copyRemoteLazy :: String -> Cachable -> IO ByteString speculateRemote :: String -> FilePath -> IO () postUrl :: String -> ByteString -> String -> IO () module Darcs.Util.Hash data Hash SHA256 :: !ByteString -> Hash NoHash :: 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 Hash. If the -- string is malformed, yields NoHash. decodeBase16 :: ByteString -> Hash -- | Compute a sha256 of a (lazy) ByteString. sha256 :: ByteString -> Hash -- | Same as previous but general purpose. sha256sum :: ByteString -> String rawHash :: Hash -> ByteString match :: Hash -> Hash -> Bool 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 SHA1 directly from its B16 encoding, given as a -- ByteString, or return Nothing. The implementation is -- quite low-level and optimized because the current implementation of -- RepoPatchV3 has to read lots of SHA1 hashes, and profiling -- showed that this is a bottleneck. sha1Read :: ByteString -> Maybe SHA1 instance GHC.Classes.Ord Darcs.Util.Hash.SHA1 instance GHC.Classes.Eq Darcs.Util.Hash.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.Show.Show Darcs.Util.Hash.SHA1 instance Data.Binary.Class.Binary Darcs.Util.Hash.SHA1 module Darcs.Util.IsoDate -- | The current time in the format returned by showIsoDateTime getIsoDateTime :: IO String -- | Read/interpret a date string, assuming UTC if timezone is not -- specified in the string (see readDate) Warning! This errors out -- if we fail to interpret the date readUTCDate :: String -> CalendarTime -- | Similar to readUTCDate, except we ignore 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 -- showIsoDateTime and dateTime 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, -- -- -- -- See englishDate and englishTime 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, -- -- 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., -- -- -- -- See iso8601Duration iso8601Interval :: Int -> CharParser a (Either TimeDiff (MCalendarTime, MCalendarTime)) -- | Durations in ISO 8601, e.g., -- -- 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 Thursday, but -- this does not match what the numerical date would lead one to expect) resetCalendar :: CalendarTime -> CalendarTime -- | An MCalenderTime is an underspecified CalendarTime 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 Nothing. This uses almost the same fields as -- CalendarTime, a notable exception being that we introduce -- mctWeek 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 CalendarTime to a fully specified -- MCalendarTime (note that this sets the mctWeek flag to -- False toMCalendarTime :: CalendarTime -> MCalendarTime -- | Returns the first CalendarTime that falls within a -- MCalendarTime This is only unsafe in the sense that it plugs in -- default values for fields that have not been set, e.g. -- January for the month or 0 for the seconds field. -- Maybe we should rename it something happier. See also -- resetCalendar unsafeToCalendarTime :: MCalendarTime -> CalendarTime -- | Zero the time fields of a CalendarTime unsetTime :: CalendarTime -> CalendarTime type TimeInterval = (Maybe CalendarTime, Maybe CalendarTime) -- | Display a CalendarTime 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 -- | parseDateMatcher s return the first matcher in -- getMatchers that can parse s parseDateMatcher :: String -> IO (CalendarTime -> Bool) -- | A DateMatcher 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 -- | getMatchers d returns the list of matchers that will -- be applied on d. 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] -- | testDate d shows the possible interpretations for the -- date string d and how they match against the current date testDate :: String -> IO () -- | testDate iso d shows the possible interpretations for -- the date string d and how they match against the date -- represented by the ISO 8601 string iso testDateAt :: String -> String -> IO () module Darcs.Util.Parser type Parser = Parser ByteString -- | Match any character. anyChar :: Parser Char char :: Char -> Parser () checkConsumes :: Parser a -> Parser a -- | choice ps tries to apply the actions in the list ps -- in order, until one of them succeeds. Returns the value of the -- succeeding action. choice :: Alternative f => [f a] -> f a -- | Match only if all input has been consumed. 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 -- | option x p tries to apply action p. If p -- fails without consuming input, it returns the value x, -- otherwise the value returned by p. -- --
--   priority  = option 0 (digitToInt <$> digit)
--   
option :: Alternative f => a -> f a -> f a -- | One or none. optional :: Alternative f => f a -> f (Maybe a) parse :: Parser a -> ByteString -> Either String (a, ByteString) -- | Skip over white space. skipSpace :: Parser () -- | Skip past input for as long as the predicate returns True. skipWhile :: (Char -> Bool) -> Parser () string :: ByteString -> Parser () -- | Consume exactly n bytes of input. take :: Int -> Parser ByteString -- | Consume input as long as the predicate returns False (i.e. -- until it returns True), and return the consumed input. -- -- This parser does not fail. It will return an empty string if the -- predicate returns True on the first byte of input. -- -- Note: Because this parser does not fail, do not use it with -- combinators such as many, because such parsers loop until a -- failure occurs. Careless use will thus result in an infinite loop. takeTill :: (Char -> Bool) -> Parser ByteString takeTillChar :: Char -> Parser ByteString -- | Darcs pretty printing library -- -- The combinator names are taken from HughesPJ, 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 Doc is a bit of enriched text. Docs are concatenated -- using <> from class Monoid, which is -- right-associative. newtype Doc Doc :: (St -> Document) -> Doc [unDoc] :: Doc -> St -> Document -- | The empty Doc empty :: Doc -- | An associative operation. (<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | a <?> b is a <> b if -- a is not empty, else empty () :: Doc -> Doc -> Doc -- | a <+> b is a followed by b -- with a space in between if both are non-empty (<+>) :: Doc -> Doc -> Doc infixr 6 <+> -- | a $$ b is a above b ($$) :: Doc -> Doc -> Doc infixr 5 $$ -- | a $+$ b is a above b with an empty -- line in between if both are non-empty ($+$) :: Doc -> Doc -> Doc infixr 5 $+$ -- | Pile Docs vertically vcat :: [Doc] -> Doc -- | Pile Docs vertically, with a blank line in between vsep :: [Doc] -> Doc -- | Concatenate Docs horizontally hcat :: [Doc] -> Doc -- | Concatenate Docs horizontally with a space as separator hsep :: [Doc] -> Doc -- | A Doc representing a "-" minus :: Doc -- | A Doc representing a newline newline :: Doc -- | A Doc representing a "+" plus :: Doc -- | A Doc representing a space (" ") space :: Doc -- | A Doc representing a "\" backslash :: Doc -- | A Doc that represents "(" lparen :: Doc -- | A Doc that represents ")" rparen :: Doc -- |
--   parens d = lparen <> d <> rparen
--   
parens :: Doc -> Doc -- | Turn a Doc into a sentence. This appends a ".". sentence :: Doc -> Doc -- | text creates a Doc from a String, using -- printable. text :: String -> Doc -- | hiddenText creates a Doc containing hidden text from a -- String hiddenText :: String -> Doc -- | invisibleText creates a Doc containing invisible text -- from a String invisibleText :: String -> Doc -- | wrapText n s is a Doc representing s -- line-wrapped at n characters wrapText :: Int -> String -> Doc -- | Quote a string for screen output quoted :: String -> Doc -- | Given a list of Strings representing the words of a paragraph, -- format the paragraphs using wrapText and separate them with an -- empty line. formatText :: Int -> [String] -> Doc -- | A variant of wrapText that takes a list of strings as input. -- Useful when {--} makes it impossible to use multiline string -- literals. formatWords :: [String] -> Doc -- | Format a list of FilePaths 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 -- | userchunk creates a Doc containing a user chunk from a -- String userchunk :: String -> Doc -- | packedString builds a Doc from a ByteString using -- printable packedString :: ByteString -> Doc prefix :: String -> Doc -> Doc hiddenPrefix :: String -> Doc -> Doc insertBeforeLastline :: Doc -> Doc -> Doc prefixLines :: Doc -> Doc -> Doc -- | invisiblePS creates a Doc with invisible text from a -- ByteString invisiblePS :: ByteString -> Doc -- | userchunkPS creates a Doc representing a user chunk from -- a ByteString. -- -- Rrrright. And what, please is that supposed to mean? userchunkPS :: ByteString -> Doc -- | renders a Doc into a String with control codes for the -- special features of the Doc. renderString :: Doc -> String -- | renders a Doc into a String using a given set of -- printers. If content is only available as ByteString, decode -- according to the current locale. renderStringWith :: Printers' -> Doc -> String -- | renders a Doc into ByteString with control codes for the -- special features of the Doc. See also readerString. renderPS :: Doc -> ByteString -- | renders a Doc into a ByteString using a given set of -- printers. renderPSWith :: Printers' -> Doc -> ByteString -- | renders a Doc into a list of PackedStrings, one for -- each line. renderPSs :: Doc -> [ByteString] -- | renders a Doc into a list of PackedStrings, one for -- each chunk of text that was added to the Doc, 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 -- | simplePrinters is a Printers which uses the set -- 'simplePriners\'' on any handle. simplePrinters :: Printers -- | invisiblePrinter is the Printer for hidden text. It just -- replaces the document with empty. 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 -- | simplePrinter is the simplest Printer: it just -- concatenates together the pieces of the Doc simplePrinter :: Printer -- | A Printable 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 Doc from any Printable. printable :: Printable -> Doc -- | Creates an invisible Doc from any Printable. invisiblePrintable :: Printable -> Doc -- | Creates a hidden Doc from any Printable. hiddenPrintable :: Printable -> Doc -- | Creates... WTF is a userchunk??? 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 -- | colorText creates a Doc containing colored text from a -- String colorText :: Color -> String -> Doc lineColor :: Color -> Doc -> Doc -- | hputDoc puts a Doc on the given handle using -- simplePrinters hPutDoc :: Handle -> Doc -> IO () -- | hputDocLn puts a Doc, followed by a newline on the -- given handle using simplePrinters. hPutDocLn :: Handle -> Doc -> IO () -- | putDoc puts a Doc on stdout using the simple printer -- simplePrinters. putDoc :: Doc -> IO () -- | putDocLn puts a Doc, followed by a newline on stdout -- using simplePrinters putDocLn :: Doc -> IO () -- | hputDocWith puts a Doc on the given handle using the -- given printer. hPutDocWith :: Printers -> Handle -> Doc -> IO () -- | hputDocLnWith puts a Doc, followed by a newline on the -- given handle using the given printer. hPutDocLnWith :: Printers -> Handle -> Doc -> IO () -- | putDocWith puts a Doc on stdout using the given printer. putDocWith :: Printers -> Doc -> IO () -- | putDocLnWith puts a Doc, followed by a newline on stdout -- using the given printer. putDocLnWith :: Printers -> Doc -> IO () -- | like hPutDoc but with compress data before writing hPutDocCompr :: Handle -> Doc -> IO () -- | Write a Doc to stderr if debugging is turned on. debugDocLn :: Doc -> IO () -- | unsafeText creates a Doc from a String, using -- simplePrinter directly unsafeText :: String -> Doc -- | unsafeBoth builds a Doc from a String and a -- ByteString representing the same text, but does not check that -- they do. unsafeBoth :: String -> ByteString -> Doc -- | unsafeBothText builds a Doc from a String. The -- string is stored in the Doc as both a String and a ByteString. unsafeBothText :: String -> Doc -- | unsafeChar creates a Doc containing just one character. unsafeChar :: Char -> Doc -- | unsafePackedString builds a Doc from a ByteString -- using simplePrinter 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: -- -- module Darcs.Util.English -- |
--   englishNum 0 (Noun "watch") "" == "watches"
--   englishNum 1 (Noun "watch") "" == "watch"
--   englishNum 2 (Noun "watch") "" == "watches"
--   
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 -- --
--   plural (Noun "batch") "" == "batches"
--   plural (Noun "bat")   "" == "bats"
--   plural (Noun "mouse") "" == "mouses" -- :-(
--   
newtype Noun Noun :: String -> Noun data Pronoun It :: Pronoun -- |
--   singular This (Noun "batch") "" == "this batch"
--   plural   This (Noun "batch") "" == "these batches"
--   
data This This :: Noun -> This -- | Given a list of things, combine them thusly: -- --
--   orClauses ["foo", "bar", "baz"] == "foo, bar or baz"
--   
andClauses :: [String] -> String -- | Given a list of things, combine them thusly: -- --
--   orClauses ["foo", "bar", "baz"] == "foo, bar or baz"
--   
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 debugDoc :: Doc -> IO () -- | fancyPrinters h returns a set of printers suitable for -- outputting to h fancyPrinters :: Printers environmentHelpColor :: ([String], [String]) environmentHelpEscape :: ([String], [String]) environmentHelpEscapeWhite :: ([String], [String]) -- | eputDocLn puts a Doc, followed by a newline to stderr -- using fancyPrinters. 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 -- | beginTedious k starts a tedious process and registers it in -- _progressData with the key k. A tedious process is one -- for which we want a progress indicator. -- -- Wouldn't it be safer if it had type String -> 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 () -- | endTedious k unregisters the tedious process with key -- k, printing Done if such a tedious process exists. endTedious :: String -> IO () tediousSize :: String -> Int -> IO () 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 -- | askUserListItem prompt xs enumerates xs 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 -- | XXX: Perhaps a word of explanation here [WL] module Darcs.Util.Ratified -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | Computation hGetContents hdl returns the list of -- characters corresponding to the unread portion of the channel or file -- managed by hdl, which is put into an intermediate state, -- semi-closed. In this state, hdl is effectively closed, -- but items are read from hdl on demand and accumulated in a -- special list returned by hGetContents hdl. -- -- Any operation that fails because a handle is closed, also fails if a -- handle is semi-closed. The only exception is hClose. A -- semi-closed handle becomes closed: -- -- -- -- Once a semi-closed handle becomes closed, the contents of the -- associated list becomes fixed. The contents of this final list is only -- partially specified: it will contain at least all the items of the -- stream that were evaluated prior to the handle becoming closed. -- -- Any I/O errors encountered while a handle is semi-closed are simply -- discarded. -- -- This operation may fail with: -- -- hGetContents :: Handle -> IO String module Darcs.Util.Show appPrec :: Int newtype BSWrapper BSWrapper :: ByteString -> BSWrapper instance GHC.Show.Show Darcs.Util.Show.BSWrapper 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 Sealed 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 Sealed 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 -- | FreeLeft p is forall x . exists y . p x y 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 y is dependent -- on the x that is supplied. This is why Stepped is -- needed, rather than writing the more obvious Sealed -- (Poly p) which would notionally have the same quantification of -- the type witnesses. data FreeLeft p -- | FreeRight p is forall y . exists x . p x y 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 x is dependent -- on the y that is supplied. data FreeRight p -- | Unwrap a FreeLeft value unFreeLeft :: FreeLeft p -> Sealed (p wX) -- | Unwrap a FreeRight value unFreeRight :: FreeRight p -> FlippedSeal p wX -- | Gap abstracts over FreeLeft and FreeRight for -- code constructing these values class Gap w -- | An empty Gap, e.g. NilFL or NilRL emptyGap :: Gap w => (forall wX. p wX wX) -> w p -- | A Gap 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 Gap values together in series, e.g. 'joinGap -- (+>+)' or 'joinGap (:>:)' 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) -- --
--   wX     wY       
--    \     /    
--     \   /
--      \ /     
--       wU
--       |
--       |
--       |
--       wA
--   
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 FL i.e. associating to the right. -- Like foldr 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 FLs that transforms a witnessed -- state in the direction opposite to the FL. This is the -- "natural" fold for FLs i.e. the one which replaces the -- :>: 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 foldrwFL for RLs. This is the "natural" -- fold for RLs i.e. the one which replaces the :<: with -- the passed operator. foldlwRL :: (forall wA wB. r wA -> p wA wB -> r wB) -> r wX -> RL p wX wY -> r wY 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 FL associating to the left, sequencing -- effects from left to right. The order of arguments follows the -- standard foldM 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 FL 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 -- | filterOutFLFL p xs deletes any x in xs for -- which p x == IsEq (indicating that x 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 (+>+) :: FL a wX wY -> FL a wY wZ -> FL a wX wZ infixr 5 +>+ (+<+) :: RL a wX wY -> RL a wY wZ -> RL a wX wZ infixl 5 +<+ -- | Prepend an RL to an FL. This traverses only the left -- hand side. (+>>+) :: RL p wX wY -> FL p wY wZ -> FL p wX wZ infixr 5 +>>+ -- | Append an FL to an RL. 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 toFL :: [FreeLeft a] -> Sealed (FL a wX) 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 () -- | Check that two FLs are equal element by element. This differs -- from the Eq2 instance for FL which uses commutation. eqFL :: Eq2 a => FL a wX wY -> FL a wX wZ -> EqCheck wY wZ eqFLUnsafe :: Eq2 a => FL a wX wY -> FL a wZ wW -> Bool initsFL :: FL p wX wY -> [Sealed ((p :> FL p) wX)] isShorterThanRL :: RL a wX wY -> Int -> Bool snocRLSealed :: FlippedSeal (RL a) wY -> a wY wZ -> FlippedSeal (RL a) wZ -- | Like span only for RLs. 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 break only for RLs. 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 takeWhile only for RLs. 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.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.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 clowns 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" -- http://en.wikipedia.org/wiki/Stuck_in_the_Middle 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 invert operation must be self-inverse, i.e. an involution: -- --
--   invert . invert = id
--   
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 -- | Delete the first subsequence of patches that is followed by an inverse -- subsequence, if one exists. If not return Nothing. dropInverses :: (Invert p, Eq2 p) => FL p wX wY -> Maybe (FL p wX wY) 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 -- Patchy. 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 (Nothing): 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 -- | Commute represents things that can be (possibly) commuted. -- -- Instances should obey the following laws: -- -- -- --
--   commute (p:>q) == Just (q':>p') <=> commute (q':>p') == Just (p':>q)
--   
-- -- -- --
--   commute (p:>q) == Just (q':>p') <=> commute (invert q:>invert p) == Just (invert p':>invert q')
--   
-- -- -- --
--   commute (p:>q) == Just (q':>p') => commute (invert p:>q') == Just (q:>invert p')
--   
-- -- is required to hold only for primitive patches, i.e. if there is -- no instance Merge p, because together with -- merge it implies that any two patches commute. class Commute p commute :: Commute p => (p :> p) wX wY -> Maybe ((p :> p) wX wY) -- | commuteFL commutes a single element past a FL. commuteFL :: Commute p => (p :> FL p) wX wY -> Maybe ((FL p :> p) wX wY) -- | commuteRL commutes a RL past a single element. commuteRL :: Commute p => (RL p :> p) wX wY -> Maybe ((p :> RL p) wX wY) -- | commuteRLFL commutes an RL past an FL. 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 CleanMerge in a -- trivial way by defining cleanMerge _ = Nothing, -- which vacuously conforms to all required laws. -- -- Instances should obey the following laws: -- -- -- -- If an instance Commute p exists, then we also require -- -- -- -- If an instance Invert p exists, then we also require -- -- 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: -- -- class CleanMerge p => Merge p merge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY -- | Synonym for merge. 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 p :/: q to a merge function over -- p :/: FL q mergerIdFL :: MergeFn p q -> MergeFn p (FL q) -- | Lift a merge function over p :/: q to a merge function over -- FL p :/: q mergerFLId :: MergeFn p q -> MergeFn (FL p) q -- | Lift a merge function over p :/: q to a merge function over -- FL p :/: FL q mergerFLFL :: MergeFn p q -> MergeFn (FL p) (FL q) -- | Cleanly merge a single patch with an FL 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, merge, then swap again. Used to exploit -- prop_mergeSymmetric when defining merge. swapMerge :: Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY -- | Swap the two patches, cleanMerge, then swap again. Used to -- exploit prop_cleanMergeSymmetric when defining -- cleanMerge. 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 symmetry law. prop_mergeSymmetric :: (Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool -- | Whether the given pair of patches satisfies the merge-commute -- 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 -- | removeFL x xs removes x from xs if -- x can be commuted to its head. Otherwise it returns -- Nothing removeFL :: (Eq2 p, Commute p) => p wX wY -> FL p wX wZ -> Maybe (FL p wY wZ) -- | removeRL is like removeFL except with RL 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 => (forall wA wB. (p :> q) wA wB -> Maybe ((q :> p) wA wB)) -> (RL p :> q) wX wY -> (RL p :> (q :> RL p)) wX wY genCommuteWhatWeCanFL :: Commute q => (forall wA wB. (p :> q) wA wB -> Maybe ((q :> p) wA wB)) -> (p :> FL q) wX wY -> (FL q :> (p :> FL q)) wX wY -- | Split an FL 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 p should be invariant under -- commutation: if commute(x:>y)==Just(y':>x') then p -- x == p x' && p y == p y'. partitionFL :: Commute p => (forall wU wV. p wU wV -> Bool) -> FL p wX wY -> (FL p :> (FL p :> FL p)) wX wY -- | Split an RL 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 p should be invariant under -- commutation: if commute(x:>y)==Just(y':>x') then p -- x == p x' && p y == p y'. 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 -- | This is a minor variant of headPermutationsFL with each -- permutation is simply returned as a FL simpleHeadPermutationsFL :: Commute p => FL p wX wY -> [FL p wX wY] -- | headPermutationsRL is like headPermutationsFL, except -- that we operate on an RL (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] -- | headPermutationsFL p:>:ps returns all the -- permutations of the list in which one element of ps is -- commuted past p -- -- Suppose we have a sequence of patches -- --
--   X h a y s-t-c k
--   
-- -- Suppose furthermore that the patch c depends on t, -- which in turn depends on s. This function will return -- --
--   X :> h a y s t c k
--   h :> X a y s t c k
--   a :> X h y s t c k
--   y :> X h a s t c k
--   s :> X h a y t c k
--   k :> X h a y s t c
--   
headPermutationsFL :: Commute p => FL p wX wY -> [(p :> FL p) wX wY] -- | All permutations of an RL. permutationsRL :: Commute p => RL p wX wY -> [RL p wX wY] -- | removeSubsequenceFL ab abc returns Just c' -- where all the patches in ab have been commuted out of it, if -- possible. If this is not possible for any reason (the set of patches -- ab is not actually a subset of abc, or they can't be -- commuted out) we return Nothing. removeSubsequenceFL :: (Eq2 p, Commute p) => FL p wA wB -> FL p wA wC -> Maybe (FL p wB wC) -- | removeSubsequenceRL is like removeSubsequenceFL except -- that it works on RL 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 :: (Commute p, CleanMerge p) => FL p wX wY -> FL p wX wZ -> (FL p :> FL p) wX wY instance (Darcs.Patch.Witnesses.Eq.Eq2 p, Darcs.Patch.Commute.Commute p) => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Witnesses.Ordered.FL p) instance (Darcs.Patch.Witnesses.Eq.Eq2 p, Darcs.Patch.Commute.Commute p) => Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.Witnesses.Ordered.RL p) module Darcs.Patch.CommuteNoConflicts -- | It is natural to think of conflicting patches p and -- q as a parallel pair p:/:q 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 -- (p:>q'). In that case, commute will always -- succeed, as expressed by the prop_mergeCommute law. -- commuteNoConflicts is a restricted version of commute -- that should fail in this case but otherwise give the same result as -- commute. -- -- Primitive patch types have no conflictors, so for them we have -- commute == commuteNoConflicts. -- -- Instances should obey the following laws: -- -- -- --
--   commuteNoConflicts (p:>q) == Just (q':>p') <=> commuteNoConflicts (q':>p') == Just (p':>q)
--   
-- -- -- --
--   commuteNoConflicts (p:>q) == Just (q':>p') => commuteNoConflicts (invert p:>q') == Just (q:>invert p')
--   
-- -- -- --
--   commuteNoConflicts (p:>q) == Just r => commute (p:>q) == Just r
--   
class Commute p => CommuteNoConflicts p -- | An alternative to commute 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 -- p:/:q is conflicting if and only if -- commuteNoConflicts(p^:>q) fails. Its main use is so that -- we can define mergeNoConflicts cleanly. commuteNoConflicts :: CommuteNoConflicts p => (p :> p) wX wY -> Maybe ((p :> p) wX wY) -- | The non-conflicting merge of p:/:q tries to commute the -- inverse p^ of p with q. If it succeeds then -- the part of the result that corresponds to p^ 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 commuteNoConflicts here and not commute. -- Otherwise we run into contradictions as explained below. -- -- Concretely, suppose we use commute here and that q -- is a conflictor that represents the primitive patch r and -- conflicts (only) with (primitive patch) p^. That is, -- q results from the conflicted merge(r:/:p^)=(s:/:q), -- where s is another conflictor. Now, according to -- prop_mergeCommute we get -- commute(p^:>q)=Just(r:>s), and thus -- mergeNoConflict(p:/:q)=Just(s^:/:r) in contradiction to our -- assumption that p^:/:q are in conflict i.e. -- mergeNoConflict(p^:/:q) 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 -- s^ as part of the result leads to further problems. For -- instance, whether our repo is conflicted now depends on the order of -- patches: (p:>r) is not conflicted, but its commute -- (q:>s^) obviously is. In fact, (q:>s^) is -- nothing else but the (identity-preserving) "force-commute" of -- (p:>r), see the thread at -- https:/lists.osuosl.orgpipermaildarcs-devel2017-November/018403.html mergeNoConflicts :: (Invert p, CommuteNoConflicts p) => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY) -- | Path resolving: -- -- -- -- Examples: -- --
--   /usr/repo/foo                 -- local file
--   c:/src/darcs                  -- local file
--   http://darcs.net/             -- URL
--   peter@host:/path              -- ssh
--   droundy@host:                 -- ssh
--   host:/path                    -- ssh
--   
-- -- This means that single-letter hosts in ssh-paths do not work, unless a -- username is provided. -- -- Perhaps ssh-paths should use "ssh://user@host/path"-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 module Darcs.Util.Workaround setExecutable :: FilePath -> Bool -> IO () -- | Obtain the current working directory as an absolute path. -- -- In a multithreaded program, the current working directory is a global -- state shared among all threads of the process. Therefore, when -- performing filesystem operations from multiple threads, it is highly -- recommended to use absolute rather than relative paths (see: -- makeAbsolute). -- -- The operation may fail with: -- -- getCurrentDirectory :: IO FilePath -- | installHandler int handler iset calls sigaction to -- install an interrupt handler for signal int. If -- handler is Default, SIG_DFL is installed; -- if handler is Ignore, SIG_IGN is installed; -- if handler is Catch action, a handler is installed -- which will invoke action in a new thread when (or shortly -- after) the signal is received. If iset is Just s, -- then the sa_mask of the sigaction structure is set -- to s; otherwise it is cleared. The previously installed -- signal handler for int is returned installHandler :: Signal -> Handler -> Maybe SignalSet -> IO Handler -- | raiseSignal int calls kill to signal the current -- process with interrupt signal int. raiseSignal :: Signal -> IO () -- | The actions to perform when a signal is received. 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 catch, 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 catchNonExistence :: IO a -> 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 fail. -- -- We use fail 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 -- | Like handleOnlyIOError but restricted to returning a given -- value. ifIOError :: a -> IO a -> IO a -- | Like ifIOError 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 instance GHC.Classes.Eq Darcs.Util.Ssh.SshSettings instance GHC.Show.Show Darcs.Util.Ssh.SshSettings module Darcs.Util.Path -- | encodeWhite translates whitespace in filenames to a -- darcs-specific format (numerical representation according to -- ord surrounded by backslashes). Note that backslashes are also -- escaped since they are used in the encoding. -- --
--   encodeWhite "hello there" == "hello\32\there"
--   encodeWhite "hello\there" == "hello\92\there"
--   
encodeWhite :: FilePath -> String -- | decodeWhite interprets the Darcs-specific "encoded" filenames -- produced by encodeWhite -- --
--   decodeWhite "hello\32\there"  == "hello there"
--   decodeWhite "hello\92\there"  == "hello\there"
--   decodeWhite "hello\there"   == error "malformed filename"
--   
decodeWhite :: String -> FilePath encodeWhiteName :: Name -> ByteString decodeWhiteName :: ByteString -> 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. 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 AbsolutePath 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 makeSubPathOf :: AbsolutePath -> AbsolutePath -> Maybe SubPath simpleSubPath :: FilePath -> Maybe SubPath -- | Transform a SubPath into an AnchoredPath. floatSubPath :: SubPath -> AnchoredPath class FilePathOrURL a toPath :: FilePathOrURL a => a -> String class FilePathOrURL a => FilePathLike a toFilePath :: FilePathLike a => a -> FilePath getCurrentDirectory :: IO AbsolutePath setCurrentDirectory :: 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 -- path_number when path already exist (e.g. -- darcs.net_0). getUniquePathName :: Bool -> (FilePath -> String) -> (Int -> FilePath) -> IO FilePath doesPathExist :: FilePath -> IO Bool -- | What is a malicious path? -- -- A spoofed path is a malicious path. -- --
    --
  1. Darcs only creates explicitly relative paths (beginning with -- "./"), so any not explicitly relative path is surely -- spoofed.
  2. --
  3. Darcs normalizes paths so they never contain "/../", so -- paths with "/../" are surely spoofed.
  4. --
-- -- A path to a darcs repository's meta data can modify "trusted" patches -- or change safety defaults in that repository, so we check for paths -- containing "/_darcs/" which is the entry to darcs meta data. -- -- To do? -- -- -- -- TODO: Properly review the way we handle paths on Windows - it's not -- enough to just use the OS native concept of path separator. Windows -- often accepts both path separators, and repositories always use the -- UNIX separator anyway. isMaliciousSubPath :: String -> Bool -- | 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 Name from a String. If the input String is -- invalid, that is, "", ".", "..", or contains a /, return -- Left with an error message. makeName :: String -> Either String Name -- | Make a Name from a ByteString. 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 ("floatPath" -- -- 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 -- FilePath. Moreover, you can use anchorPath "" to get a -- relative FilePath. anchorPath :: FilePath -> AnchoredPath -> FilePath -- | Check whether a path is a prefix of another path. isPrefix :: AnchoredPath -> AnchoredPath -> Bool -- | If the patch is under a directory, split into Right of the first -- component (which must be a directory name) and the rest of teh path. -- Otherwise return Left of the single component. This function is -- *undefined* on the root path (which has no components). breakOnDir :: AnchoredPath -> Either Name (Name, AnchoredPath) -- | 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. foobarbaz -> foo/bar parent :: AnchoredPath -> Maybe AnchoredPath -- | List all parents of a given path. foobarbaz -> [.,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 showPatch and friends, except for the root -- path which is displayed as plain ".". displayPath :: AnchoredPath -> FilePath -- | Interpret an AnchoredPath 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 -- | Take a relative FilePath and turn it into an AnchoredPath. This is a -- partial function. Basically, by using floatPath, you are testifying -- that the argument is a path relative to some common root -- i.e. the -- root of the associated Tree 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) floatPath :: FilePath -> AnchoredPath instance GHC.Classes.Eq Darcs.Util.Path.CorruptPatch 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 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.AbsoluteOrRemotePath instance GHC.Classes.Eq Darcs.Util.Path.AbsoluteOrRemotePath instance GHC.Classes.Ord Darcs.Util.Path.AbsolutePathOrStd instance GHC.Classes.Eq Darcs.Util.Path.AbsolutePathOrStd instance GHC.Classes.Ord Darcs.Util.Path.AbsolutePath instance GHC.Classes.Eq Darcs.Util.Path.AbsolutePath instance GHC.Classes.Ord Darcs.Util.Path.SubPath instance GHC.Classes.Eq Darcs.Util.Path.SubPath instance GHC.Exception.Type.Exception Darcs.Util.Path.CorruptPatch instance GHC.Show.Show Darcs.Util.Path.CorruptPatch instance Darcs.Util.Path.CharLike c => Darcs.Util.Path.FilePathOrURL [c] instance Darcs.Util.Path.CharLike GHC.Types.Char instance Darcs.Util.Path.CharLike c => Darcs.Util.Path.FilePathLike [c] 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 -- | 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.: -- --
--   tree <- readDarcsPristine "." >>= expand
--   
-- -- 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 -> !Hash -> Blob m data TreeItem m File :: !Blob m -> TreeItem m SubTree :: !Tree m -> TreeItem m Stub :: !m (Tree m) -> !Hash -> TreeItem m data ItemType TreeType :: ItemType BlobType :: ItemType data Hash SHA256 :: !ByteString -> Hash NoHash :: 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, Hash, Maybe Hash)] (Tree IO)) items :: Tree m -> Map Name (TreeItem m) -- | List all contents of a Tree. 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 -> Hash -- | Look up a Tree item (an immediate subtree or blob). lookup :: Tree m -> Name -> Maybe (TreeItem m) -- | Find a TreeItem by its path. Gives Nothing if the path -- is invalid. find :: Tree m -> AnchoredPath -> Maybe (TreeItem m) -- | Find a Blob by its path. Gives Nothing if the path is -- invalid, or does not point to a Blob. findFile :: Tree m -> AnchoredPath -> Maybe (Blob m) -- | Find a Tree by its path. Gives Nothing 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 -> 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 zipFiles or zipTrees. 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. -- --
--   explodePath t p == Prelude.filter (p `isPrefix`) (map fst (list t))
--   
explodePath :: Tree m -> AnchoredPath -> [AnchoredPath] -- | Like explodePath but for multiple paths. explodePaths :: Tree IO -> [AnchoredPath] -> [AnchoredPath] -- | 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 pred tree, produce a Tree that only has items -- for which pred returns True. 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 guide and a tree, produces a new -- Tree that is a identical to tree, but only has those items -- that are present in both tree and guide. The -- guide 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 not expand the tree. updateTree :: Monad m => (TreeItem m -> m (TreeItem m)) -> Tree m -> m (Tree m) -- | Does not 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 :: Monad m => Tree m -> Tree m -> Tree m addMissingHashes :: Monad m => (TreeItem m -> m Hash) -> Tree m -> m (Tree m) -- | Specification of explodePath 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 -- | An experimental monadic interface to Tree 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 monad -- interface itself is generic, and a number of actual implementations -- can be used. This module provides just virtualTreeIO that never -- writes any changes, but may trigger filesystem reads as appropriate. module Darcs.Util.Tree.Monad virtualTreeIO :: TreeIO a -> Tree IO -> IO (a, Tree IO) -- | Run a TreeIO action without storing any changes. This is useful for -- running monadic tree mutations for obtaining the resulting Tree (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 a form of -- modified Tree. virtualTreeMonad :: Monad m => TreeMonad m a -> Tree m -> m (a, Tree m) -- | Grab content of a file in the current Tree at the given path. readFile :: TreeRO m => AnchoredPath -> m ByteString -- | 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 :: TreeRW m => AnchoredPath -> ByteString -> m () createDirectory :: TreeRW m => AnchoredPath -> m () rename :: TreeRW m => AnchoredPath -> AnchoredPath -> m () copy :: TreeRW m => AnchoredPath -> AnchoredPath -> m () unlink :: TreeRW m => AnchoredPath -> m () -- | Check for existence of a file. fileExists :: TreeRO m => AnchoredPath -> m Bool -- | Check for existence of a directory. directoryExists :: TreeRO m => AnchoredPath -> m Bool -- | Check for existence of a node (file or directory, doesn't matter). exists :: TreeRO m => AnchoredPath -> m Bool withDirectory :: TreeRO m => AnchoredPath -> m a -> m a currentDirectory :: TreeRO m => m AnchoredPath tree :: TreeState m -> Tree m -- | Internal state of the TreeIO monad. Keeps track of the current -- Tree content, unsync'd changes and a current working directory (of the -- monad). data TreeState m -- | A TreeIO monad. A sort of like IO but it keeps a -- TreeState around as well, which is a sort of virtual -- filesystem. Depending on how you obtained your TreeIO, the -- actions in your virtual filesystem get somehow reflected in the actual -- real filesystem. For virtualTreeIO, nothing happens in real -- filesystem, however with plainTreeIO, the plain tree will be -- updated every now and then, and with hashedTreeIO a -- darcs-style hashed tree will get updated. type TreeMonad m = RWST AnchoredPath () (TreeState m) m type TreeIO = TreeMonad IO runTreeMonad :: Monad m => TreeMonad m a -> TreeState m -> m (a, Tree m) initialState :: Tree m -> (TreeItem m -> m Hash) -> (AnchoredPath -> TreeItem m -> TreeMonad m (TreeItem m)) -> TreeState m -- | Replace an item with a new version without modifying the content of -- the tree. This does not do any change tracking. Ought to be only used -- from a sync implementation for a particular storage format. -- The presumed use-case is that an existing in-memory Blob is replaced -- with a one referring to an on-disk file. replaceItem :: Monad m => AnchoredPath -> Maybe (TreeItem m) -> 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)) class Monad m => TreeRO m class TreeRO m => TreeRW m instance GHC.Base.Monad m => Darcs.Util.Tree.Monad.TreeRW (Darcs.Util.Tree.Monad.TreeMonad m) instance GHC.Base.Monad m => Darcs.Util.Tree.Monad.TreeRO (Darcs.Util.Tree.Monad.TreeMonad m) module Darcs.Patch.MonadProgress class Monad m => MonadProgress m -- | run a list of ProgressActions. In some monads (typically -- IO-based ones), the progress and error messages will be used. In -- others they will be ignored and just the actions will be run. runProgressActions :: MonadProgress m => String -> [ProgressAction m ()] -> m () -- | a monadic action, annotated with a progress message that could be -- printed out while running the action, and a message that could be -- printed out on error. Actually printing out these messages is optional -- to allow non-IO monads to just run the action. data ProgressAction m a ProgressAction :: m a -> Doc -> Doc -> ProgressAction m a [paAction] :: ProgressAction m a -> m a [paMessage] :: ProgressAction m a -> Doc [paOnError] :: ProgressAction m a -> Doc -- | run a list of ProgressActions without any feedback messages silentlyRunProgressActions :: Monad m => String -> [ProgressAction m ()] -> m () instance GHC.Base.Monad m => Darcs.Patch.MonadProgress.MonadProgress (Darcs.Util.Tree.Monad.TreeMonad m) -- | 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 :: FilePath -> (Maybe Int, Hash) -> IO (Tree IO) -- | Write a Tree into a darcs-style hashed directory. writeDarcsHashed :: Tree IO -> FilePath -> IO Hash -- | Run a TreeIO action in a hashed setting. The -- initial tree is assumed to be fully available from the -- directory, and any changes will be written out to same. -- Please note that actual filesystem files are never removed. hashedTreeIO :: TreeIO a -> Tree IO -> FilePath -> IO (a, Tree IO) -- | Read and parse a darcs-style hashed directory listing from a given -- dir and with a given hash. readDarcsHashedDir :: FilePath -> (Maybe Int, Hash) -> IO [(ItemType, Name, Maybe Int, Hash)] readDarcsHashedNosize :: FilePath -> Hash -> IO (Tree IO) darcsAddMissingHashes :: Monad m => Tree m -> m (Tree m) darcsLocation :: FilePath -> (Maybe Int, Hash) -> FileSegment -- | Compute a darcs-compatible hash value for a tree-like structure. darcsTreeHash :: Tree m -> Hash decodeDarcsHash :: ByteString -> Hash decodeDarcsSize :: ByteString -> Maybe Int darcsUpdateHashes :: Monad m => Tree m -> m (Tree m) module Darcs.Util.File getFileStatus :: FilePath -> IO (Maybe FileStatus) withCurrentDirectory :: FilePathLike p => p -> IO a -> IO a doesDirectoryReallyExist :: FilePath -> IO Bool removeFileMayNotExist :: FilePathLike p => p -> IO () -- | getRecursiveContents returns all files under topdir that aren't -- directories. getRecursiveContents :: FilePath -> IO [FilePath] -- | getRecursiveContentsFullPath returns all files under topdir that -- aren't directories. Unlike getRecursiveContents this function returns -- the full path. getRecursiveContentsFullPath :: FilePath -> IO [FilePath] -- | xdgCacheDir returns the $XDG_CACHE_HOME environment variable, or -- ~/.cache if undefined. See the FreeDesktop specification: -- http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html xdgCacheDir :: IO (Maybe FilePath) -- | osxCacheDir assumes ~LibraryCaches/ exists. osxCacheDir :: IO (Maybe FilePath) -- | 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 read function on Blobs coming from a plain tree is -- susceptible to file content changes. Since we use mmap in read, -- 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 writePlainTree implemented in -- this module is safe in this respect). module Darcs.Util.Tree.Plain readPlainTree :: FilePath -> IO (Tree IO) -- | Write out full tree to a plain directory structure. If you -- instead want to make incremental updates, refer to -- Darcs.Util.Tree.Monad. writePlainTree :: Tree IO -> FilePath -> IO () -- | 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 library: this is responsibility of your application. -- It is advisable that in your validity tracking code, you also check -- for format validity (see indexFormatValid) 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 Item). The on-disk format is -- best described by the section Index format 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 Tree object, and can be leveraged by eg. -- diffTrees 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. -- -- Endianness -- -- Since version 6 (magic == HSI6), 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. -- -- Index format -- -- 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 -- organised into "lines" where each line describes a single indexed -- item. It consists of -- -- -- -- With directories, the aux holds the offset of the next sibling line in -- the index, so we can efficiently skip reading the whole subtree -- starting at a given directory (by just seeking aux bytes forward). The -- lines are pre-ordered with respect to directory structure -- the -- directory comes first and after it come all its items. Cf. -- readIndex'. -- -- 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. -- -- Comments by bf: -- -- The null byte terminator seems useless. -- -- We could as well use just a single ByteString to represent an item; or -- even a single raw pointer, since finalizers are needed only when we -- copy hash and path back to the program as ByteStrings. -- -- An alternative representation could be to store the fixed-size fields -- (i.e everything except the path) as an unboxed array of records -- (structs). The paths would then be stored in a bidirectional map -- between item indices and paths. module Darcs.Util.Index -- | Read an index and build up a Tree object from it, referring to -- current working directory. The initial Index object returned by -- readIndex is not directly useful. However, you can use filter -- on it. Either way, to obtain the actual Tree object, call update. -- -- The usual use pattern is this: -- --
--   do (idx, update) <- readIndex
--      tree <- update =<< filter predicate idx
--   
-- -- The resulting tree will be fully expanded. readIndex :: FilePath -> (Tree IO -> Hash) -> IO Index -- | Will add and remove files in index to make it match the Tree -- object given (it is an error for the Tree to contain a file or -- directory that does not exist in a plain form in current working -- directory). updateIndexFrom :: FilePath -> (Tree IO -> Hash) -> 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 updateIndex :: 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 pred tree, produce a Tree that only has items -- for which pred returns True. 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 file or folder path, get the corresponding fileID from the -- filesystem. getFileID :: AnchoredPath -> IO (Maybe FileID) align :: Integral a => a -> a -> a instance GHC.Classes.Eq Darcs.Util.Index.CorruptIndex instance GHC.Show.Show Darcs.Util.Index.Item 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.Util.Compat stdoutIsAPipe :: IO Bool canonFilename :: FilePath -> IO FilePath maybeRelink :: String -> String -> IO Bool atomicCreate :: FilePath -> IO () sloppyAtomicCreate :: FilePath -> IO () 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]) -- | withTemp safely creates an empty file (not open for writing) -- and returns its name. -- -- The temp file operations are rather similar to the locking operations, -- in that they both should always try to clean up, so exitWith causes -- trouble. withTemp :: (FilePath -> IO a) -> IO a -- | withOpenTemp creates a temporary file, and opens it. Both of -- them run their argument and then delete the file. Also, both of them -- (to my knowledge) are not susceptible to race conditions on the -- temporary file (as long as you never delete the temporary file; that -- would reintroduce a race condition). withOpenTemp :: ((Handle, FilePath) -> IO a) -> IO a -- | withTempDir creates a temporary directory, runs the action and -- then removes the directory. The location of that directory is -- determined by the contents of _darcsprefstmpdir, if it exists, -- otherwise by $DARCS_TMPDIR, and if that doesn't exist then -- whatever your operating system considers to be a a temporary directory -- (e.g. $TMPDIR under Unix, $TEMP 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 -- $DARCS_KEEP_TMPDIR variable is set temporary directory is not -- removed, this can be useful for debugging. withTempDir :: FilePath -> (AbsolutePath -> IO a) -> IO a -- | withPermDir is like withTempDir, 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 () removeFileMayNotExist :: FilePathLike p => p -> IO () canonFilename :: FilePath -> IO FilePath 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.External cloneTree :: FilePath -> FilePath -> IO () cloneFile :: FilePath -> FilePath -> IO () -- | fetchFile fileOrUrl cache 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 -- | fetchFileLazyPS fileOrUrl cache 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 gzFetchFilePS :: String -> Cachable -> IO ByteString speculateFileOrUrl :: String -> FilePath -> IO () copyFileOrUrl :: String -> FilePath -> FilePath -> Cachable -> IO () data Cachable Cachable :: Cachable Uncachable :: Cachable MaxAge :: !CInt -> Cachable backupByRenaming :: FilePath -> IO () backupByCopying :: FilePath -> IO () -- | 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 < and -- >. -- -- (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 (|) and -- newlines. Empty lines are ignored and multiple properties on the same -- line are separated with a |. -- -- If multiple properties appear on the same line (separated by vertical -- bars), then this indicates alternative format properties. These have a -- generic meaning: -- -- -- -- 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 transferProblem -- and readProblem 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 Left reason if -- it fails, where reason explains why we weren't able to -- identify the format. Note that we do no verification of the format, -- which is handled by readProblem or writeProblem on the -- resulting RepoFormat. 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. writeRepoFormat :: RepoFormat -> FilePath -> IO () -- | writeProblem source returns Just an error -- message if we cannot write to a repo in format source, or -- Nothing if there's no such problem. writeProblem :: RepoFormat -> Maybe String -- | readProblem source returns Just an error -- message if we cannot read from a repo in format source, or -- Nothing if there's no such problem. readProblem :: RepoFormat -> Maybe String -- | transferProblem source target returns Just an -- error message if we cannot transfer patches from a repo in format -- source to a repo in format target, or Nothing -- 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 module Darcs.Repository.Cache -- | cacheHash computes the cache hash (i.e. filename) of a packed -- string. cacheHash :: ByteString -> String okayHash :: String -> Bool -- | Cache is an abstract type for hiding the underlying cache locations data Cache mkCache :: [CacheLoc] -> 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 data HashedDir HashedPristineDir :: HashedDir HashedPatchesDir :: HashedDir HashedInventoriesDir :: HashedDir hashedDir :: HashedDir -> String bucketFolder :: String -> String unionCaches :: Cache -> Cache -> Cache -- | unionRemoteCaches merges caches. It tries to do better than just -- blindly copying remote cache entries: -- -- -- -- This approach should save us from bogus cache entries. One case it -- does not work very well is when you fetch from partial repository over -- network. Hopefully this is not a common case. unionRemoteCaches :: Cache -> Cache -> String -> IO Cache cleanCaches :: Cache -> HashedDir -> IO () cleanCachesWithHint :: Cache -> HashedDir -> [String] -> IO () -- | fetchFileUsingCache cache dir hash receives a list of caches -- cache, the directory for which that file belongs dir -- and the hash 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. fetchFileUsingCache :: Cache -> HashedDir -> String -> IO (String, ByteString) -- | speculateFileUsingCache cache subdirectory name takes note -- that the file name is likely to be useful soon: pipelined -- downloads will add it to the (low-priority) queue, for the rest it is -- a noop. speculateFileUsingCache :: Cache -> HashedDir -> String -> IO () -- | Note that the files are likely to be useful soon: pipelined downloads -- will add them to the (low-priority) queue, for the rest it is a noop. speculateFilesUsingCache :: Cache -> HashedDir -> [String] -> IO () -- | writeFileUsingCache cache compression subdir contents write -- the string contents to the directory subdir, except if it is -- already in the cache, in which case it is a noop. Warning (?) this -- means that in case of a hash collision, writing using -- writeFileUsingCache is a noop. The returned value is the filename that -- was given to the string. writeFileUsingCache :: Cache -> Compression -> HashedDir -> ByteString -> IO String -- | peekInCache cache subdir hash tells whether cache -- and contains an object with hash hash in a writable position. -- Florent: why do we want it to be in a writable position? peekInCache :: Cache -> HashedDir -> String -> IO Bool repo2cache :: String -> Cache writable :: CacheLoc -> Bool isThisRepo :: CacheLoc -> Bool -- | hashedFilePath cachelocation subdir hash returns the physical -- filename of hash hash in the subdir section of -- cachelocation. hashedFilePath :: CacheLoc -> HashedDir -> String -> String allHashedDirs :: [HashedDir] -- | Prints an error message with a list of bad caches. reportBadSources :: IO () closestWritableDirectory :: Cache -> Maybe String -- | This keeps only Repo NotWritable entries. dropNonRepos :: Cache -> Cache instance GHC.Classes.Eq Darcs.Repository.Cache.FromWhere instance GHC.Classes.Eq Darcs.Repository.Cache.OrOnlySpeculate instance GHC.Show.Show Darcs.Repository.Cache.CacheType instance GHC.Classes.Eq Darcs.Repository.Cache.CacheType instance GHC.Show.Show Darcs.Repository.Cache.WritableOrNot instance GHC.Classes.Eq Darcs.Repository.Cache.WritableOrNot instance GHC.Show.Show Darcs.Repository.Cache.Cache instance GHC.Classes.Eq Darcs.Repository.Cache.CacheLoc instance GHC.Show.Show Darcs.Repository.Cache.CacheLoc -- | This module should only be imported by Darcs.UI.Options.* and by -- Flags. Other modules needing access to DarcsFlag should -- import Flags module Darcs.UI.Options.Flags -- | The DarcsFlag 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 OneHash :: String -> DarcsFlag AfterPatch :: String -> DarcsFlag UpToPatch :: String -> DarcsFlag AfterHash :: String -> DarcsFlag UpToHash :: String -> DarcsFlag TagName :: String -> DarcsFlag LastN :: String -> DarcsFlag MaxCount :: String -> DarcsFlag IndexRange :: String -> DarcsFlag OneIndex :: String -> DarcsFlag NumberPatches :: DarcsFlag OneTag :: String -> DarcsFlag AfterTag :: String -> DarcsFlag UpToTag :: String -> 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 RemoteRepo :: 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 OnePattern :: String -> DarcsFlag SeveralPattern :: String -> DarcsFlag AfterPattern :: String -> DarcsFlag UpToPattern :: String -> 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 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 :: String -> DarcsFlag WriteMarks :: String -> DarcsFlag NullFlag :: DarcsFlag NoAmendUnrecord :: DarcsFlag AmendUnrecord :: DarcsFlag PatchIndexFlag :: DarcsFlag NoPatchIndexFlag :: DarcsFlag EnumPatches :: DarcsFlag NoEnumPatches :: DarcsFlag instance GHC.Show.Show Darcs.UI.Options.Flags.DarcsFlag instance GHC.Classes.Eq Darcs.UI.Options.Flags.DarcsFlag -- | Constructing OptSpecs and OptDescrs 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 DarcsFlag -- qualified. type Flag = DarcsFlag -- | We do not instantiate the d in OptSpec d f -- directly with OptDescr. Instead we (post-) compose it with -- (->) AbsolutePath. Modulo newtype noise, this is -- the same as -- --
--   type DarcsOptDescr f = OptDescr (AbsolutePath -> f)
--   
-- -- 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 PrimOptSpec instantiated with DarcsOptDescr and -- Flag. type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v -- | Construct a DarcsOptDescr with no arguments. noArg :: [Char] -> [String] -> f -> String -> DarcsOptDescr f -- | Construct a DarcsOptDescr with a String argument. strArg :: SingleArgOptDescr String f -- | Construct a DarcsOptDescr with an optional String -- argument. optStrArg :: SingleArgOptDescr (Maybe String) f -- | Construct a DarcsOptDescr with an AbsolutePath argument. absPathArg :: SingleArgOptDescr AbsolutePath f -- | Construct a DarcsOptDescr with an AbsolutePathOrStd -- argument. absPathOrStdArg :: SingleArgOptDescr AbsolutePathOrStd f -- | Construct a DarcsOptDescr with an optional AbsolutePath -- argument. optAbsPathArg :: [Char] -> [String] -> String -> (AbsolutePath -> f) -> String -> String -> DarcsOptDescr f -- | The raw material from which multi-valued options are built. See -- withDefault. 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 PrimDarcsOption from a default value and a list of -- RawOptSpec. -- -- Precondition: the list must have an entry for each possible value -- (type v). withDefault :: Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v -- | Construct a Bool 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 Maybe String valued option with a -- single flag that takes a String 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 singleStrArg, except that the flag can be given more -- than once. The flag arguments are collected in a list of -- Strings. multiStrArg :: [Char] -> [String] -> (String -> Flag) -> ([Flag] -> [String]) -> String -> String -> PrimDarcsOption [String] -- | Similar to multiStrArg, except that the flag arguments are -- optional. multiOptStrArg :: [Char] -> [String] -> (Maybe String -> Flag) -> ([Flag] -> [Maybe String]) -> String -> String -> PrimDarcsOption [Maybe String] -- | Construct a Maybe AbsolutePath valued option -- with a single flag that takes an AbsolutePath 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 singleAbsPathArg, except that the flag can be given -- more than once. The flag arguments are collected in a list of -- AbsolutePaths. 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 RawOptSpecs 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 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 -- | 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 makeAbsoluteOrStd :: AbsolutePath -> String -> 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.UI.Commands.Util.Tree 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 module Darcs.Repository.Prefs addToPreflist :: String -> 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 :: String -> IO [String] setPreflist :: String -> [String] -> IO () getGlobal :: String -> IO [String] environmentHelpHome :: ([String], [String]) defaultrepo :: RemoteRepos -> AbsolutePath -> [String] -> IO [String] getDefaultRepo :: IO (Maybe String) -- | addRepoSource adds a new entry to _darcsprefsrepos and sets it -- as default in _darcsprefsdefaultrepo, unless --no-set-default -- or --dry-run is passed, or it is the same repository as the current -- one. addRepoSource :: String -> DryRun -> RemoteRepos -> SetDefault -> InheritDefault -> Bool -> IO () getPrefval :: String -> IO (Maybe String) setPrefval :: String -> String -> IO () changePrefval :: String -> String -> String -> IO () defPrefval :: String -> String -> IO String writeDefaultPrefs :: IO () -- | boringRegexps returns a list of the boring regexps, from the local and -- global prefs/boring files. Any invalid regexps are filtered, -- preventing an exception in (potentially) pure code, when the regexps -- are used. boringRegexps :: IO [Regex] isBoring :: IO (FilePath -> Bool) data FileType BinaryFile :: FileType TextFile :: FileType filetypeFunction :: IO (FilePath -> FileType) getCaches :: UseCache -> String -> IO Cache globalCacheDir :: IO (Maybe FilePath) -- | The relative path of the global preference directory; -- ~/.darcs on Unix, and %APPDATA%/darcs on Windows. -- This is used for online documentation. globalPrefsDirDoc :: String -- | The path of the global preference directory; ~/.darcs on -- Unix, and %APPDATA%/darcs 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 :: FilePath -> String prefsDirPath :: FilePath prefsFilePath :: FilePath getPrefLines :: FilePath -> IO [String] prefsFilesHelp :: [(String, String)] instance GHC.Classes.Eq Darcs.Repository.Prefs.FileType 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.SummDetail instance GHC.Classes.Ord Darcs.Patch.SummaryData.SummDetail instance GHC.Classes.Eq Darcs.Patch.SummaryData.SummOp instance GHC.Classes.Ord Darcs.Patch.SummaryData.SummOp module Darcs.Patch.Prim.FileUUID.ObjectMap newtype UUID UUID :: ByteString -> UUID -- | An object is located by giving the UUID of the parent -- Directory and a Name. data Location L :: !UUID -> !Name -> Location data Object (m :: * -> *) Directory :: DirContent -> Object Blob :: m FileContent -> !Hash -> Object data ObjectMap (m :: * -> *) ObjectMap :: (UUID -> m (Maybe (Object m))) -> (UUID -> Object m -> m (ObjectMap m)) -> m [UUID] -> ObjectMap [getObject] :: ObjectMap -> UUID -> m (Maybe (Object m)) [putObject] :: ObjectMap -> UUID -> Object m -> m (ObjectMap m) [listObjects] :: ObjectMap -> 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.Location instance GHC.Classes.Eq Darcs.Patch.Prim.FileUUID.ObjectMap.Location 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 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 InFirst, a final section named InLast, and -- between them a third section of not yet decided patches named -- InMiddle. The reason for the neutral terminology -- InFirst, InMiddle, and InLast, is that which of -- InFirst and InLast counts as selected or -- deselected depends on what we want to achive, that is, on the -- command and its options. See Darcs.UI.SelectChanges 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 LabelledPatches where each patch is either -- InFirst, InMiddle, or InLast. The representation -- is optimized for the case where we start chosing patches from the left -- of the sequence: patches that are InFirst are commuted to the -- head immediately, but patches that are InMiddle or -- InLast are mixed together; when a patch is marked -- InLast, its dependencies are not updated until we retrieve the -- final result. data PatchChoices p wX wY -- | See module documentation for Darcs.Patch.Choices. data Slot InFirst :: Slot InMiddle :: Slot InLast :: Slot -- | Create a PatchChoices from a sequence of patches, so that all -- patches are initially InMiddle. patchChoices :: FL p wX wY -> PatchChoices p wX wY -- | Create a PatchChoices from an already labelled sequence of -- patches, so that all patches are initially InMiddle. mkPatchChoices :: FL (LabelledPatch p) wX wY -> PatchChoices p wX wY -- | Given a LabelledPatch determine to which section of the given -- PatchChoices it belongs. This is not trivial to compute, since -- a patch tagged as InMiddle may be forced to actually be -- InLast by dependencies. We return a possibly re-ordered -- PatchChoices 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 PatchChoice. The result -- is a triple first:>middle:>last, such that all patches -- in first are InFirst, all patches in middle -- are InMiddle, and all patches in last are -- InLast. getChoices :: Commute p => PatchChoices p wX wY -> (FL (LabelledPatch p) :> (FL (LabelledPatch p) :> FL (LabelledPatch p))) wX wY -- | Like getChoices but lumps together InFirst and -- InMiddle patches. -- --
--   separateFirstMiddleFromLast c == case getChoices c of f:>m:>l -> f+>+m:>l
--   
separateFirstMiddleFromLast :: Commute p => PatchChoices p wX wZ -> (FL (LabelledPatch p) :> FL (LabelledPatch p)) wX wZ -- | Like getChoices but lumps together InMiddle and -- InLast patches. This is more efficient than using -- getChoices and then catenating InMiddle and -- InLast sections because we have to commute less. (This is what -- PatchChoices are optimized for.) -- --
--   separateFirstFromMiddleLast c == case getChoices c of f:>m:>l -> f:>m+>+l
--   
separateFirstFromMiddleLast :: PatchChoices p wX wZ -> (FL (LabelledPatch p) :> FL (LabelledPatch p)) wX wZ -- | Force all patches matching the given predicate to be InFirst, -- pulling any dependencies with them. This even forces any patches that -- were already tagged InLast. 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 -- InFirst, pulling any dependencies with them. This even forces -- any patches that were already tagged InLast. forceFirsts :: Commute p => [Label] -> PatchChoices p wA wB -> PatchChoices p wA wB -- | Force a single patch labelled with the given label to be -- InFirst, pulling any dependencies with them. This even forces -- any patches that were already tagged InLast. forceFirst :: Commute p => Label -> PatchChoices p wA wB -> PatchChoices p wA wB -- | Similar to forceMatchingFirst only that patches are forced to -- be InLast 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 -- InLast, pulling any dependencies with them. This even forces -- any patches that were previously tagged InFirst. forceLasts :: Commute p => [Label] -> PatchChoices p wA wB -> PatchChoices p wA wB -- | Force a single patch labelled with the given label to be -- InLast, 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 Label to be InMiddle, -- pulling any dependencies with it, regardless of their previous status. forceMiddle :: Commute p => Label -> PatchChoices p wA wB -> PatchChoices p wA wB -- | Turn InMiddle patches into InFirst and InLast -- patches into InMiddle. Does *not* pull dependencies into -- InFirst, instead patches that cannot be commuted past -- InLast patches stay InMiddle. makeEverythingSooner :: forall p wX wY. Commute p => PatchChoices p wX wY -> PatchChoices p wX wY -- | Turn InFirst patches into InMiddle ones and -- InMiddle into InLast ones. makeEverythingLater :: PatchChoices p wX wY -> PatchChoices p wX wY -- | Make all InMiddle patches either InFirst or -- InLast. This does *not* modify any patches that are already -- determined to be InLast by dependencies. selectAllMiddles :: forall p wX wY. Commute p => Bool -> PatchChoices p wX wY -> PatchChoices p wX wY -- | Use the given monadic PatchChoices transformer on the -- InMiddle section of a PatchChoices, then fold the result -- back into the original PatchChoices. 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 LabelledPatch with an equivalent list of -- patches, preserving its status as InFirst, InMiddle or -- InLast). The patch is looked up using equality of -- Labels. substitute :: forall p wX wY. Sealed2 (LabelledPatch p :||: FL (LabelledPatch p)) -> PatchChoices p wX wY -> PatchChoices p wX wY -- | A patch with a Label attached to it. data LabelledPatch p wX wY -- | Label mp i 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 Label mp i. The -- i is an integer, expected to be unique within the patches -- being scrutinised. The mp 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 Label -- Nothing 5, the resulting sub-patches could be identified as -- Label (Just (Label Nothing 5))1, Label (Just (Label -- Nothing 5)) 2, etc. -- -- IOW, Label is a non-empty, reversed list of Ints. 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.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 -- | This is used to track changes to files data PatchMod a PTouch :: a -> PatchMod a PCreateFile :: a -> PatchMod a PCreateDir :: a -> PatchMod a PRename :: a -> a -> PatchMod a PRemove :: a -> PatchMod a -- | This is an invalid patch e.g. there is a patch 'Move Autoconf.lhs -- Autoconf.lhs.in' where there is no Autoconf.lhs in the darcs repo PInvalid :: a -> PatchMod a -- | this is used for duplicate patches that don't have any effect, but we -- still want to keep track of them PDuplicateTouch :: a -> PatchMod a short :: PatchId -> Word32 zero :: PatchId instance GHC.Base.Functor Darcs.Patch.Index.Types.PatchMod instance GHC.Classes.Eq a => GHC.Classes.Eq (Darcs.Patch.Index.Types.PatchMod a) instance GHC.Show.Show a => GHC.Show.Show (Darcs.Patch.Index.Types.PatchMod a) 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 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 Data.Binary.Class.Binary Darcs.Patch.Index.Types.FileId module Darcs.Patch.ApplyMonad class (Monad m, Monad (ApplyMonadBase m), ApplyMonadStateOperations state m, ToTree state) => ApplyMonad (state :: (* -> *) -> *) m where { type family ApplyMonadBase m :: * -> *; } nestedApply :: ApplyMonad state m => m x -> state (ApplyMonadBase m) -> m (x, state (ApplyMonadBase m)) liftApply :: ApplyMonad state m => (state (ApplyMonadBase m) -> ApplyMonadBase m x) -> state (ApplyMonadBase m) -> m (x, state (ApplyMonadBase m)) getApplyState :: ApplyMonad state m => m (state (ApplyMonadBase m)) class (Monad m, ApplyMonad state (ApplyMonadOver state m)) => ApplyMonadTrans (state :: (* -> *) -> *) m where { type family ApplyMonadOver state m :: * -> *; } runApplyMonad :: ApplyMonadTrans state m => ApplyMonadOver state m x -> state m -> m (x, state m) class ApplyMonadState (state :: (* -> *) -> *) where { type family ApplyMonadStateOperations 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 withFiles :: [(AnchoredPath, ByteString)] -> RestrictedApply a -> [(AnchoredPath, ByteString)] class ToTree s toTree :: ToTree s => s m -> Tree m class Monad 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 () instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Patch.ApplyMonad.RestrictedApply instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Patch.ApplyMonad.RestrictedApply instance Darcs.Patch.MonadProgress.MonadProgress Darcs.Patch.ApplyMonad.RestrictedApply instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Patch.ApplyMonad.FilePathMonad instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Patch.ApplyMonad.FilePathMonad instance Darcs.Patch.MonadProgress.MonadProgress Darcs.Patch.ApplyMonad.FilePathMonad instance GHC.Base.Monad m => Darcs.Patch.ApplyMonad.ApplyMonadTrans Darcs.Util.Tree.Tree m instance GHC.Base.Monad m => Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree (Darcs.Util.Tree.Monad.TreeMonad m) instance Darcs.Patch.ApplyMonad.ApplyMonadState Darcs.Util.Tree.Tree instance GHC.Base.Monad m => Darcs.Patch.ApplyMonad.ApplyMonadTree (Darcs.Util.Tree.Monad.TreeMonad m) instance Darcs.Patch.ApplyMonad.ToTree Darcs.Util.Tree.Tree module Darcs.Patch.Apply class Apply p where { type family 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 () applyToPaths :: (Apply p, ApplyState p ~ Tree) => p wX wY -> Maybe [(AnchoredPath, AnchoredPath)] -> [AnchoredPath] -> ([AnchoredPath], [AnchoredPath], [(AnchoredPath, AnchoredPath)]) -- | Apply a patch to a Tree, yielding a new Tree. applyToTree :: (Apply p, Monad 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) => p wX wY -> Tree IO -> IO (Maybe (Tree IO)) 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 description and content are -- suitable only for PrimPatch and RepoPatch types. -- Logically, description should default to mempty while -- content should default to displayPatch. We define them -- the other way around so that showFriendly 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 -- | showContextPatch is used to add context to a patch, 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 -- tree. showContextPatch :: (ShowContextPatch p, ApplyMonad (ApplyState p) m) => ShowPatchFor -> p wX wY -> m Doc -- | Format a AnchoredPath to a Doc according to the given -- FileNameFormat. -- -- 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 -- writePatchIfNecessary. -- -- Besides white space encoding, for FileNameFormatV2 we just pack -- it into a Doc. For FileNameFormatV1 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 readFileName. 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. -- -- _piLegacyIsInverted: -- -- Historically, the isInverted flag was used to indicate that a -- Named patch was inverted. -- -- We no longer support direct inversion of Named patches, except -- sometimes via the Invertible wrapper which tracks inversion in -- the wrapper. -- -- However, going even further back in time, inverted patches could be -- written out by darcs rollback. 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 PatchInfo apart from never being set -- freshly: -- -- -- -- The flag is completely separate and orthogonal to the tracking of -- explicit inversion in the Invertible wrapper. The -- Invertible 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 -- | patchinfo date name author log constructs a new -- PatchInfo 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 PatchInfo as stored in patch bundles and inventory -- files, for example: -- --
--   [Document the foo interface
--   John Doe <john.doe@example.com>**20110615084241
--    Ignore-this: 85b94f67d377c4ab671101266ef9c229
--    Nobody knows what a 'foo' is, so describe it.
--   ]
--   
-- -- See showPatchInfo 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 justName, 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.Classes.Ord Darcs.Patch.Info.PatchInfo instance GHC.Classes.Eq Darcs.Patch.Info.PatchInfo instance GHC.Show.Show Darcs.Patch.Info.PatchInfo module Darcs.Repository.Inventory data Inventory Inventory :: Maybe InventoryHash -> [InventoryEntry] -> Inventory [inventoryParent] :: Inventory -> Maybe InventoryHash [inventoryPatches] :: Inventory -> [InventoryEntry] type HeadInventory = (PristineHash, Inventory) type InventoryEntry = (PatchInfo, PatchHash) class ValidHash a getValidHash :: ValidHash a => a -> String mkValidHash :: ValidHash a => String -> a 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 -- HeadInventory 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.Inventory instance GHC.Classes.Eq Darcs.Repository.Inventory.Inventory instance GHC.Show.Show Darcs.Repository.Inventory.PristineHash instance GHC.Classes.Eq Darcs.Repository.Inventory.PristineHash instance GHC.Show.Show Darcs.Repository.Inventory.PatchHash instance GHC.Classes.Eq Darcs.Repository.Inventory.PatchHash instance GHC.Show.Show Darcs.Repository.Inventory.InventoryHash instance GHC.Classes.Eq Darcs.Repository.Inventory.InventoryHash instance Darcs.Repository.Inventory.ValidHash Darcs.Repository.Inventory.PristineHash instance Darcs.Repository.Inventory.ValidHash Darcs.Repository.Inventory.PatchHash instance Darcs.Repository.Inventory.ValidHash Darcs.Repository.Inventory.InventoryHash module Darcs.Repository.HashedIO -- | Grab a whole pristine tree from a hash, and, if asked, write files in -- the working tree. copyHashed :: ProgressKey -> Cache -> WithWorkingDir -> PristineHash -> IO () copyPartialsHashed :: Cache -> PristineHash -> [AnchoredPath] -> IO () cleanHashdir :: Cache -> HashedDir -> [PristineHash] -> IO () -- | getHashedFiles returns all hash files targeted by files in hashroots -- in the hashdir directory. getHashedFiles :: FilePath -> [String] -> IO [String] -- | Returns a list of pairs (FilePath, (strict) ByteString) of the -- pristine tree starting with the hash root. path -- should be either "." or end with "/" Separator "/" is used since this -- function is used to generate zip archives from pristine trees. pathsAndContents :: FilePath -> Cache -> PristineHash -> IO [(FilePath, ByteString)] instance GHC.Classes.Eq Darcs.Repository.HashedIO.ObjType instance Darcs.Patch.ApplyMonad.ApplyMonadTree Darcs.Repository.HashedIO.HashedIO instance Darcs.Patch.ApplyMonad.ApplyMonad Darcs.Util.Tree.Tree Darcs.Repository.HashedIO.HashedIO module Darcs.Patch.Ident -- | Class of patches that have an identity. -- -- It generalizes named prim patches a la camp (see -- Darcs.Patch.Prim.Named) and Named patches i.e. those with a PatchInfo. -- -- Patch identity should be invariant under commutation: if there is also -- an instance Commute p, then -- --
--   commute (p :> q) == Just (q' :> p') => ident p == ident p' && ident q == ident q'
--   
-- -- The converse should also be true: patches with the same identity can -- be commuted (back) to the same context and then compare equal. -- Assuming -- --
--   p :: p wX wY, (ps :> q) :: (RL p :> p) wX wZ
--   
-- -- then -- --
--   ident p == ident q => commuteRL (ps :> q) == Just (p :> _)
--   
-- -- As a special case we get that parallel patches with the same identity -- are equal: if p :: p wX wY, q :: p wX wZ, then -- --
--   ident p == ident q => p =\/= q == IsEq
--   
-- -- In general, comparing patches via their identity is coarser than -- (structural) equality, so we only have -- --
--   unsafeCompare p q => (ident p == ident q)
--   
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 Invert exists, inverting a patch -- inverts its identity: -- --
--   ident (invert p) = invertId (ident p)
--   
type SignedIdent p = (Ident p, SignedId (PatchId p)) type family PatchId (p :: * -> * -> *) -- | Signed identities. -- -- Like for class Invert, we require that invertId is -- self-inverse: -- --
--   invertId . invertId = id
--   
-- -- We also require that inverting changes the sign: -- --
--   positiveId . invertId = not . positiveId
--   
-- -- Side remark: in mathematical terms, these properties can be expressed -- by stating that invertId is an involution and that -- positiveId is a "homomorphism of sets with an involution" -- (there is no official term for this) from a to the simplest -- non-trivial set with involution, namely Bool with the -- involution not. 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 showId -- ForStorage a can be parsed by readId to produce -- a. class StorableId a readId :: StorableId a => Parser a showId :: StorableId a => ShowPatchFor -> a -> Doc -- | Faster equality tests for patches with an identity. class IdEq2 p (=\^/=) :: IdEq2 p => p wA wB -> p wA wC -> EqCheck wB wC (=/^\=) :: IdEq2 p => p wA wC -> p wB wC -> EqCheck wA wB (=\^/=) :: (IdEq2 p, Ident p) => p wA wB -> p wA wC -> EqCheck wB wC (=/^\=) :: (IdEq2 p, Ident p) => p wA wC -> p wB wC -> EqCheck wA wB -- | This function is similar to merge, but with one important -- difference: merge works on patches for which there is not -- necessarily a concept of identity (e.g. primitive patches, -- conflictors, etc). Thus it does not even try to recognize patches that -- are common to both sequences. Instead these are passed on to the Merge -- instance for single patches. This instance may handle duplicate -- patches by creating special patches (Duplicate, Conflictor). -- -- We do not want this to happen for named patches, or in general for -- patches with an identity. Instead, we want to discard one of -- the two duplicates, retaining only one copy. This is done by the -- fastRemoveFL calls below. We call mergeFL only after we have ensured -- that the head of the left hand side does not occur in the right hand -- side. merge2FL :: (Commute p, Merge p, Ident p) => FL p wX wY -> FL p wX wZ -> (FL p :/\: FL p) wY wZ -- | Remove a patch from an FL of patches with an identity. The result is -- Just whenever the patch has been found and removed and -- Nothing 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. fastRemoveFL :: forall p wX wY wZ. (Commute p, Ident p) => p wX wY -> FL p wX wZ -> Maybe (FL p wY wZ) -- | Same as fastRemoveFL only for RL. 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, similar to -- merge2FL. findCommonFL :: (Commute p, Ident p) => FL p wX wY -> FL p wX wZ -> Fork (FL p) (FL p) (FL p) wX wY wZ -- | Try to commute patches matching any of the PatchIds in the set -- to the head of an FL, i.e. backwards in history. It is not -- required that all the PatchIds are found in the sequence, but -- if they do then the traversal terminates as soon as the set is -- exhausted. commuteToPrefix :: (Commute p, Ident p) => Set (PatchId p) -> FL p wX wY -> Maybe ((FL p :> RL p) wX wY) -- | Try to commute patches matching any of the PatchIds in the set -- to the head of an RL, i.e. forwards in history. It is not -- required that all the PatchIds are found in the sequence, but -- if they do then the traversal terminates as soon as the set is -- exhausted. commuteToPostfix :: forall p wX wY. (Commute p, Ident p) => Set (PatchId p) -> RL p wX wY -> Maybe ((FL p :> RL p) wX wY) -- | Like commuteToPostfix but drag dependencies with us. commuteWhatWeCanToPostfix :: forall p wX wY. (Commute p, Ident p) => Set (PatchId p) -> RL p wX wY -> (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 :\/: p) wX wY -> Maybe Bool instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Ident.Ident p) => Darcs.Patch.Ident.IdEq2 (Darcs.Patch.Witnesses.Ordered.FL p) module Darcs.Patch.FileHunk data FileHunk wX wY FileHunk :: !AnchoredPath -> !Int -> [ByteString] -> [ByteString] -> FileHunk wX wY class IsHunk p isHunk :: IsHunk p => p wX wY -> Maybe (FileHunk wX wY) showFileHunk :: FileNameFormat -> FileHunk wX wY -> Doc instance Darcs.Patch.Invert.Invert Darcs.Patch.FileHunk.FileHunk module Darcs.Patch.Viewing showContextHunk :: ApplyMonad Tree m => FileNameFormat -> FileHunk 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.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.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) 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 :: 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) -- | Contexted 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 Contexted patch but -- still guard against violation of teh invariants. So we export a view -- that is isomorphic to the Contexted type but doesn't allow to -- manipulate the internals. ctxView :: Contexted p wX -> Sealed ((FL p :> p) wX) -- | Contexted 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 Contexted patch into a plain FL with the patch -- at the end. ctxToFL :: Contexted p wX -> Sealed (FL p wX) -- | A Contexted patch with empty context. ctx :: p wX wY -> Contexted p wX -- | Add a patch to the context of a Contexted 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 RL of patches to the context. ctxAddRL :: (Commute p, Invert p, Ident p) => RL p wX wY -> Contexted p wY -> Contexted p wX -- | Add an FL 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 FL 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 Contexted 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 not succeed if the inverted patch is in the -- Contexted 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 Contexted patch and that the context never contains -- a patch and its inverse. prop_ctxInvariants :: (Commute p, Invert p, SignedIdent p) => Contexted p wX -> Bool 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 Contexted -- patch as well as the patch itself are positive. It does not -- necessarily hold for all Contexted 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.Repair -- | Repair and RepairToFL deal with repairing old patches -- that were were written out due to bugs or that we no longer wish to -- support. Repair 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)) -- | RepairToFL 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.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 wX wY -> prim wX wY class PrimCanonize prim -- | tryToShrink ps simplifies ps by getting rid of -- self-cancellations or coalescing patches -- -- Question (Eric Kow): what properties should this have? For example, -- the prim1 implementation only gets rid of the first self-cancellation -- it finds (as far as I can tell). Is that OK? Can we try harder? tryToShrink :: PrimCanonize prim => FL prim wX wY -> FL prim wX wY -- | sortCoalesceFL ps coalesces as many patches in -- ps as possible, sorting the results in some standard order. sortCoalesceFL :: PrimCanonize prim => FL prim wX wY -> FL prim wX wY -- | It can sometimes be handy to have a canonical representation of a -- given patch. We achieve this by defining a canonical form for each -- patch type, and a function canonize which takes a patch and -- puts it into canonical form. This routine is used by the diff function -- to create an optimal patch (based on an LCS algorithm) from a simple -- hunk describing the old and new version of a file. canonize :: PrimCanonize prim => DiffAlgorithm -> prim wX wY -> FL prim wX wY -- | canonizeFL ps puts 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. -- -- Note that this process does not preserve the commutation behaviour of -- the patches and is therefore not appropriate for use when working with -- already recorded patches (unless doing amend-record or the like). canonizeFL :: PrimCanonize prim => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY -- | Either primCoalesce or cancel inverses. -- --
--   primCoalesce (p :> q) == Just r => apply r = apply p >> apply q
--   
-- --
--   primCoalesce (p :> q) == Just r => lengthFL r < 2
--   
coalesce :: PrimCanonize prim => (prim :> prim) wX wY -> Maybe (FL prim wX wY) -- | Coalesce adjacent patches to one with the same effect. -- --
--   apply (primCoalesce p q) == apply p >> apply q
--   
primCoalesce :: PrimCanonize prim => prim wX wY -> prim wY wZ -> Maybe (prim wX wZ) -- | If primCoalesce is addition, then this is subtraction. -- --
--   Just r == primCoalesce p q => primDecoalesce r p == Just q
--   
primDecoalesce :: PrimCanonize prim => prim wX wZ -> prim wX wY -> Maybe (prim wY wZ) class PrimClassify prim primIsAddfile :: PrimClassify prim => prim wX wY -> Bool primIsRmfile :: PrimClassify prim => prim wX wY -> Bool primIsAdddir :: PrimClassify prim => prim wX wY -> Bool primIsRmdir :: PrimClassify prim => prim wX wY -> Bool primIsMove :: PrimClassify prim => prim wX wY -> Bool primIsHunk :: PrimClassify prim => prim wX wY -> Bool primIsTokReplace :: PrimClassify prim => prim wX wY -> Bool primIsBinary :: PrimClassify prim => prim wX wY -> Bool primIsSetpref :: PrimClassify prim => prim wX wY -> Bool is_filepatch :: PrimClassify prim => prim wX wY -> Maybe AnchoredPath class PrimDetails prim summarizePrim :: PrimDetails prim => prim wX wY -> [SummDetail] class PrimSift prim -- | siftForPending ps simplifies the candidate pending patch -- ps through a combination of looking for self-cancellations -- (sequences of patches followed by their inverses), coalescing, and -- getting rid of any hunk/binary patches we can commute out the back -- -- The visual image of sifting can be quite helpful here. We are -- repeatedly tapping (shrinking) the patch sequence and shaking it -- (sift). Whatever falls out is the pending we want to keep. We do this -- until the sequence looks about as clean as we can get it siftForPending :: PrimSift prim => FL prim wX wY -> Sealed (FL prim wX) class PrimShow prim showPrim :: PrimShow prim => FileNameFormat -> prim wA wB -> Doc showPrimCtx :: (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 = (Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCanonize prim, PrimClassify 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 isIdentity :: Prim wX wY -> EqCheck wX wY -- | comparePrim p1 p2 is used to provide an arbitrary -- ordering between p1 and p2. Basically, identical -- patches are equal and Move < DP < FP < ChangePref. -- Everything else is compared in dictionary order of its arguments. comparePrim :: Prim wX wY -> Prim wW wZ -> Ordering 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 GHC.Classes.Ord (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY) instance GHC.Classes.Eq (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY) instance Darcs.Patch.Prim.Class.PrimClassify Darcs.Patch.Prim.V1.Core.Prim instance Darcs.Patch.Prim.Class.PrimConstruct Darcs.Patch.Prim.V1.Core.Prim instance 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.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.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.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.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 GHC.Show.Show (Darcs.Patch.Prim.V1.Core.FilePatchType wX wY) instance (Darcs.Patch.Apply.ApplyState Darcs.Patch.Prim.V1.Core.Prim Data.Type.Equality.~ Darcs.Util.Tree.Tree) => Darcs.Patch.Prim.Class.PrimShow Darcs.Patch.Prim.V1.Core.Prim module Darcs.Patch.Prim.V1.Commute data Perhaps a Unknown :: Perhaps a Failed :: Perhaps a Succeeded :: a -> Perhaps a toPerhaps :: Maybe a -> Perhaps a type CommuteFunction = forall wX wY. (Prim :> Prim) wX wY -> Perhaps ((Prim :> Prim) wX wY) speedyCommute :: CommuteFunction cleverCommute :: CommuteFunction -> CommuteFunction commuteFiledir :: CommuteFunction commuteFilepatches :: CommuteFunction 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.Coalesce instance GHC.Show.Show (Darcs.Patch.Prim.V1.Coalesce.Simple wX wY) instance Darcs.Patch.Prim.Class.PrimCanonize 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 data Prim wX wY instance Darcs.Patch.Prim.Class.PrimSift 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 Blob :: m FileContent -> !Hash -> Object newtype UUID UUID :: ByteString -> UUID -- | An object is located by giving the UUID of the parent -- Directory and a Name. data Location L :: !UUID -> !Name -> Location data Name type FileContent = ByteString 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.Show.Show (Darcs.Patch.Prim.FileUUID.Core.Hunk wX wY) instance GHC.Classes.Eq (Darcs.Patch.Prim.FileUUID.Core.Hunk 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.PrimClassify 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.PrimCanonize Darcs.Patch.Prim.FileUUID.Core.Prim instance Darcs.Patch.Prim.Class.PrimSift Darcs.Patch.Prim.FileUUID.Core.Prim module Darcs.Patch.Prim class PrimApply prim applyPrimFL :: (PrimApply prim, ApplyMonad (ApplyState prim) m) => FL prim wX wY -> m () class PrimCanonize prim -- | tryToShrink ps simplifies ps by getting rid of -- self-cancellations or coalescing patches -- -- Question (Eric Kow): what properties should this have? For example, -- the prim1 implementation only gets rid of the first self-cancellation -- it finds (as far as I can tell). Is that OK? Can we try harder? tryToShrink :: PrimCanonize prim => FL prim wX wY -> FL prim wX wY -- | sortCoalesceFL ps coalesces as many patches in -- ps as possible, sorting the results in some standard order. sortCoalesceFL :: PrimCanonize prim => FL prim wX wY -> FL prim wX wY -- | It can sometimes be handy to have a canonical representation of a -- given patch. We achieve this by defining a canonical form for each -- patch type, and a function canonize which takes a patch and -- puts it into canonical form. This routine is used by the diff function -- to create an optimal patch (based on an LCS algorithm) from a simple -- hunk describing the old and new version of a file. canonize :: PrimCanonize prim => DiffAlgorithm -> prim wX wY -> FL prim wX wY -- | canonizeFL ps puts 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. -- -- Note that this process does not preserve the commutation behaviour of -- the patches and is therefore not appropriate for use when working with -- already recorded patches (unless doing amend-record or the like). canonizeFL :: PrimCanonize prim => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY -- | Either primCoalesce or cancel inverses. -- --
--   primCoalesce (p :> q) == Just r => apply r = apply p >> apply q
--   
-- --
--   primCoalesce (p :> q) == Just r => lengthFL r < 2
--   
coalesce :: PrimCanonize prim => (prim :> prim) wX wY -> Maybe (FL prim wX wY) -- | Coalesce adjacent patches to one with the same effect. -- --
--   apply (primCoalesce p q) == apply p >> apply q
--   
primCoalesce :: PrimCanonize prim => prim wX wY -> prim wY wZ -> Maybe (prim wX wZ) -- | If primCoalesce is addition, then this is subtraction. -- --
--   Just r == primCoalesce p q => primDecoalesce r p == Just q
--   
primDecoalesce :: PrimCanonize prim => prim wX wZ -> prim wX wY -> Maybe (prim wY wZ) class PrimClassify prim primIsAddfile :: PrimClassify prim => prim wX wY -> Bool primIsRmfile :: PrimClassify prim => prim wX wY -> Bool primIsAdddir :: PrimClassify prim => prim wX wY -> Bool primIsRmdir :: PrimClassify prim => prim wX wY -> Bool primIsMove :: PrimClassify prim => prim wX wY -> Bool primIsHunk :: PrimClassify prim => prim wX wY -> Bool primIsTokReplace :: PrimClassify prim => prim wX wY -> Bool primIsBinary :: PrimClassify prim => prim wX wY -> Bool primIsSetpref :: PrimClassify prim => prim wX wY -> Bool is_filepatch :: PrimClassify prim => prim wX wY -> Maybe AnchoredPath 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 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 = (Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCanonize prim, PrimClassify 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 showPrimCtx :: (PrimShow prim, ApplyMonad (ApplyState prim) m) => FileNameFormat -> prim wA wB -> m Doc class PrimSift prim -- | siftForPending ps simplifies the candidate pending patch -- ps through a combination of looking for self-cancellations -- (sequences of patches followed by their inverses), coalescing, and -- getting rid of any hunk/binary patches we can commute out the back -- -- The visual image of sifting can be quite helpful here. We are -- repeatedly tapping (shrinking) the patch sequence and shaking it -- (sift). Whatever falls out is the pending we want to keep. We do this -- until the sequence looks about as clean as we can get it siftForPending :: PrimSift prim => FL prim wX wY -> Sealed (FL 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)] 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 family 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 Merger undos unwindings conflicting -- original. -- -- undos = the effect of the merger -- -- unwindings = TODO: eh? -- -- conflicting = the patch we conflict with -- -- original = 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 Unwound 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 Named. 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 ConflictState and also hides the -- context witnesses (as in Sealed2), 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.Classes.Eq Darcs.Patch.Summary.SummChunk instance GHC.Classes.Ord Darcs.Patch.Summary.SummChunk 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 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.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 -> FileContent data ObjectMap (m :: * -> *) ObjectMap :: (UUID -> m (Maybe (Object m))) -> (UUID -> Object m -> m (ObjectMap m)) -> m [UUID] -> ObjectMap [getObject] :: ObjectMap -> UUID -> m (Maybe (Object m)) [putObject] :: ObjectMap -> UUID -> Object m -> m (ObjectMap m) [listObjects] :: ObjectMap -> m [UUID] instance Darcs.Patch.Apply.Apply Darcs.Patch.Prim.FileUUID.Core.Prim instance Darcs.Patch.ApplyMonad.ApplyMonadState Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap instance GHC.Base.Monad 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 Darcs.Patch.ApplyMonad.ToTree Darcs.Patch.Prim.FileUUID.ObjectMap.ObjectMap instance GHC.Base.Monad 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 GHC.Base.Monad 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 effect or -- effectRL. 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 Non stores a context with a Prim 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 -- | commuteOrAddToCtx x cy tries to commute x -- past cy and always returns some variant cy'. If -- commutation suceeds, the variant is just straightforwardly the -- commuted version. If commutation fails, the variant consists of -- x prepended to the context of cy. 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) -- | commuteOrAddToCtxRL xs cy commutes as many patches of -- xs past cy as possible, adding any that don't -- commute to the context of cy. Suppose we have -- --
--   x1 x2 x3 [c1 c2 y]
--   
-- -- and that in our example x1 fails to commute past c1, -- this function would commute down to -- --
--   x1 [c1'' c2'' y''] x2' x3'
--   
-- -- and return [x1 c1'' c2'' y''] 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 -- | (*>) 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) -- | (>*) 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) -- | (*>>) 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) -- | (>>*) 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 -- | 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 FL -- 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)] 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 RL 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 -- commuteNoConflictsFL 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] module Darcs.Patch.V2.RepoPatch -- | RepoPatchV2 is used to represents prim patches that are -- duplicates of, or conflict with, another prim patch in the repository. -- -- Normal prim: A primitive patch -- -- Duplicate x: This patch has no effect since x is -- already present in the repository. -- --
--   Etacilpud x: invert (Duplicate x)
--   
-- -- Conflictor ix xx x: ix is the set of patches: * that -- conflict with x and also conflict with another patch in the -- repository. * that conflict with a patch that conflict with x -- -- xx is the sequence of patches that conflict *only* with -- x -- -- x is the original, conflicting patch. -- -- ix and x are stored as Non 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 x conflicts with, that haven't already been -- undone by another Conflictor in the repository. Therefore, the effect -- of a Conflictor is invert xx. -- -- InvConflictor ix xx x: like invert (Conflictor ix xx -- x) 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 -- | isForward p is True if p is either -- an InvConflictor or Etacilpud. isForward :: PrimPatch prim => RepoPatchV2 prim wS wY -> Maybe Doc -- | isDuplicate p is True if p is either -- a Duplicate or Etacilpud patch. isDuplicate :: RepoPatchV2 prim wS wY -> Bool -- | mergeUnravelled 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.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. p1 is -- considered to be conflicting with p2 (p1 is the -- "first" patch in the repo ordering), the resulting Merger is therefore -- a representation of p2. 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.FileHunk.IsHunk 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.Named -- | The Named type adds a patch info about a patch, that is a -- name. -- -- NamedP info deps p represents patch p with name -- info. deps is a list of dependencies added at the -- named patch level, compared with the unnamed level (ie, dependencies -- added with darcs record --ask-deps). 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 anonymous :: FromPrim p => FL (PrimOf p) wX wY -> IO (Named p wX wY) -- | This slightly ad-hoc class is here so we can call getdeps with -- patch types that wrap a Named, such as RebaseChange. 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 showDependencies :: ShowDepsFormat -> [PatchInfo] -> Doc instance GHC.Classes.Eq Darcs.Patch.Named.ShowDepsFormat instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Named.Named p wX wY) 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.Ident.IdEq2 (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.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.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.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 RebaseName 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 RebaseName 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 RebaseName. 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 :: (PrimPatch (PrimOf p), 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 -- | Hopefully p C (x y) is Either -- String (p C (x y)) in a form adapted to darcs patches. -- The C (x y) represents the type witness for the -- patch that should be there. The Hopefully type just tells -- whether we expect the patch to be hashed or not, and -- SimpleHopefully does the real work of emulating Either. -- Hopefully sh represents an expected unhashed patch, and -- Hashed hash sh represents an expected hashed patch with its -- hash. data Hopefully a wX wY type PatchInfoAnd rt p = PatchInfoAndG rt (Named p) -- | PatchInfoAnd p wA wB 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 (rt :: RepoType) p wA wB -- | WPatchInfo wA wB represents the info of a patch, -- marked with the patch's witnesses. data WPatchInfo wA wB unWPatchInfo :: WPatchInfo wA wB -> PatchInfo compareWPatchInfo :: WPatchInfo wA wB -> WPatchInfo wC wD -> EqCheck (wA, wB) (wC, wD) -- | piap i p creates a PatchInfoAnd containing p with info -- i. piap :: PatchInfo -> p wA wB -> PatchInfoAndG rt p wA wB -- | n2pia creates a PatchInfoAnd representing a Named -- patch. n2pia :: (Ident p, PatchId p ~ PatchInfo) => p wX wY -> PatchInfoAndG rt p wX wY patchInfoAndPatch :: PatchInfo -> Hopefully p wA wB -> PatchInfoAndG rt p wA wB fmapPIAP :: (p wX wY -> q wX wY) -> PatchInfoAndG rt p wX wY -> PatchInfoAndG rt q wX wY fmapFLPIAP :: (FL p wX wY -> FL q wX wY) -> PatchInfoAnd rt p wX wY -> PatchInfoAnd rt q wX wY -- | conscientiously er hp tries to extract a patch from a -- PatchInfoAnd. If it fails, it applies the error handling -- function er to a description of the patch info component of -- hp. Note: this function must be lazy in its second argument, -- which is why we use a lazy pattern match. conscientiously :: (Doc -> Doc) -> PatchInfoAndG rt p wA wB -> p wA wB -- | hopefully hp tries to get a patch from a -- PatchInfoAnd value. If it fails, it outputs an error "failed to -- read patch: <description of the patch>". We get the description -- of the patch from the info part of hp hopefully :: PatchInfoAndG rt p wA wB -> p wA wB info :: PatchInfoAndG rt p wA wB -> PatchInfo winfo :: PatchInfoAnd rt p wA wB -> WPatchInfo wA wB -- | hopefullyM is a version of hopefully which calls -- fail in a monad instead of erroring. hopefullyM :: PatchInfoAndG rt p wA wB -> Maybe (p wA wB) createHashed :: String -> (String -> IO (Sealed (a wX))) -> IO (Sealed (Hopefully a wX)) extractHash :: PatchInfoAndG rt p wA wB -> Either (p wA wB) String actually :: a wX wY -> Hopefully a wX wY unavailable :: String -> Hopefully a wX wY patchDesc :: forall rt p wX wY. PatchInfoAnd rt p wX wY -> String instance GHC.Show.Show (p wA wB) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p wA wB) instance GHC.Show.Show (a wX wY) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.Hopefully a wX wY) instance GHC.Show.Show (a wX wY) => GHC.Show.Show (Darcs.Patch.PatchInfoAnd.SimpleHopefully a wX wY) instance GHC.Exception.Type.Exception Darcs.Patch.PatchInfoAnd.PatchNotAvailable instance GHC.Show.Show Darcs.Patch.PatchInfoAnd.PatchNotAvailable instance Darcs.Patch.Witnesses.Eq.Eq2 Darcs.Patch.PatchInfoAnd.WPatchInfo instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.PatchInfoAnd.PatchInfoAnd rt p wX) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.PatchInfoAnd.PatchInfoAnd rt p) instance Darcs.Patch.Repair.RepairToFL p => Darcs.Patch.Repair.Repair (Darcs.Patch.PatchInfoAnd.PatchInfoAnd rt p) instance (Darcs.Patch.Commute.Commute p, Darcs.Patch.Conflict.Conflict p) => Darcs.Patch.Conflict.Conflict (Darcs.Patch.PatchInfoAnd.PatchInfoAnd rt p) instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Witnesses.Eq.Eq2 (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Ident.Ident (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Ident.IdEq2 (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Show.ShowPatchBasic p => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Show.ShowContextPatch p => Darcs.Patch.Show.ShowContextPatch (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt 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 rt p) instance (Darcs.Patch.Ident.PatchId p Data.Type.Equality.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Commute.Commute p) => Darcs.Patch.Commute.Commute (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance (Darcs.Patch.Ident.PatchId p Data.Type.Equality.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Merge.CleanMerge p) => Darcs.Patch.Merge.CleanMerge (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance (Darcs.Patch.Ident.PatchId p Data.Type.Equality.~ Darcs.Patch.Info.PatchInfo, Darcs.Patch.Merge.Merge p) => Darcs.Patch.Merge.Merge (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Inspect.PatchInspect p => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Ident.Ident p, Darcs.Patch.Ident.PatchId p Data.Type.Equality.~ Darcs.Patch.Info.PatchInfo) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Effect.Effect p => Darcs.Patch.Effect.Effect (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.FileHunk.IsHunk (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt p) instance Darcs.Patch.Debug.PatchDebug p => Darcs.Patch.Debug.PatchDebug (Darcs.Patch.PatchInfoAnd.PatchInfoAndG rt 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 PatchSet 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 -- PatchSet contains the whole history, the first witness is -- always forced to be Origin. The type still has two witnesses so -- it can easily be used with combinators like :> and -- Fork. -- -- The history is lazily loaded from disk so does not normally need to be -- all kept in memory. data PatchSet rt p wStart wY [PatchSet] :: RL (Tagged rt p) Origin wX -> RL (PatchInfoAnd rt p) wX wY -> PatchSet rt p Origin wY -- | A Tagged is a single chunk of a PatchSet. It has a -- PatchInfo representing a clean tag, the hash of the previous -- inventory (if it exists), and the list of patches since that previous -- inventory. data Tagged rt p wX wZ [Tagged] :: PatchInfoAnd rt p wY wZ -> Maybe String -> RL (PatchInfoAnd rt p) wX wY -> Tagged rt p wX wZ type SealedPatchSet rt p wStart = Sealed ((PatchSet rt p) wStart) -- | Origin 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 rt p wStart wX -> PatchSet rt p wStart wX -- | The tag names of all tags of a given PatchSet. patchSetTags :: PatchSet rt p wX wY -> [String] emptyPatchSet :: PatchSet rt p Origin Origin -- | appendPSFL takes a PatchSet and a FL of patches -- that "follow" the PatchSet, and concatenates the patches into the -- PatchSet. appendPSFL :: PatchSet rt p wStart wX -> FL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY -- | patchSet2RL takes a PatchSet and returns an equivalent, -- linear RL of patches. patchSet2RL :: PatchSet rt p wStart wX -> RL (PatchInfoAnd rt p) wStart wX -- | patchSet2FL takes a PatchSet and returns an equivalent, -- linear FL of patches. patchSet2FL :: PatchSet rt p wStart wX -> FL (PatchInfoAnd rt p) wStart wX inOrderTags :: PatchSet rt p wS wX -> [PatchInfo] patchSetSnoc :: PatchSet rt p wX wY -> PatchInfoAnd rt p wY wZ -> PatchSet rt p wX wZ -- | Split a PatchSet before 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 rt p wX wY -> (PatchSet rt p :> RL (PatchInfoAnd rt p)) wX wY -- | Drop the last n patches from the given PatchSet. patchSetDrop :: Int -> PatchSet rt p wStart wX -> SealedPatchSet rt p wStart instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Set.PatchSet rt p wStart wY) instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Set.Tagged rt p wX wZ) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Set.PatchSet rt p wStart) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Set.PatchSet rt p) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Set.Tagged rt p wX) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Set.Tagged rt p) module Darcs.Patch.Progress -- | Evaluate an RL list and report progress. progressRL :: String -> RL a wX wY -> RL a wX wY -- | Evaluate an FL list and report progress. progressFL :: String -> FL a wX wY -> FL a wX wY -- | Evaluate an RL 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 rt p) wX wY -> RL (PatchInfoAnd rt p) wX wY -- | Definitions used in this module: -- -- module Darcs.Patch.Depends -- | Return the PatchInfo for all the patches in a PatchSet -- that are not depended on by any tag (in the given PatchSet). -- -- This is exactly the set of patches that a new tag recorded on top of -- the PatchSet would explicitly depend on. getUncovered :: PatchSet rt p wStart wX -> [PatchInfo] areUnrelatedRepos :: Commute p => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> Bool findCommonAndUncommon :: forall rt p wX wY. Commute p => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wX wY mergeThem :: (Commute p, Merge p) => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> Sealed (FL (PatchInfoAnd rt p) wX) findCommonWithThem :: Commute p => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> (PatchSet rt p :> FL (PatchInfoAnd rt p)) Origin wX countUsThem :: Commute p => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> (Int, Int) removeFromPatchSet :: (Commute p, Eq2 p) => FL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY -> Maybe (PatchSet rt p wStart wX) -- | Create a new Tagged section for the most recent clean tag found -- in the tail of un-Tagged patches without re-ordering patches. -- Note that earlier tags may remain un-Tagged even if they are -- actually clean. slightlyOptimizePatchset :: PatchSet rt p wStart wX -> PatchSet rt p wStart wX -- | Take a tag's PatchInfo, and a PatchSet, and attempt to -- find the tag in the PatchSet. If found, return a new -- PatchSet, in which the tag is now clean (and the last of the -- Tagged 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 -- PatchSet, we return Nothing. splitOnTag :: Commute p => PatchInfo -> PatchSet rt p wStart wX -> Maybe (PatchSet rt p wStart wX) patchSetUnion :: (Commute p, Merge p, Eq2 p) => [SealedPatchSet rt p Origin] -> SealedPatchSet rt p Origin patchSetIntersection :: Commute p => [SealedPatchSet rt p Origin] -> SealedPatchSet rt p Origin findUncommon :: Commute p => PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> (FL (PatchInfoAnd rt p) :\/: FL (PatchInfoAnd rt p)) wX wY -- | Reorder a PatchSet such that the latest tag becomes clean. cleanLatestTag :: Commute p => PatchSet rt p wStart wX -> PatchSet rt p wStart wX -- | Split a PatchSet 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 rt p wX wY -> (PatchSet rt p :> RL (PatchInfoAnd rt p)) wX wY module Darcs.Patch.Index.Monad withPatchMods :: FileModMonad a -> Set AnchoredPath -> (Set AnchoredPath, [PatchMod AnchoredPath]) -- | Apply a patch to set of AnchoredPaths, yielding the new set of -- AnchoredPaths and PatchMods applyToFileMods :: (Apply p, ApplyState p ~ Tree) => p wX wY -> Set AnchoredPath -> (Set AnchoredPath, [PatchMod AnchoredPath]) makePatchID :: PatchInfo -> PatchId instance Control.Monad.State.Class.MonadState (Data.Set.Internal.Set Darcs.Util.Path.AnchoredPath, [Darcs.Patch.Index.Types.PatchMod Darcs.Util.Path.AnchoredPath]) 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.ApplyPatches applyPatches :: (MonadProgress m, ApplyMonad (ApplyState p) m, Apply p) => FL (PatchInfoAnd rt p) wX wY -> m () module Darcs.Repository.ApplyPatches applyPatches :: (MonadProgress m, ApplyMonad (ApplyState p) m, Apply p) => FL (PatchInfoAnd rt p) wX wY -> m () -- | 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 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 GHC.Base.Monad Darcs.Repository.ApplyPatches.SilentIO instance GHC.Base.Applicative Darcs.Repository.ApplyPatches.SilentIO instance GHC.Base.Functor Darcs.Repository.ApplyPatches.SilentIO 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 GHC.Base.Monad Darcs.Repository.ApplyPatches.DefaultIO instance GHC.Base.Applicative Darcs.Repository.ApplyPatches.DefaultIO instance GHC.Base.Functor Darcs.Repository.ApplyPatches.DefaultIO 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.MonadProgress.MonadProgress Darcs.Repository.ApplyPatches.DefaultIO 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.Annotate annotateFile :: AnnotateRP p => RL (PatchInfoAnd rt p) wX wY -> AnchoredPath -> ByteString -> AnnotateResult annotateDirectory :: AnnotateRP p => RL (PatchInfoAnd rt 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 GHC.Classes.Eq (Darcs.Patch.Annotate.Content2 [] ((,) GHC.Types.Int)) instance GHC.Show.Show (Darcs.Patch.Annotate.Content2 [] ((,) GHC.Types.Int)) instance GHC.Classes.Eq (Darcs.Patch.Annotate.Annotated2 [] ((,) GHC.Types.Int)) instance GHC.Show.Show (Darcs.Patch.Annotate.Annotated2 [] ((,) GHC.Types.Int)) instance Darcs.Patch.Annotate.Annotate Darcs.Patch.Prim.V1.Core.Prim instance Darcs.Patch.Annotate.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.PrimClassify Darcs.Patch.V2.Prim.Prim instance Darcs.Patch.Prim.Class.PrimCanonize 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.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.V2 -- | RepoPatchV2 is used to represents prim patches that are -- duplicates of, or conflict with, another prim patch in the repository. -- -- Normal prim: A primitive patch -- -- Duplicate x: This patch has no effect since x is -- already present in the repository. -- --
--   Etacilpud x: invert (Duplicate x)
--   
-- -- Conflictor ix xx x: ix is the set of patches: * that -- conflict with x and also conflict with another patch in the -- repository. * that conflict with a patch that conflict with x -- -- xx is the sequence of patches that conflict *only* with -- x -- -- x is the original, conflicting patch. -- -- ix and x are stored as Non 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 x conflicts with, that haven't already been -- undone by another Conflictor in the repository. Therefore, the effect -- of a Conflictor is invert xx. -- -- InvConflictor ix xx x: like invert (Conflictor ix xx -- x) data RepoPatchV2 prim wX wY 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.PrimClassify Darcs.Patch.V1.Prim.Prim instance Darcs.Patch.Prim.Class.PrimCanonize 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.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.V1 -- | The format of a merger is Merger undos unwindings conflicting -- original. -- -- undos = the effect of the merger -- -- unwindings = TODO: eh? -- -- conflicting = the patch we conflict with -- -- original = the patch we really are data RepoPatchV1 prim wX wY 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 family 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 -- | Commute represents things that can be (possibly) commuted. -- -- Instances should obey the following laws: -- -- -- --
--   commute (p:>q) == Just (q':>p') <=> commute (q':>p') == Just (p':>q)
--   
-- -- -- --
--   commute (p:>q) == Just (q':>p') <=> commute (invert q:>invert p) == Just (invert p':>invert q')
--   
-- -- -- --
--   commute (p:>q) == Just (q':>p') => commute (invert p:>q') == Just (q:>invert p')
--   
-- -- is required to hold only for primitive patches, i.e. if there is -- no instance Merge p, because together with -- merge it implies that any two patches commute. class Commute p commute :: Commute p => (p :> p) wX wY -> Maybe ((p :> p) wX wY) class Conflict p -- | 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 FL -- 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 effect or -- effectRL. 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 unsafeCompare, =\/= and =/\=. class Eq2 p -- | It is unsafe to define a class instance via this method, because if it -- returns True then the default implementations of =\/= and -- =/\= will coerce the equality of two witnesses. -- -- Calling this method is safe, although =\/= or =/\= 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 wX wY) -- | Patches that can always be merged, even if they conflict. -- -- Instances should obey the following laws: -- -- 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 ListFormat). -- 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 family PrimOf (p :: (* -> * -> *)) :: (* -> * -> *); } -- | This class is used to decode patches from their binary representation. class ReadPatch p readPatch' :: ReadPatch p => Parser (Sealed (p wX)) -- | RepairToFL 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 -- | showContextPatch is used to add context to a patch, 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 -- tree. showContextPatch :: (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 description and content are -- suitable only for PrimPatch and RepoPatch types. -- Logically, description should default to mempty while -- content should default to displayPatch. We define them -- the other way around so that showFriendly 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 module Darcs.Patch.Rebase.Change data RebaseChange prim wX wY [RC] :: FL (RebaseFixup prim) wX wY -> Named prim wY wZ -> RebaseChange prim wX wZ toRebaseChanges :: FL (RebaseChange prim) wX wY -> FL (PatchInfoAndG ( 'RepoType 'IsRebase) (RebaseChange prim)) wX wY -- | 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 extractRebaseChange, 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 Named patch inside a RebaseChange and -- wrap it in a PatchInfoAnd. rcToPia :: RebaseChange prim wX wY -> Sealed2 (PatchInfoAnd ( 'RepoType 'NoRebase) 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 ToEdit 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 simplifyPush 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.Show.ShowPatchBasic prim, Darcs.Patch.Invert.Invert prim, Darcs.Patch.Format.PatchListFormat 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.Show.ShowPatchBasic prim, Darcs.Patch.Invert.Invert prim, Darcs.Patch.Format.PatchListFormat 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". -- -- ToEdit holds a patch that is being edited. The name -- (PatchInfo) 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 -- Ignore-This junk. -- -- Fixup adjusts the context so that a subsequent -- ToEdit patch is correct. Where possible, Fixup -- changes are commuted as far as possible into the rebase state, so any -- remaining ones will typically cause a conflict when the -- ToEdit 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 :: forall p wX wY. 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 single Suspended patch contains the entire rebase state, in -- the form of RebaseItems. -- -- The witnesses are such that a Suspended appears to have no -- effect. This behaviour is only kept so we can read old-style rebase -- patches, where the entire rebase state was kept in a single patch on -- disk. data Suspended p wX wY [Items] :: FL (RebaseChange (PrimOf p)) wX wY -> Suspended p wX wX countToEdit :: Suspended p wX wY -> Int simplifyPush :: (PrimPatchBase p, Commute p, FromPrim p, Effect p) => DiffAlgorithm -> RebaseFixup (PrimOf p) wX wY -> Suspended p wY wY -> Suspended p wX wX simplifyPushes :: (PrimPatchBase p, Commute p, FromPrim p, Effect p) => DiffAlgorithm -> FL (RebaseFixup (PrimOf p)) wX wY -> Suspended p wY wY -> Suspended p wX wX -- | add fixups for the name and effect of a patch to a Suspended addFixupsToSuspended :: (PrimPatchBase p, Commute p, FromPrim p, Effect p) => Named p wX wY -> Suspended p wY wY -> Suspended p wX wX -- | remove fixups (actually, add their inverse) for the name and effect of -- a patch to a Suspended removeFixupsFromSuspended :: (PrimPatchBase p, Commute p, FromPrim p, Effect p) => Named p wX wY -> Suspended p wX wX -> Suspended p wY wY -- | Add Named patches for editing to a Suspended. The -- patches to be suspended are renamed by replacing the junk in their -- Patchinfo. -- -- 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 wY -> IO (Suspended p wX wX) 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 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.Suspended.Suspended 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.Suspended.Suspended p) instance (Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Inspect.PatchInspect p) => Darcs.Patch.Inspect.PatchInspect (Darcs.Patch.Rebase.Suspended.Suspended p) instance (Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Show.ShowPatchBasic p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Rebase.Suspended.Suspended p) instance (Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.Read.ReadPatch p, Darcs.Patch.RepoPatch.RepoPatch p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Rebase.Suspended.Suspended p) module Darcs.Patch.Named.Wrapped -- | A patch that lives in a repository where an old-style rebase is in -- progress. Such a repository will consist of Normal patches -- along with exactly one Suspended patch. -- -- It is here only so that we can upgrade an old-style rebase. -- -- NormalP represents a normal patch within a respository where -- a rebase is in progress. NormalP p is given the same on-disk -- representation as p, so a repository can be switched into and -- out of rebasing mode simply by adding or removing a RebaseP -- patch and setting the appropriate format flag. -- -- Note that the witnesses are such that the RebaseP 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 (rt :: RepoType) p wX wY [NormalP] :: !Named p wX wY -> WrappedNamed rt p wX wY [RebaseP] :: (PrimPatchBase p, FromPrim p, Effect p) => !PatchInfo -> !Suspended p wX wX -> WrappedNamed ( 'RepoType 'IsRebase) p wX wX fromRebasing :: WrappedNamed rt p wX wY -> Named p wX wY instance Darcs.Patch.Witnesses.Show.Show2 p => GHC.Show.Show (Darcs.Patch.Named.Wrapped.WrappedNamed rt p wX wY) instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.FromPrim.FromPrim p, Darcs.Patch.Effect.Effect p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.RepoPatch.RepoPatch p, Darcs.Patch.RepoType.IsRepoType rt) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.Format.PatchListFormat p => Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Named.Wrapped.ReadRebasing p) instance (Darcs.Patch.Read.ReadPatch p, Darcs.Patch.Format.PatchListFormat p, Darcs.Patch.FromPrim.PrimPatchBase p, Darcs.Patch.RepoPatch.RepoPatch p) => Darcs.Patch.Read.ReadPatch (Darcs.Patch.Named.Wrapped.ReadRebasing p) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show1 (Darcs.Patch.Named.Wrapped.WrappedNamed rt p wX) instance Darcs.Patch.Witnesses.Show.Show2 p => Darcs.Patch.Witnesses.Show.Show2 (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.FromPrim.PrimPatchBase p => Darcs.Patch.FromPrim.PrimPatchBase (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.Ident.Ident (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.Format.PatchListFormat (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance (Darcs.Patch.Show.ShowPatchBasic p, Darcs.Patch.Format.PatchListFormat p) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.Apply.Apply p => Darcs.Patch.Apply.Apply (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) instance Darcs.Patch.Commute.Commute p => Darcs.Patch.Commute.Commute (Darcs.Patch.Named.Wrapped.WrappedNamed rt p) -- | Formal inverses for patches that aren't really invertible. Note that -- most the mixed {Fwd,Rev} cases for Commute and -- Eq2 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) Invertible. The result is -- initially positive i.e. Fwd. mkInvertible :: p wX wY -> Invertible p wX wY -- | Get the underlying patch from an Invertible, assuming (as a -- precondition) that it is positive i.e. Fwd. fromPositiveInvertible :: Invertible p wX wY -> p wX wY -- | Run a function on the patch inside an Invertible. The function -- has to be parametric in the witnesses, so we can run it with both a -- Fwd and a Rev 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) module Darcs.Patch -- | This type is intended to be used as a phantom type via the -- DataKinds extension. It tracks different types of -- repositories, e.g. to indicate when a rebase is in progress. data RepoType class IsRepoType (rt :: RepoType) class PrimPatch (PrimOf p) => PrimPatchBase p where { type family PrimOf (p :: (* -> * -> *)) :: (* -> * -> *); } -- | The Named type adds a patch info about a patch, that is a -- name. -- -- NamedP info deps p represents patch p with name -- info. deps is a list of dependencies added at the -- named patch level, compared with the unnamed level (ie, dependencies -- added with darcs record --ask-deps). data Named p wX wY type family 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 -- | showContextPatch is used to add context to a patch, 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 -- tree. showContextPatch :: (ShowContextPatch p, ApplyMonad (ApplyState p) m) => ShowPatchFor -> 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 primIsAddfile :: PrimClassify prim => prim wX wY -> Bool primIsHunk :: PrimClassify prim => prim wX wY -> Bool primIsSetpref :: PrimClassify prim => prim wX wY -> Bool 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 -- | forceTokReplace tokChars old new input replaces all -- occurrences of the old token with the new one, -- throughout the input. forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString type PrimPatch prim = (Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCanonize prim, PrimClassify 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 FL -- 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 effect or -- effectRL. class Effect p effect :: Effect p => p wX wY -> FL (PrimOf p) wX wY primIsBinary :: PrimClassify prim => prim wX wY -> Bool primIsAdddir :: PrimClassify prim => prim wX wY -> Bool 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 -- | Delete the first subsequence of patches that is followed by an inverse -- subsequence, if one exists. If not return Nothing. dropInverses :: (Invert p, Eq2 p) => FL p wX wY -> Maybe (FL p wX wY) -- | commuteFL commutes a single element past a FL. commuteFL :: Commute p => (p :> FL p) wX wY -> Maybe ((FL p :> p) wX wY) -- | commuteRL 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) -- | It can sometimes be handy to have a canonical representation of a -- given patch. We achieve this by defining a canonical form for each -- patch type, and a function canonize which takes a patch and -- puts it into canonical form. This routine is used by the diff function -- to create an optimal patch (based on an LCS algorithm) from a simple -- hunk describing the old and new version of a file. canonize :: PrimCanonize prim => DiffAlgorithm -> prim wX wY -> FL prim wX wY -- | sortCoalesceFL ps coalesces as many patches in -- ps as possible, sorting the results in some standard order. sortCoalesceFL :: PrimCanonize prim => FL prim wX wY -> FL prim wX wY -- | tryToShrink ps simplifies ps by getting rid of -- self-cancellations or coalescing patches -- -- Question (Eric Kow): what properties should this have? For example, -- the prim1 implementation only gets rid of the first self-cancellation -- it finds (as far as I can tell). Is that OK? Can we try harder? tryToShrink :: PrimCanonize prim => FL prim wX wY -> 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 Tree, yielding a new Tree. applyToTree :: (Apply p, Monad 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) => p wX wY -> Tree IO -> IO (Maybe (Tree IO)) 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) module Darcs.Repository.Old readOldRepo :: RepoPatch p => String -> IO (SealedPatchSet rt p Origin) oldRepoFailMsg :: String module Darcs.Repository.InternalTypes -- | A Repository is a token representing the state of a -- repository on disk. It is parameterized by the patch type in the -- repository, and witnesses for the recorded state of the repository -- (i.e. what darcs get would retrieve), the unrecorded state (what's in -- the working tree now), and the tentative state, which represents work -- in progress that will eventually become the new recorded state unless -- something goes wrong. data Repository (rt :: RepoType) (p :: * -> * -> *) wRecordedstate wUnrecordedstate wTentativestate data PristineType NoPristine :: PristineType PlainPristine :: PristineType HashedPristine :: PristineType repoCache :: Repository rt p wR wU wT -> Cache modifyCache :: (Cache -> Cache) -> Repository rt p wR wU wT -> Repository rt p wR wU wT repoFormat :: Repository rt p wR wU wT -> RepoFormat repoLocation :: Repository rt p wR wU wT -> String withRepoLocation :: Repository rt p wR wU wT -> IO a -> IO a repoPristineType :: Repository rt p wR wU wT -> PristineType unsafeCoerceRepoType :: Repository rt p wR wU wT -> Repository rt' p wR wU wT unsafeCoercePatchType :: Repository rt p wR wU wT -> Repository rt p' wR wU wT unsafeCoerceR :: Repository rt p wR wU wT -> Repository rt p wR' wU wT unsafeCoerceU :: Repository rt p wR wU wT -> Repository rt p wR wU' wT unsafeCoerceT :: Repository rt p wR wU wT -> Repository rt p wR wU wT' mkRepo :: String -> RepoFormat -> PristineType -> Cache -> Repository rt p wR wU wT instance GHC.Show.Show (Darcs.Repository.InternalTypes.Repository rt p wRecordedstate wUnrecordedstate wTentativestate) instance GHC.Classes.Eq Darcs.Repository.InternalTypes.PristineType instance GHC.Show.Show Darcs.Repository.InternalTypes.PristineType module Darcs.Repository.Traverse -- | Remove unreferenced files in the inventories directory. cleanInventories :: Repository rt p wR wU wT -> IO () -- | Remove unreferenced files in the patches directory. cleanPatches :: Repository rt p wR wU wT -> IO () -- | Remove unreferenced entries in the pristine cache. cleanPristine :: Repository rt p wR wU wT -> IO () cleanRepository :: Repository rt p wR wU wT -> IO () -- | Set difference between two lists of hashes. diffHashLists :: [String] -> [String] -> [String] -- | Return a list of the inventories hashes. This function attempts to -- retrieve missing inventory files from the cache. listInventories :: IO [String] -- | Return inventories hashes by following the head inventory. This -- function does not attempt to retrieve missing inventory files. listInventoriesLocal :: IO [String] -- | Return a list of the inventories hashes. The argument repoDir -- 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 darcsDir in bucketed format. listPatchesLocalBucketed :: String -> String -> IO [String] -- | List of special patch files that may exist in the directory -- _darcspatches. We must not clean those. specialPatches :: [FilePath] module Darcs.Repository.Rebase withManualRebaseUpdate :: forall rt p x wR wU wT1 wT2. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT1 -> (Repository rt p wR wU wT1 -> IO (Repository rt p wR wU wT2, FL (RebaseFixup (PrimOf p)) wT2 wT1, x)) -> IO (Repository rt p wR wU wT2, x) -- | got a rebase operation to run where it is required that a rebase is -- already in progress rebaseJob :: (RepoPatch p, ApplyState p ~ Tree) => (Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a -- | Got a rebase operation to run where we may need to initialise the -- rebase state first. Make sure you have taken the lock before calling -- this. startRebaseJob :: (RepoPatch p, ApplyState p ~ Tree) => (Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a -- | Generic status display for non-rebase commands. maybeDisplaySuspendedStatus :: RepoPatch p => SRebaseType rebaseType -> Repository ( 'RepoType rebaseType) p wR wU wR -> IO () readTentativeRebase :: RepoPatch p => Repository rt p wR wU wT -> IO (Suspended p wT wT) writeTentativeRebase :: RepoPatch p => Repository rt p wR wU wT -> Suspended p wT wT -> IO () withTentativeRebase :: RepoPatch p => Repository rt p wR wU wT -> Repository rt p wR wU wY -> (Suspended p wT wT -> Suspended p wY wY) -> IO () createTentativeRebase :: RepoPatch p => Repository rt p wR wU wR -> IO () readRebase :: RepoPatch p => Repository rt p wR wU wR -> IO (Suspended p wR wR) commuteOutOldStyleRebase :: RepoPatch p => RL (PiaW rt p) wA wB -> Maybe ((RL (PiaW rt p) :> PiaW rt p) wA wB) checkOldStyleRebaseStatus :: RepoPatch p => SRebaseType rebaseType -> Repository ( 'RepoType rebaseType) p wR wU wR -> IO () module Darcs.Repository.Pristine data ApplyDir ApplyNormal :: ApplyDir ApplyInverted :: ApplyDir -- | applyToHashedPristine takes a root hash, a patch p and -- attempts to apply the patch to the Tree identified by -- h. If we encounter an old, size-prefixed pristine, we first -- convert it to the non-size-prefixed format, then apply the patch. applyToHashedPristine :: (Apply p, ApplyState p ~ Tree) => ApplyDir -> PristineHash -> p wX wY -> IO PristineHash -- | applyToTentativePristine applies a patch p to the tentative -- pristine tree, and updates the tentative pristine hash applyToTentativePristine :: (ApplyState q ~ Tree, Apply q, ShowPatch q) => Repository rt p wR wU wT -> ApplyDir -> Verbosity -> q wT wY -> IO () applyToTentativePristineCwd :: (ApplyState p ~ Tree, Apply p) => ApplyDir -> p wX wY -> IO () -- | readHashedPristineRoot attempts to read the pristine hash from the -- current inventory, returning Nothing if it cannot do so. readHashedPristineRoot :: Repository rt p wR wU wT -> IO (Maybe PristineHash) -- | Replace the pristine hash at the start of a raw, unparsed -- HeadInventory or add it if none is present. pokePristineHash :: PristineHash -> ByteString -> Doc peekPristineHash :: ByteString -> PristineHash -- | grab the pristine hash of _darcs/hash_inventory, and retrieve whole -- pristine tree, possibly writing a clean working tree in the process. createPristineDirectoryTree :: Repository rt p wR wU wT -> FilePath -> WithWorkingDir -> IO () -- | Used by the commands dist and diff createPartialsPristineDirectoryTree :: Repository rt p wR wU wT -> [AnchoredPath] -> FilePath -> IO () withRecorded :: Repository rt p wR wU wT -> ((AbsolutePath -> IO a) -> IO a) -> (AbsolutePath -> IO a) -> IO a withTentative :: Repository rt p wR wU wT -> ((AbsolutePath -> IO a) -> IO a) -> (AbsolutePath -> IO a) -> IO a module Darcs.Repository.Pending -- | Read the contents of pending. readPending :: RepoPatch p => Repository rt p wR wU wT -> IO (Sealed (FL (PrimOf p) wR)) -- | Read the contents of tentative pending. readTentativePending :: RepoPatch p => Repository rt p wR wU wT -> IO (Sealed (FL (PrimOf p) wT)) -- | Write the contents of tentative pending. writeTentativePending :: RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wT wY -> IO () -- | siftForPending ps simplifies the candidate pending patch -- ps through a combination of looking for self-cancellations -- (sequences of patches followed by their inverses), coalescing, and -- getting rid of any hunk/binary patches we can commute out the back -- -- The visual image of sifting can be quite helpful here. We are -- repeatedly tapping (shrinking) the patch sequence and shaking it -- (sift). Whatever falls out is the pending we want to keep. We do this -- until the sequence looks about as clean as we can get it siftForPending :: 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. 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. These changes cannot be removed -- from pending because they have never been part of it. -- -- This function is used by Darcs whenever it adds a patch to the -- repository (eg. with apply or record). Think of it as one part of -- transferring patches from pending to somewhere else. tentativelyRemoveFromPending :: forall rt p wR wU wT wO. RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wO wT -> IO () -- | Similar to tentativelyRemoveFromPending, but also takes the -- (old) difference between pending and working into account. It is used -- by amend and record commands to adjust the pending patch. See the docs -- for updatePending below for details. tentativelyRemoveFromPW :: forall rt p wR wO wT wP wU. RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wO wT -> FL (PrimOf p) wO wP -> FL (PrimOf p) wP wU -> IO () revertPending :: RepoPatch p => Repository rt p wR wU wT -> UpdatePending -> IO () -- | Replace the pending patch with the tentative pending. If -- NoUpdatePending, this merely deletes the tentative pending -- without replacing the current one. -- -- Question (Eric Kow): shouldn't this also delete the tentative pending -- if YesUpdatePending? I'm just puzzled by the seeming -- inconsistency of the NoUpdatePending doing deletion, but -- YesUpdatePending not bothering. finalizePending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> UpdatePending -> Tree IO -> IO () -- | makeNewPending repo YesUpdatePending pendPs verifies that the -- pendPs could be applied to pristine if we wanted to, and if -- so writes it to disk. If it can't be applied, pendPs must be -- somehow buggy, so we save it for forensics and crash. makeNewPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> UpdatePending -> FL (PrimOf p) wT wP -> Tree IO -> IO () -- | tentativelyAddToPending repo ps appends ps to the -- pending patch. -- -- This fuction is unsafe because it accepts a patch that works on the -- tentative pending and we don't currently track the state of the -- tentative pending. tentativelyAddToPending :: forall rt p wR wU wT wX wY. RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wX wY -> IO () -- | Overwrites the pending patch with a new one, starting at the tentative -- state. setTentativePending :: forall rt p wR wU wT wP. RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wT 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 -- log and annotate). More precisely, for every file -- tracked by the repository, it stores the list of patches that touch -- it. -- -- When created, patch-index lives in _darcs/patch_index/, 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 -- _darcs/no_patch_index. "Explicitely disabed" means that no -- command should attempt to automatically create the patch-index. -- -- See http://darcs.net/Internals/PatchIndex for more information. module Darcs.Repository.PatchIndex -- | Read-only. Checks if patch-index exists for this repository it works -- by checking if: -- --
    --
  1. _darcs/patch_index/ and its corresponding files are all -- present
  2. --
  3. patch index version is the one handled by this version of -- Darcs
  4. --
doesPatchIndexExist :: FilePath -> IO Bool -- | Read-only. Checks if _darcs/noPatchIndex exists, that is, if -- patch-index is explicitely disabled. isPatchIndexDisabled :: FilePath -> IO Bool -- | Checks if patch-index exists and is in sync with repository (more -- precisely with _darcs/hashed_inventory). That is, checks if -- patch-index can be used as it is now. isPatchIndexInSync :: Repository rt p wR wU wT -> IO Bool -- | Read-only. Checks the two following things: -- --
    --
  1. doesPatchIndexExist
  2. --
  3. isPatchIndexDisabled
  4. --
-- -- Then only if it exists and it is not explicitely disabled, returns -- True, else returns False (or an error if it exists -- and is explicitely disabled at the same time). canUsePatchIndex :: Repository rt p wR wU wT -> 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 wR wU wT -> PatchSet rt p Origin wR -> IO () -- | Create or update patch index -- --
    --
  1. if _darcs/no_patch_index exists, delete it
  2. --
  3. if patch index exists, update it
  4. --
  5. if not, create it from scratch
  6. --
createOrUpdatePatchIndexDisk :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> PatchSet rt p Origin wR -> IO () -- | Deletes patch-index (_darcs/patch_index/ and its contents) -- and mark repository as disabled (creates -- _darcs/no_patch_index). deletePatchIndex :: FilePath -> IO () -- | Checks if patch index can be created and build it with interrupt. attemptCreatePatchIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> PatchSet rt p Origin wR -> IO () type PatchFilter rt p = [AnchoredPath] -> [Sealed2 (PatchInfoAnd rt p)] -> IO [Sealed2 (PatchInfoAnd rt p)] -- | If a patch index is available, returns a filter that takes a list of -- files and returns a PatchFilter 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 wR wU wT -> PatchSet rt p Origin wR -> PatchFilter rt p -- | Returns an RL in which the order of patches matters. Useful for the -- annotate 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 rt p) => Sealed (RL a wK) -> Repository rt p wR wU wR -> PatchSet rt 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.FileInfo instance GHC.Classes.Eq Darcs.Repository.PatchIndex.FileInfo instance GHC.Show.Show Darcs.Repository.PatchIndex.FileInfo 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.FileIdSpan instance GHC.Classes.Eq Darcs.Repository.PatchIndex.FileIdSpan instance GHC.Show.Show Darcs.Repository.PatchIndex.FileIdSpan 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 wR wU wT -> [AnchoredPath] -> IO (TreeFilter m) -- | Construct a TreeFilter that removes any boring files that are -- not also contained in the argument Tree. -- -- 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 Nothing, -- 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: -- -- -- -- 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) => (UseIndex, ScanKnown, DiffAlgorithm) -> LookForMoves -> LookForReplaces -> Repository rt p wR 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. readRecorded :: Repository rt p wR wU wT -> 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 wR wU wR -> UseIndex -> Maybe [AnchoredPath] -> IO (Tree IO) -- | Obtains the recorded Tree with the pending patch applied. readRecordedAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR 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) => (UseIndex, ScanKnown, DiffAlgorithm) -> LookForMoves -> LookForReplaces -> Repository rt p wR wU wR -> Maybe [AnchoredPath] -> IO ((FL (PrimOf p) :> FL (PrimOf p)) wR wU) -- | A variant of readUnrecorded that takes the UseIndex and -- ScanKnown options into account, similar to -- readPendingAndWorking. We are only interested in the resulting -- tree, not the patch, so the DiffAlgorithm option is irrelevant. readUnrecordedFiltered :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> UseIndex -> ScanKnown -> LookForMoves -> Maybe [AnchoredPath] -> IO (Tree IO) readIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO Index updateIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO () -- | Mark the existing index as invalid. This has to be called whenever the -- listing of pristine changes and will cause darcs to update the index -- next time it tries to read it. (NB. This is about files added and -- removed from pristine: changes to file content in either pristine or -- working are handled transparently by the index reading code.) invalidateIndex :: t -> IO () data UseIndex UseIndex :: UseIndex IgnoreIndex :: UseIndex data ScanKnown -- | Just files already known to darcs ScanKnown :: ScanKnown -- | All files, i.e. look for new ones ScanAll :: ScanKnown -- | All files, even boring ones ScanBoring :: ScanKnown -- | 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 wR wU wR -> FL (PatchInfoAnd rt p) wX wR -> FL (PatchInfoAnd rt p) wX wZ -> IO (Bool, Sealed (FL (PatchInfoAnd rt p) wX)) -- | Add an FL of patches started from the pending state to the -- pending patch. TODO: add witnesses for pending so we can make the -- types precise: currently the passed patch can be applied in any -- context, not just after pending. addPendingDiffToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> FreeLeft (FL (PrimOf p)) -> IO () -- | Add an FL 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 rt p wR wU wR -> UseIndex -> FL (PrimOf p) wU wY -> IO () module Darcs.Repository.Resolution standardResolution :: (Commute p, PrimPatchBase p, Conflict p) => RL (PatchInfoAnd rt p) wO wX -> RL (PatchInfoAnd rt 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 rt 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 -> ExternalMerge -> StandardResolution prim wX -> IO Bool warnUnmangled :: PrimPatch prim => StandardResolution prim wX -> IO () showUnmangled :: PrimPatch prim => [Unravelled prim wX] -> Doc showUnravelled :: PrimPatch prim => Doc -> Unravelled prim wX -> Doc -- | First matcher, Second matcher and Nonrange matcher -- -- 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 Matchers: -- -- module Darcs.Patch.Match -- | The string that is emitted when the user runs darcs help -- patterns. helpOnMatchers :: [String] -- | matchFirstPatchset fs ps returns the part of ps -- before its first matcher, ie the one that comes first dependencywise. -- Hence, patches in matchFirstPatchset fs ps are the context -- for the ones we don't want. matchFirstPatchset :: MatchableRP p => [MatchFlag] -> PatchSet rt p wStart wX -> Maybe (SealedPatchSet rt p wStart) -- | matchSecondPatchset fs ps returns the part of ps -- before its second matcher, ie the one that comes last dependencywise. matchSecondPatchset :: MatchableRP p => [MatchFlag] -> PatchSet rt p wStart wX -> Maybe (SealedPatchSet rt 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 -- matchSecondPatchset 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 MatchFlags. This should be -- invariant under inversion: -- --
--   matchAPatch (invert p) = matchAPatch p
--   
matchAPatch :: Matchable p => [MatchFlag] -> p wX wY -> Bool -- | Rollback (i.e. apply the inverse) of what remains of a PatchSet -- after we extract a PatchSetMatch. This is the counterpart of -- getOnePatchset 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, IsRepoType rt, MatchableRP p, ApplyState p ~ Tree) => PatchSetMatch -> PatchSet rt p Origin wX -> m () -- | firstMatch fs tells whether fs 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 -- | secondMatch fs tells whether fs 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 -- | haveNonrangeMatch flags tells whether there is a flag in -- flags which corresponds to a match that is "non-range". Thus, -- --match, --patch, and --hash make -- haveNonrangeMatch true, but not --from-patch or -- --to-patch. 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) -- | getMatchingTag m ps, where m is a Matcher -- which matches tags returns a SealedPatchSet containing all -- patches in the last tag which matches m. Last tag means the -- most recent tag in repository order, i.e. the last one you'd see if -- you ran darcs log -t m. Calls error if there is no -- matching tag. getMatchingTag :: MatchableRP p => Matcher -> PatchSet rt p wStart wX -> SealedPatchSet rt p wStart -- | matchAPatchset m ps returns a prefix of ps ending in -- a patch matching m, and calls error if there is none. matchAPatchset :: MatchableRP p => Matcher -> PatchSet rt p wStart wX -> SealedPatchSet rt 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 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 rt p wR. MatchableRP p => [MatchFlag] -> PatchSet rt p Origin wR -> (PatchSet rt p :> FL (PatchInfoAnd rt 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 p that ensures -- PatchInfoAnd rt p is Matchable. 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 MatchOption 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 MatchFlag (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 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: -- -- module Darcs.UI.Options.All -- | DarcsOption instantiates the first two type parameters of -- OptSpec to what we need in darcs. The first parameter is -- instantiated to The flag type is instantiate to Flag. 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 -> 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) data RemoteRepos RemoteRepos :: [String] -> RemoteRepos remoteRepos :: PrimDarcsOption RemoteRepos 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 --repodir 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 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 LookFor LookFor :: LookForAdds -> LookForReplaces -> LookForMoves -> LookFor [adds] :: LookFor -> LookForAdds [replaces] :: LookFor -> LookForReplaces [moves] :: LookFor -> LookForMoves data LookForAdds YesLookForAdds :: LookForAdds NoLookForAdds :: LookForAdds data LookForMoves YesLookForMoves :: LookForMoves NoLookForMoves :: LookForMoves data LookForReplaces YesLookForReplaces :: LookForReplaces NoLookForReplaces :: LookForReplaces lookfor :: PrimDarcsOption LookFor lookforadds :: LookForAdds -> PrimDarcsOption LookForAdds lookforreplaces :: PrimDarcsOption LookForReplaces lookformoves :: PrimDarcsOption LookForMoves data UseIndex UseIndex :: UseIndex IgnoreIndex :: UseIndex data ScanKnown -- | Just files already known to darcs ScanKnown :: ScanKnown -- | All files, i.e. look for new ones ScanAll :: ScanKnown -- | All files, even boring ones ScanBoring :: ScanKnown data IncludeBoring YesIncludeBoring :: IncludeBoring NoIncludeBoring :: IncludeBoring includeBoring :: PrimDarcsOption IncludeBoring 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 [diffOpts] :: ExternalDiff -> [String] [diffUnified] :: ExternalDiff -> Bool extDiff :: PrimDarcsOption ExternalDiff data TestChanges NoTestChanges :: TestChanges YesTestChanges :: LeaveTestDir -> TestChanges testChanges :: PrimDarcsOption TestChanges data RunTest YesRunTest :: RunTest NoRunTest :: RunTest runTest :: PrimDarcsOption 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) sendmail :: PrimDarcsOption (Bool, Maybe String) 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 :: AllowConflicts YesAllowConflictsAndMark :: AllowConflicts -- | push, apply, rebase apply: default to NoAllowConflicts conflictsNo :: PrimDarcsOption (Maybe AllowConflicts) -- | pull, rebase pull: default to YesAllowConflictsAndMark conflictsYes :: PrimDarcsOption (Maybe AllowConflicts) data ExternalMerge YesExternalMerge :: String -> ExternalMerge NoExternalMerge :: ExternalMerge externalMerge :: PrimDarcsOption ExternalMerge -- | pull, apply, rebase pull, rebase apply reorder :: PrimDarcsOption Reorder data Compression NoCompression :: Compression GzipCompression :: Compression 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 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 -- | TODO: reconsider this grouping of options data NetworkOptions NetworkOptions :: Bool -> RemoteDarcs -> NetworkOptions [noHttpPipelining] :: NetworkOptions -> Bool [remoteDarcs] :: NetworkOptions -> RemoteDarcs network :: PrimDarcsOption NetworkOptions 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 String -> Maybe String -> a) readMarks :: PrimDarcsOption (Maybe String) writeMarks :: PrimDarcsOption (Maybe String) 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 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.GzcrcsAction instance GHC.Classes.Eq Darcs.UI.Options.All.GzcrcsAction 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.ChangesFormat instance GHC.Classes.Eq Darcs.UI.Options.All.ChangesFormat 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.Output instance GHC.Classes.Eq Darcs.UI.Options.All.Output 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.Sign instance GHC.Classes.Eq Darcs.UI.Options.All.Sign instance GHC.Classes.Eq Darcs.UI.Options.All.TestChanges instance GHC.Show.Show Darcs.UI.Options.All.ExternalDiff instance GHC.Classes.Eq Darcs.UI.Options.All.ExternalDiff 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.AskLongComment instance GHC.Classes.Eq Darcs.UI.Options.All.AskLongComment 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.SelectDeps instance GHC.Classes.Eq Darcs.UI.Options.All.SelectDeps 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.StdCmdAction instance GHC.Classes.Eq Darcs.UI.Options.All.StdCmdAction 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.EnumPatches instance GHC.Classes.Eq Darcs.UI.Options.All.EnumPatches instance Darcs.UI.Options.All.YesNo Darcs.UI.Options.All.WithSummary 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.Compression 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.IncludeBoring 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 module Darcs.UI.Options -- | DarcsOption instantiates the first two type parameters of -- OptSpec to what we need in darcs. The first parameter is -- instantiated to The flag type is instantiate to Flag. type DarcsOption = OptSpec DarcsOptDescr Flag -- | This is PrimOptSpec instantiated with DarcsOptDescr and -- Flag. type PrimDarcsOption v = forall a. PrimOptSpec DarcsOptDescr Flag a v -- | We do not instantiate the d in OptSpec d f -- directly with OptDescr. Instead we (post-) compose it with -- (->) AbsolutePath. Modulo newtype noise, this is -- the same as -- --
--   type DarcsOptDescr f = OptDescr (AbsolutePath -> f)
--   
-- -- 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 DarcsOptDescr with an AbsolutePath optDescr :: AbsolutePath -> DarcsOptDescr f -> OptDescr f type Config = [Flag] module Darcs.UI.Flags -- | The DarcsFlag type is a list of all flags that can ever be -- passed to darcs, or to one of its commands. data DarcsFlag remoteDarcs :: Config -> RemoteDarcs diffingOpts :: Config -> (UseIndex, ScanKnown, DiffAlgorithm) diffOpts :: UseIndex -> LookForAdds -> IncludeBoring -> DiffAlgorithm -> (UseIndex, ScanKnown, DiffAlgorithm) -- | Non-trivial interaction between options. scanKnown :: LookForAdds -> IncludeBoring -> ScanKnown -- | This will become dis-entangled as soon as we inline these functions. wantGuiPause :: Config -> WantGuiPause -- | Non-trivial interaction between options. Explicit -i or -- -a dominates, else --count, --xml, or -- --dry-run imply -a, else use the def argument. isInteractive :: Bool -> Config -> Bool willRemoveLogFile :: Config -> Bool includeBoring :: Config -> Bool lookForAdds :: Config -> LookForAdds lookForMoves :: Config -> LookForMoves lookForReplaces :: Config -> LookForReplaces setDefault :: Bool -> Config -> SetDefault allowConflicts :: Config -> AllowConflicts hasXmlOutput :: Config -> Bool hasLogfile :: Config -> Maybe AbsolutePath quiet :: Config -> Bool verbose :: Config -> Bool enumeratePatches :: Config -> Bool -- | Ugly. The alternative is to put the remoteRepos accessor into the IO -- monad, which is hardly better. However, accessing the flag list -- directly here is benign, as we only map over the list and don't change -- the order. fixRemoteRepos :: AbsolutePath -> Config -> IO Config -- | fixUrl takes a String that may be a file path or a URL. It -- returns either the URL, or an absolute version of the path. 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 Nothing here means "no -- restriction to the set of paths". If Just is returned, the set -- is guaranteed to be non-empty. pathSetFromArgs :: (AbsolutePath, AbsolutePath) -> [String] -> IO (Maybe [AnchoredPath]) -- | getRepourl takes a list of flags and returns the url of the -- repository specified by Repodir "directory" in that list of -- flags, if any. This flag is present if darcs was invoked with -- --repodir=DIRECTORY getRepourl :: Config -> Maybe String -- | getAuthor takes a list of flags and returns the author of the -- change specified by Author "Leo Tolstoy" in that list of -- flags, if any. Otherwise, if Pipe 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 -- | promptAuthor 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 _darcs/prefs. promptAuthor :: Bool -> Bool -> IO String -- | getEasyAuthor tries to get the author name first from the -- repository preferences, then from global preferences, then from -- environment variables. Returns [] if it could not get it. -- Note that it may only return multiple possibilities when reading from -- global preferences getEasyAuthor :: IO [String] -- | getSendmailCmd takes a list of flags and returns the sendmail -- command to be used by darcs send. Looks for a command -- specified by SendmailCmd "command" in that list of flags, if -- any. This flag is present if darcs was invoked with -- --sendmail-command=COMMAND Alternatively the user can set -- $SENDMAIL which will be used as a fallback if -- present. getSendmailCmd :: Config -> IO String fileHelpAuthor :: [String] environmentHelpEmail :: ([String], [String]) -- | getSubject takes a list of flags and returns the subject of the -- mail to be sent by darcs send. Looks for a subject specified -- by Subject "subject" in that list of flags, if any. This flag -- is present if darcs was invoked with --subject=SUBJECT getSubject :: Config -> Maybe String getInReplyTo :: Config -> Maybe String -- | getCc takes a list of flags and returns the addresses to send a -- copy of the patch bundle to when using darcs send. looks for -- a cc address specified by Cc "address" in that list of flags. -- Returns the addresses as a comma separated string. getCc :: Config -> String environmentHelpSendmail :: ([String], [String]) -- | Accessor for output option getOutput :: Config -> FilePath -> Maybe AbsolutePathOrStd getDate :: Bool -> IO String workRepo :: Config -> WorkRepo withNewRepo :: String -> Config -> Config compress :: PrimDarcsOption Compression diffAlgorithm :: PrimDarcsOption DiffAlgorithm -- | pull, apply, rebase pull, rebase apply reorder :: PrimDarcsOption Reorder minimize :: PrimDarcsOption Bool editDescription :: PrimDarcsOption Bool externalMerge :: PrimDarcsOption ExternalMerge 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 runTest :: PrimDarcsOption RunTest testChanges :: PrimDarcsOption TestChanges setScriptsExecutable :: PrimDarcsOption SetScriptsExecutable -- | convert, clone, init withWorkingDir :: PrimDarcsOption WithWorkingDir leaveTestDir :: PrimDarcsOption LeaveTestDir remoteRepos :: PrimDarcsOption RemoteRepos 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 -> 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 -> String -> Maybe (Doc, Doc) -> Doc -> IO () resendEmail :: String -> String -> ByteString -> 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 () haveSendmail :: IO Bool sendmailPath :: IO String diffProgram :: IO String -- | Get the name of the darcs executable (as supplied by -- getExecutablePath) darcsProgram :: IO String editText :: String -> ByteString -> IO ByteString -- | editFile f 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 String. It also uses certain special variants of this -- encoding to determine how to handle encoding errors. -- -- See GHC.IO.Encoding for details. -- -- In particular, the default variant used for command line arguments and -- environment variables is /ROUNDTRIP, which means that 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 -- getFileSystemEncoding. -- -- 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 Strings. The encoding -- used for IO from and to handles is controlled by -- setLocaleEncoding which we use here to make it equal to the -- //ROUNDTRIP variant. -- -- setDarcsEncoding 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 () getSystemEncoding :: IO String -- | isUTF8 checks if an encoding is UTF-8 (or ascii, since it is -- a subset of UTF-8). isUTF8Locale :: String -> Bool module Darcs.UI.PrintPatch -- | contextualPrintPatch prints a patch, together with its context, -- on standard output. contextualPrintPatch :: (ShowContextPatch p, ApplyState p ~ Tree) => Tree IO -> p wX wY -> IO () printContent :: ShowPatch p => p wX wY -> IO () printContentWithPager :: ShowPatch p => p wX wY -> IO () -- | printFriendly opts patch prints patch in -- accordance with the flags in opts, ie, whether --verbose or -- --summary were passed at the command-line. printFriendly :: (ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => Maybe (Tree IO) -> Verbosity -> WithSummary -> WithContext -> p wX wY -> IO () printSummary :: ShowPatch p => p wX wY -> IO () -- | showFriendly flags patch returns a Doc -- representing the right way to show patch given the list -- flags 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.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 rt p cX cY -> ByteString updatePending :: [DarcsFlag] -> UpdatePending module Darcs.Patch.Bundle -- | A Bundle is a context together with some patches. The context -- consists of unavailable patches. data Bundle rt p wX wY [Bundle] :: (FL (PatchInfoAnd rt p) :> FL (PatchInfoAnd rt p)) wX wY -> Bundle rt p wX wY makeBundle :: (ApplyState p ~ Tree, RepoPatch p) => Maybe (Tree IO) -> PatchSet rt p wStart wX -> FL (Named p) wX wY -> IO Doc parseBundle :: RepoPatch p => ByteString -> Either String (Sealed (Bundle rt p wX)) -- | Interpret a Bundle in the context of a PatchSet. This -- means we match up a possible tag in the context of the Bundle. -- This fails if the tag couldn't be found. interpretBundle :: Commute p => PatchSet rt p Origin wT -> Bundle rt p wA wB -> Either String (PatchSet rt p Origin wB) readContextFile :: Commute p => PatchSet rt p Origin wX -> FilePath -> IO (SealedPatchSet rt p Origin) -- | Minimize the context of an FL of patches to be packed into a -- bundle. minContext :: RepoPatch p => PatchSet rt p wStart wB -> FL (PatchInfoAnd rt p) wB wC -> Sealed ((PatchSet rt p :> FL (PatchInfoAnd rt p)) wStart) 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 :: IO () -- | 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 rt p wR wU wT -> UpdatePending -> IO (Repository rt p wR wU wR) -- | 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 :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wT -> Compression -> IO () -- | Add (append) a patch to the tentative inventory. | Warning: this -- allows to add any arbitrary patch! Used by convert import. addToTentativeInventory :: RepoPatch p => Cache -> Compression -> PatchInfoAnd rt p wX wY -> IO () -- | Read inventories and patches from a repository and return them as a -- PatchSet. Note that patches and inventories are read lazily. readRepo :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wT -> IO (PatchSet rt p Origin wR) -- | readRepo returns the "current" repo patchset. readRepoHashed :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wT -> String -> IO (PatchSet rt p Origin wR) -- | readRepo returns the tentative repo patchset. readTentativeRepo :: (IsRepoType rt, PatchListFormat p, ReadPatch p) => Repository rt p wR wU wT -> String -> IO (PatchSet rt p Origin wT) -- | 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 -> Compression -> PatchInfoAnd rt p wX wY -> IO (PatchInfoAnd rt p wX wY) -- | writeTentativeInventory writes patchSet as the tentative -- inventory. writeTentativeInventory :: RepoPatch p => Cache -> Compression -> PatchSet rt 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 rt p wR wU wT -> RemoteDarcs -> String -> IO () -- | writeHashIfNecessary writes the patch and returns the resulting -- info/hash, if it has not already been written. If it has been written, -- we have the hash in the PatchInfoAnd, so we extract and return the -- info/hash. writePatchIfNecessary :: RepoPatch p => Cache -> Compression -> PatchInfoAnd rt p wX wY -> IO InventoryEntry tentativelyAddPatch :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> Compression -> Verbosity -> UpdatePending -> PatchInfoAnd rt p wT wY -> IO (Repository rt p wR wU wY) tentativelyRemovePatches :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> Compression -> UpdatePending -> FL (PatchInfoAnd rt p) wX wT -> IO (Repository rt p wR wU wX) tentativelyRemovePatches_ :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository rt p wR wU wT -> Compression -> UpdatePending -> FL (PatchInfoAnd rt p) wX wT -> IO (Repository rt p wR wU wX) tentativelyAddPatch_ :: (RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository rt p wR wU wT -> Compression -> Verbosity -> UpdatePending -> PatchInfoAnd rt p wT wY -> IO (Repository rt p wR wU wY) tentativelyAddPatches_ :: (RepoPatch p, ApplyState p ~ Tree) => UpdatePristine -> Repository rt p wR wU wT -> Compression -> Verbosity -> UpdatePending -> FL (PatchInfoAnd rt p) wT wY -> IO (Repository rt p wR wU wY) -- | Atomically copy the tentative state to the recorded state, thereby -- committing the tentative changes that were made so far. This includes -- inventories, pending, and the index. finalizeRepositoryChanges :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> UpdatePending -> Compression -> IO (Repository rt p wT wU wT) -- | Writes out a fresh copy of the inventory that minimizes the amount of -- inventory that need be downloaded when people pull from the -- repository. -- -- Specifically, 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. reorderInventory :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> Compression -> 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 http://robotics.stanford.edu/~xb/crypto06b/ . repoXor :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wR -> IO SHA1 -- | Upgrade a possible old-style rebase in progress to the new style. upgradeOldStyleRebase :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> Compression -> IO () instance GHC.Classes.Eq Darcs.Repository.Hashed.UpdatePristine module Darcs.Repository.Repair replayRepository :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => DiffAlgorithm -> Repository rt p wR wU wT -> Compression -> Verbosity -> (RepositoryConsistency rt p wR -> IO a) -> IO a checkIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> Bool -> IO Bool replayRepositoryInTemp :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => DiffAlgorithm -> Repository rt p wR wU wT -> Compression -> Verbosity -> IO (RepositoryConsistency rt p wR) data RepositoryConsistency rt p wX RepositoryConsistent :: RepositoryConsistency rt p wX BrokenPristine :: Tree IO -> RepositoryConsistency rt p wX BrokenPatches :: Tree IO -> PatchSet rt p Origin wX -> RepositoryConsistency rt p wX -- | Packs are an optimization that enable faster repository cloning over -- HTTP. A pack is actually a tar.gz 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 createPacks: -- --
    --
  1. The basic pack, contains the latest recorded version of the -- working tree.
  2. --
  3. The patches pack, contains the set of patches of the -- repository.
  4. --
-- -- The paths of these files are _darcs/packs/basic.tar.gz and -- _darcs/packs/patches.tar.gz. There is also -- _darcs/packs/pristine 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 :: [String] -> Cache -> FilePath -> IO () packsDir :: String -- | Create packs from the current recorded version of the repository. createPacks :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wT -> IO () module Darcs.Repository.Merge tentativelyMergePatches :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> String -> AllowConflicts -> ExternalMerge -> WantGuiPause -> Compression -> Verbosity -> Reorder -> (UseIndex, ScanKnown, DiffAlgorithm) -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU)) considerMergeToWorking :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> String -> AllowConflicts -> ExternalMerge -> WantGuiPause -> Compression -> Verbosity -> Reorder -> (UseIndex, ScanKnown, DiffAlgorithm) -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU)) instance GHC.Classes.Eq Darcs.Repository.Merge.MakeChanges module Darcs.Repository.Match -- | Create a new pristine and working tree in the current working -- directory, corresponding to the state of the PatchSet returned -- by getOnePatchSet for the same PatchSetMatch. getRecordedUpToMatch :: (ApplyMonad (ApplyState p) DefaultIO, IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> PatchSetMatch -> IO () getOnePatchset :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wR -> PatchSetMatch -> IO (SealedPatchSet rt p Origin) -- | Generic wrapper for prim patches to give them an identity. module Darcs.Patch.Prim.WithName -- | A PrimWithName 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 name -- 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 (Darcs.Patch.Ident.SignedId name, Darcs.Patch.Witnesses.Eq.Eq2 p) => Darcs.Patch.Ident.IdEq2 (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.Annotate p => Darcs.Patch.Annotate.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.PrimClassify p => Darcs.Patch.Prim.Class.PrimClassify (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) -- | Conflictors a la camp. -- -- Similar to the camp paper, but with a few differences: -- -- 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 insert. (+|) :: Ord a => a -> Set a -> Set a infixr 9 +| -- | A handy synonym for delete. (-|) :: 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.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.StorableId name, Darcs.Patch.Prim.Class.PrimPatch prim) => Darcs.Patch.Show.ShowPatchBasic (Darcs.Patch.V3.Core.RepoPatchV3 name prim) -- | Conflict resolution for RepoPatchV3 module Darcs.Patch.V3.Resolution instance (GHC.Show.Show name, Darcs.Patch.Witnesses.Show.Show2 prim) => GHC.Show.Show (Darcs.Patch.V3.Resolution.Node name prim wY) 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 SHA1 hash of the non-inverted meta -- data (PatchInfo) plus an Int for the sequence number -- within the named patch, starting with 1. The Int 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 PrimPatchIds. 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 PrimPatchId. 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.Repository.Working applyToWorking :: (ApplyState p ~ Tree, RepoPatch p) => Repository rt p wR wU wT -> Verbosity -> FL (PrimOf p) wU wY -> IO (Repository rt p wR wY wT) setScriptsExecutable :: IO () setScriptsExecutablePatches :: PatchInspect p => p wX wY -> IO () module Darcs.Repository.Test getTest :: Verbosity -> IO (IO ExitCode) runPosthook :: HookConfig -> Verbosity -> AbsolutePath -> IO ExitCode runPrehook :: HookConfig -> Verbosity -> AbsolutePath -> IO ExitCode testTentative :: Repository rt p wR wU wT -> RunTest -> LeaveTestDir -> SetScriptsExecutable -> Verbosity -> IO ExitCode -- | A set of functions to identify and find Darcs repositories from a -- given URL or a given filesystem path. module Darcs.Repository.Identify -- | Tries to identify the repository in a given directory maybeIdentifyRepository :: UseCache -> String -> IO (IdentifyRepo rt p wR wU wT) -- | identifyRepository identifies the repo at url. Warning: you -- have to know what kind of patches are found in that repo. identifyRepository :: UseCache -> String -> IO (Repository rt p wR wU wT) -- | identifyRepositoryFor repo url identifies (and returns) the -- repo at url, but fails if it is not compatible for reading -- from and writing to. identifyRepositoryFor :: ReadingOrWriting -> Repository rt p wR wU wT -> UseCache -> String -> IO (Repository rt p vR vU vT) -- | The status of a given directory: is it a darcs repository? data IdentifyRepo rt p wR wU wT -- | looks like a repository with some error BadRepository :: String -> IdentifyRepo rt p wR wU wT -- | safest guess NonRepository :: String -> IdentifyRepo rt p wR wU wT GoodRepository :: Repository rt p wR wU wT -> IdentifyRepo rt p wR wU wT 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 ())) -- | findAllReposInDir topDir returns all paths to repositories -- under topDir. findAllReposInDir :: FilePath -> IO [FilePath] module Darcs.Repository.Job -- | A RepoJob 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. RepoJob is used to wrap up the -- polymorphism, and the various functions that act on a RepoJob -- are responsible for instantiating the underlying action with the -- appropriate patch type. data RepoJob a -- | The most common RepoJob; the underlying action can accept any -- patch type that a darcs repository may use. RepoJob :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO a) -> RepoJob a -- | A job that only works on darcs 1 patches V1Job :: (forall wR wU. Repository ( 'RepoType 'NoRebase) (RepoPatchV1 Prim) wR wU wR -> IO a) -> RepoJob a -- | A job that only works on darcs 2 patches V2Job :: (forall rt wR wU. IsRepoType rt => Repository rt (RepoPatchV2 Prim) wR wU wR -> IO a) -> RepoJob a -- | A job that works on any repository where the patch type p has -- PrimOf p = Prim. -- -- This was added to support darcsden, which inspects the internals of V1 -- prim patches. -- -- In future this should be replaced with a more abstract inspection API -- as part of PrimPatch. PrimV1Job :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree, IsPrimV1 (PrimOf p)) => Repository rt p wR wU wR -> IO a) -> RepoJob a RebaseAwareJob :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO a) -> RepoJob a RebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a OldRebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a StartRebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a class ApplyState p ~ Tree => 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, unless this is a dry-run. withRepoLock :: DryRun -> UseCache -> UpdatePending -> UMask -> RepoJob a -> IO a -- | run a lock-taking job in an old-fashion repository. only used by -- `darcs optimize upgrade`. withOldRepoLock :: RepoJob 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 () -> IO () -- | apply a given RepoJob to a repository in the current working directory withRepository :: UseCache -> RepoJob a -> IO a -- | apply a given RepoJob to a repository in a given url withRepositoryLocation :: UseCache -> String -> RepoJob a -> IO a -- | If the RepoType of the given repo indicates that we have -- NoRebase, then Just the repo with the refined type, else -- Nothing. NB The amount of types we have to import to make this -- simple check is ridiculous! checkRepoIsNoRebase :: forall rt p wR wU wT. IsRepoType rt => Repository rt p wR wU wT -> Maybe (Repository ( 'RepoType 'NoRebase) p wR wU wT) 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. Subdirectories get a separator (slash) -- appended. 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). Subdirectories get a -- separator (slash) appended. 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. Subdirectories get a -- separator (slash) appended. unknownFileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath] -- | Return all files available under the original working directory that -- are modified (relative to the recorded state). Subdirectories get a -- separator (slash) appended. modifiedFileArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [FilePath] -- | Return an empty list. noArgs :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String] -- | Return the available prefs of the given kind. prefArgs :: String -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO [String] module Darcs.Repository.Create createRepository :: PatchFormat -> WithWorkingDir -> WithPatchIndex -> UseCache -> IO EmptyRepository createRepositoryV1 :: WithWorkingDir -> WithPatchIndex -> UseCache -> IO (Repository ( 'RepoType 'NoRebase) (RepoPatchV1 Prim) Origin Origin Origin) createRepositoryV2 :: WithWorkingDir -> WithPatchIndex -> UseCache -> IO (Repository ( 'RepoType 'NoRebase) (RepoPatchV2 Prim) Origin Origin Origin) data EmptyRepository [EmptyRepository] :: (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'NoRebase) p Origin Origin Origin -> EmptyRepository writePristine :: FilePath -> Tree IO -> IO () module Darcs.Repository.Clone cloneRepository :: String -> String -> Verbosity -> UseCache -> CloneKind -> UMask -> RemoteDarcs -> SetScriptsExecutable -> RemoteRepos -> SetDefault -> InheritDefault -> [MatchFlag] -> RepoFormat -> WithWorkingDir -> WithPatchIndex -> Bool -> ForgetParent -> IO () -- | Replace the existing pristine with a new one (loaded up in a Tree -- object). replacePristine :: Repository rt p wR wU wT -> Tree IO -> IO () module Darcs.Repository -- | A Repository is a token representing the state of a -- repository on disk. It is parameterized by the patch type in the -- repository, and witnesses for the recorded state of the repository -- (i.e. what darcs get would retrieve), the unrecorded state (what's in -- the working tree now), and the tentative state, which represents work -- in progress that will eventually become the new recorded state unless -- something goes wrong. data Repository (rt :: RepoType) (p :: * -> * -> *) wRecordedstate wUnrecordedstate wTentativestate repoLocation :: Repository rt p wR wU wT -> String repoFormat :: Repository rt p wR wU wT -> RepoFormat repoPristineType :: Repository rt p wR wU wT -> PristineType repoCache :: Repository rt p wR wU wT -> Cache data PristineType NoPristine :: PristineType PlainPristine :: PristineType HashedPristine :: PristineType 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] mkCache :: [CacheLoc] -> Cache -- | Prints an error message with a list of bad caches. reportBadSources :: IO () -- | A RepoJob 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. RepoJob is used to wrap up the -- polymorphism, and the various functions that act on a RepoJob -- are responsible for instantiating the underlying action with the -- appropriate patch type. data RepoJob a -- | The most common RepoJob; the underlying action can accept any -- patch type that a darcs repository may use. RepoJob :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO a) -> RepoJob a -- | A job that only works on darcs 1 patches V1Job :: (forall wR wU. Repository ( 'RepoType 'NoRebase) (RepoPatchV1 Prim) wR wU wR -> IO a) -> RepoJob a -- | A job that only works on darcs 2 patches V2Job :: (forall rt wR wU. IsRepoType rt => Repository rt (RepoPatchV2 Prim) wR wU wR -> IO a) -> RepoJob a -- | A job that works on any repository where the patch type p has -- PrimOf p = Prim. -- -- This was added to support darcsden, which inspects the internals of V1 -- prim patches. -- -- In future this should be replaced with a more abstract inspection API -- as part of PrimPatch. PrimV1Job :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree, IsPrimV1 (PrimOf p)) => Repository rt p wR wU wR -> IO a) -> RepoJob a RebaseAwareJob :: (forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO a) -> RepoJob a RebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a OldRebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a StartRebaseJob :: (forall p wR wU. (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'IsRebase) p wR wU wR -> IO a) -> RepoJob a -- | Tries to identify the repository in a given directory maybeIdentifyRepository :: UseCache -> String -> IO (IdentifyRepo rt p wR wU wT) -- | identifyRepositoryFor repo url identifies (and returns) the -- repo at url, but fails if it is not compatible for reading -- from and writing to. identifyRepositoryFor :: ReadingOrWriting -> Repository rt p wR wU wT -> UseCache -> String -> IO (Repository rt p vR vU vT) data ReadingOrWriting Reading :: ReadingOrWriting Writing :: ReadingOrWriting withRecorded :: Repository rt p wR wU wT -> ((AbsolutePath -> IO a) -> IO a) -> (AbsolutePath -> IO a) -> IO a -- | 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, unless this is a dry-run. withRepoLock :: DryRun -> UseCache -> UpdatePending -> UMask -> RepoJob 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 () -> IO () -- | apply a given RepoJob to a repository in the current working directory withRepository :: UseCache -> RepoJob a -> IO a -- | apply a given RepoJob to a repository in a given url withRepositoryLocation :: UseCache -> String -> RepoJob 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). replacePristine :: Repository rt p wR wU wT -> Tree IO -> IO () -- | Read inventories and patches from a repository and return them as a -- PatchSet. Note that patches and inventories are read lazily. readRepo :: (IsRepoType rt, RepoPatch p) => Repository rt p wR wU wT -> IO (PatchSet rt p Origin wR) prefsUrl :: FilePath -> String -- | Add an FL 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 rt p wR wU wR -> UseIndex -> FL (PrimOf p) wU wY -> IO () -- | Add an FL of patches started from the pending state to the -- pending patch. TODO: add witnesses for pending so we can make the -- types precise: currently the passed patch can be applied in any -- context, not just after pending. addPendingDiffToPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> FreeLeft (FL (PrimOf p)) -> IO () tentativelyAddPatch :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> Compression -> Verbosity -> UpdatePending -> PatchInfoAnd rt p wT wY -> IO (Repository rt p wR wU wY) tentativelyRemovePatches :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> Compression -> UpdatePending -> FL (PatchInfoAnd rt p) wX wT -> IO (Repository rt p wR wU wX) -- | tentativelyAddToPending repo ps appends ps to the -- pending patch. -- -- This fuction is unsafe because it accepts a patch that works on the -- tentative pending and we don't currently track the state of the -- tentative pending. tentativelyAddToPending :: forall rt p wR wU wT wX wY. RepoPatch p => Repository rt p wR wU wT -> FL (PrimOf p) wX wY -> IO () -- | readRepo returns the tentative repo patchset. readTentativeRepo :: (IsRepoType rt, PatchListFormat p, ReadPatch p) => Repository rt p wR wU wT -> String -> IO (PatchSet rt p Origin wT) withManualRebaseUpdate :: forall rt p x wR wU wT1 wT2. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT1 -> (Repository rt p wR wU wT1 -> IO (Repository rt p wR wU wT2, FL (RebaseFixup (PrimOf p)) wT2 wT1, x)) -> IO (Repository rt p wR wU wT2, x) tentativelyMergePatches :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> String -> AllowConflicts -> ExternalMerge -> WantGuiPause -> Compression -> Verbosity -> Reorder -> (UseIndex, ScanKnown, DiffAlgorithm) -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wR wY -> IO (Sealed (FL (PrimOf p) wU)) considerMergeToWorking :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> String -> AllowConflicts -> ExternalMerge -> WantGuiPause -> Compression -> Verbosity -> Reorder -> (UseIndex, ScanKnown, DiffAlgorithm) -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt 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 rt p wR wU wT -> UpdatePending -> IO (Repository rt p wR 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, and the index. finalizeRepositoryChanges :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> UpdatePending -> Compression -> IO (Repository rt p wT wU wT) createRepository :: PatchFormat -> WithWorkingDir -> WithPatchIndex -> UseCache -> IO EmptyRepository createRepositoryV1 :: WithWorkingDir -> WithPatchIndex -> UseCache -> IO (Repository ( 'RepoType 'NoRebase) (RepoPatchV1 Prim) Origin Origin Origin) createRepositoryV2 :: WithWorkingDir -> WithPatchIndex -> UseCache -> IO (Repository ( 'RepoType 'NoRebase) (RepoPatchV2 Prim) Origin Origin Origin) data EmptyRepository [EmptyRepository] :: (RepoPatch p, ApplyState p ~ Tree) => Repository ( 'RepoType 'NoRebase) p Origin Origin Origin -> EmptyRepository cloneRepository :: String -> String -> Verbosity -> UseCache -> CloneKind -> UMask -> RemoteDarcs -> SetScriptsExecutable -> RemoteRepos -> SetDefault -> InheritDefault -> [MatchFlag] -> RepoFormat -> WithWorkingDir -> WithPatchIndex -> Bool -> ForgetParent -> IO () applyToWorking :: (ApplyState p ~ Tree, RepoPatch p) => Repository rt p wR wU wT -> Verbosity -> FL (PrimOf p) wU wY -> IO (Repository rt p wR wY wT) -- | grab the pristine hash of _darcs/hash_inventory, and retrieve whole -- pristine tree, possibly writing a clean working tree in the process. createPristineDirectoryTree :: Repository rt p wR wU wT -> FilePath -> WithWorkingDir -> IO () -- | Used by the commands dist and diff createPartialsPristineDirectoryTree :: Repository rt p wR wU wT -> [AnchoredPath] -> FilePath -> 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. -- -- Specifically, 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. reorderInventory :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> Compression -> IO () cleanRepository :: Repository rt p wR wU wT -> 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 PatchSet 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 -- PatchSet contains the whole history, the first witness is -- always forced to be Origin. The type still has two witnesses so -- it can easily be used with combinators like :> and -- Fork. -- -- The history is lazily loaded from disk so does not normally need to be -- all kept in memory. data PatchSet rt p wStart wY type SealedPatchSet rt p wStart = Sealed ((PatchSet rt p) wStart) type PatchInfoAnd rt p = PatchInfoAndG rt (Named p) setScriptsExecutable :: IO () setScriptsExecutablePatches :: PatchInspect p => p wX wY -> IO () testTentative :: Repository rt p wR wU wT -> RunTest -> LeaveTestDir -> SetScriptsExecutable -> Verbosity -> IO ExitCode modifyCache :: (Cache -> Cache) -> Repository rt p wR wU wT -> Repository rt p wR wU wT -- | 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. readRecorded :: Repository rt p wR wU wT -> 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 wR wU wR -> UseIndex -> Maybe [AnchoredPath] -> IO (Tree IO) -- | For a repository and an optional list of paths (when Nothing, -- 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: -- -- -- -- 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) => (UseIndex, ScanKnown, DiffAlgorithm) -> LookForMoves -> LookForReplaces -> Repository rt p wR wU wR -> Maybe [AnchoredPath] -> IO (FL (PrimOf p) wR wU) readPendingAndWorking :: (RepoPatch p, ApplyState p ~ Tree) => (UseIndex, ScanKnown, DiffAlgorithm) -> LookForMoves -> LookForReplaces -> Repository rt p wR 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 wR wU wR -> FL (PatchInfoAnd rt p) wX wR -> FL (PatchInfoAnd rt p) wX wZ -> IO (Bool, Sealed (FL (PatchInfoAnd rt p) wX)) -- | Obtains the recorded Tree with the pending patch applied. readRecordedAndPending :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO (Tree IO) readIndex :: (RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wR -> IO Index -- | Mark the existing index as invalid. This has to be called whenever the -- listing of pristine changes and will cause darcs to update the index -- next time it tries to read it. (NB. This is about files added and -- removed from pristine: changes to file content in either pristine or -- working are handled transparently by the index reading code.) invalidateIndex :: t -> IO () 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. -- -- First: ask for an initial segment, first patches first (default -- for all pull-like commands) -- -- FirstReversed: ask for an initial segment, last patches first -- (used to ask about dependencies in record, and for pull-like commands -- with the --reverse flag). -- -- LastReversed: ask for a final segment, last patches first. -- (default for unpull-like commands, except for selecting *primitive* -- patches in rollback) -- -- Last: ask for a final segment, first patches first. (used for -- selecting primitive patches in rollback, and for unpull-like commands -- with the --reverse 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 runSelection for the darcs log -- 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 wO wR -> PatchSelectionOptions -> (forall wA. (FL p :> p) wA wR -> IO ()) -> IO () -- | Run a PatchSelection action in the given -- SelectionConfig, 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 PatchSelection action in the given -- SelectionConfig, 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 SelectionConfig for selecting Prim patches. selectionConfigPrim :: WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter prim) -> Maybe [AnchoredPath] -> Maybe (Tree IO) -> SelectionConfig prim -- | A generic SelectionConfig. selectionConfigGeneric :: Matchable p => (forall wX wY. q wX wY -> Sealed2 p) -> WhichChanges -> String -> PatchSelectionOptions -> Maybe [AnchoredPath] -> SelectionConfig q -- | A SelectionConfig for selecting full (Matchable) 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 -> WithContext -> PatchSelectionOptions [verbosity] :: PatchSelectionOptions -> Verbosity [matchFlags] :: PatchSelectionOptions -> [MatchFlag] [interactive] :: PatchSelectionOptions -> Bool [selectDeps] :: PatchSelectionOptions -> SelectDeps [withSummary] :: PatchSelectionOptions -> WithSummary [withContext] :: PatchSelectionOptions -> WithContext 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 Sealed2 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 () -- | decide True selects the current patch, and decide -- False deselects it. decide :: Commute p => Bool -> LabelledPatch p wT wU -> InteractiveSelectionM p wX wY () -- | like decide, but for all patches touching file decideWholeFile :: (Commute p, PatchInspect p) => AnchoredPath -> Bool -> InteractiveSelectionM p wX wY () isSingleFile :: PatchInspect p => p wX wY -> Bool -- | returns Just f if the currentPatch only modifies -- f, Nothing 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 keyPress groups. keysFor :: [[KeyPress]] -> [Char] -- | Generates the help for a set of basic and advanced KeyPress -- groups. helpFor :: String -> [[KeyPress]] -> [[KeyPress]] -> String askAboutDepends :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> FL (PrimOf p) wT wY -> 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 -- -- -- -- 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 :: forall prim wX wY. PrimPatch prim => Maybe String -> Bool -> Logfile -> Maybe AskLongComment -> Maybe (String, [String]) -> FL prim wX wY -> IO (String, [String], Maybe String) -- | getAuthor tries to return the updated author for the patch. -- There are two different scenarios: -- -- getAuthor :: String -> Bool -> Maybe String -> PatchInfo -> HijackT IO String -- | Update the metadata for a patch. This potentially involves a bit of -- interactivity, so we may return Nothing if there is cause to -- abort what we're doing along the way updatePatchHeader :: forall rt p wX wY wR wU wT. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => String -> AskAboutDeps rt p wR wU wT -> PatchSelectionOptions -> DiffAlgorithm -> Bool -> Bool -> Maybe String -> Maybe String -> Maybe AskLongComment -> Named (PrimOf p) wT wX -> FL (PrimOf p) wX wY -> HijackT IO (Maybe String, PatchInfoAnd rt p wT wY) -- | specify whether to ask about dependencies with respect to a particular -- repository, or not data AskAboutDeps rt p wR wU wT AskAboutDeps :: Repository rt p wR wU wT -> AskAboutDeps rt p wR wU wT NoAskAboutDeps :: AskAboutDeps rt p wR wU wT -- | 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 RequestHijackPermission for initial values runHijackT :: Monad m => HijackOptions -> HijackT m a -> m a module Darcs.UI.Commands data CommandControl CommandData :: DarcsCommand -> CommandControl HiddenCommand :: DarcsCommand -> CommandControl GroupName :: String -> CommandControl -- | A DarcsCommand 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]) -> [DarcsOptDescr DarcsFlag] -> [DarcsOptDescr DarcsFlag] -> [DarcsFlag] -> ([DarcsFlag] -> [String]) -> 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] [commandBasicOptions] :: DarcsCommand -> [DarcsOptDescr DarcsFlag] [commandAdvancedOptions] :: DarcsCommand -> [DarcsOptDescr DarcsFlag] [commandDefaults] :: DarcsCommand -> [DarcsFlag] [commandCheckOptions] :: DarcsCommand -> [DarcsFlag] -> [String] 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 commandOptions :: AbsolutePath -> DarcsCommand -> [OptDescr DarcsFlag] commandAlloptions :: DarcsCommand -> ([DarcsOptDescr DarcsFlag], [DarcsOptDescr DarcsFlag]) withStdOpts :: DarcsOption (Maybe StdCmdAction -> Verbosity -> b) c -> DarcsOption (UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a) b -> DarcsOption a c 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 rt 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 () 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.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 wR wU wR -> Verbosity -> UseIndex -> ScanKnown -> LookForMoves -> [AnchoredPath] -> IO ([AnchoredPath], [AnchoredPath]) testTentativeAndMaybeExit :: Repository rt p wR wU wT -> Verbosity -> TestChanges -> SetScriptsExecutable -> Bool -> String -> String -> Maybe String -> IO () -- | printDryRunMessageAndExit action flags patches prints -- a string representing the action that would be taken if the -- --dry-run option had not been passed to darcs. Then darcs -- exits successfully. action is the name of the action being -- taken, like "push" flags is the list of flags which -- were sent to darcs patches is the sequence of patches which -- would be touched by action. printDryRunMessageAndExit :: RepoPatch p => String -> Verbosity -> WithSummary -> DryRun -> XmlOutput -> Bool -> FL (PatchInfoAnd rt p) wX wY -> IO () getUniqueRepositoryName :: Bool -> FilePath -> IO FilePath getUniqueDPatchName :: FilePath -> IO FilePath doesDirectoryReallyExist :: FilePath -> IO Bool checkUnrelatedRepos :: RepoPatch p => Bool -> PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> IO () preselectPatches :: (IsRepoType rt, RepoPatch p) => [DarcsFlag] -> Repository rt p wR wU wT -> IO ((PatchSet rt p :> FL (PatchInfoAnd rt p)) Origin wR) getLastPatches :: RepoPatch p => [MatchFlag] -> PatchSet rt p Origin wR -> (PatchSet rt p :> FL (PatchInfoAnd rt p)) Origin wR matchRange :: MatchableRP p => [MatchFlag] -> PatchSet rt p Origin wY -> Sealed2 (FL (PatchInfoAnd rt p)) historyEditHelp :: Doc module Darcs.UI.Commands.WhatsNew whatsnew :: DarcsCommand -- | An alias for whatsnew, with implicit -l (and thus -- implicit -s) flags. We override the default description, to -- include these flags. status :: DarcsCommand module Darcs.UI.Commands.Unrevert unrevert :: DarcsCommand writeUnrevert :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => Repository rt p wR wU wT -> FL (PrimOf p) wX wY -> Tree IO -> FL (PrimOf p) wR wX -> IO () 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 instance GHC.Show.Show Darcs.UI.Commands.Test.BisectDir 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 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.Show.Show Darcs.UI.Commands.Move.FileStatus instance GHC.Classes.Eq Darcs.UI.Commands.Move.FileKind instance GHC.Show.Show Darcs.UI.Commands.Move.FileKind 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 rt p wStart wX. (ShowPatch p, PatchListFormat p, Summary p, HasDeps p, PrimDetails (PrimOf p)) => [DarcsFlag] -> RL (PatchInfoAndG rt p) wStart wX -> LogInfo (PatchInfoAndG rt p) -> Doc logInfoFL :: FL p wX wY -> LogInfo p simpleLogInfo :: (MatchableRP p, ApplyState p ~ Tree) => AnchoredPath -> PatchFilter rt p -> PatchSet rt p Origin wY -> IO [Sealed2 (PatchInfoAnd rt 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.Object instance GHC.Show.Show Darcs.UI.Commands.Convert.Import.CopyRenameNames instance GHC.Show.Show Darcs.UI.Commands.Convert.Import.RefId instance GHC.Show.Show (Darcs.UI.Commands.Convert.Import.State p) module Darcs.UI.Commands.Convert.Export convertExport :: DarcsCommand 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 pullapply and rebase -- pullapply. class PatchApplier pa where { type family ApplierRepoTypeConstraint pa (rt :: RepoType) :: Constraint; } repoJob :: PatchApplier pa => pa -> (forall rt p wR wU. (IsRepoType rt, ApplierRepoTypeConstraint pa rt, RepoPatch p, ApplyState p ~ Tree) => PatchProxy p -> Repository rt p wR wU wR -> IO ()) -> RepoJob () applyPatches :: forall rt p wR wU wZ. (PatchApplier pa, ApplierRepoTypeConstraint pa rt, IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => pa -> PatchProxy p -> String -> [DarcsFlag] -> Repository rt p wR wU wR -> Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wR wZ -> IO () data PatchProxy (p :: * -> * -> *) PatchProxy :: PatchProxy data StandardPatchApplier StandardPatchApplier :: StandardPatchApplier applyPatchesStart :: (RepoPatch p, ApplyState p ~ Tree) => String -> [DarcsFlag] -> FL (PatchInfoAnd rt p) wX wY -> IO () applyPatchesFinish :: (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => String -> [DarcsFlag] -> Repository rt p wR 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 :: forall rt p wR wU. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) => AbsolutePath -> [DarcsFlag] -> [String] -> String -> Repository rt p wR wU wR -> IO (Sealed (Fork (PatchSet rt p) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) Origin wR)) module Darcs.UI.Commands.Apply apply :: DarcsCommand applyCmd :: PatchApplier pa => pa -> (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO () getPatchBundle :: RepoPatch p => [DarcsFlag] -> PatchSet rt p Origin wR -> ByteString -> IO (Either String (SealedPatchSet rt 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 DarcsFlags (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 -- -- -- -- Note that the pseudo command ALL 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 -- ALL 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]) -- | 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 ()