David,

I don't think the last patch will compile with modules that use select
changes but I do think this version might be what you were expecting.  If
so I'll amend-record the last patch so that it compiles everywhere.

Let me know what you think.

Thanks,
Jason

Tue Aug 12 20:16:25 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * major refactor of SelectChanges to work with type witnesses

Tue Aug 12 22:04:25 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * refine type witnesses in SelectChanges

Thu Aug 14 22:39:58 PDT 2008  Jason Dagit <[EMAIL PROTECTED]>
  * Potentially correct SelectChanges

New patches:

[major refactor of SelectChanges to work with type witnesses
Jason Dagit <[EMAIL PROTECTED]>**20080813031625] hunk ./src/Darcs/Commands/AmendRecord.lhs 120
-    with_selected_patch_from_repo "amend" repository opts True $ \ (oldp, _) -> do
+    with_selected_patch_from_repo "amend" repository opts True $ \ (_ :> oldp) -> do
hunk ./src/Darcs/SelectChanges.lhs 45
-                     fromPrims, invert, list_touched_files, anonymous )
+                     fromPrims, invert, list_touched_files, anonymous,
+                     commuteFL )
hunk ./src/Darcs/SelectChanges.lhs 48
-import Darcs.Patch.Ordered ( FL(..), RL(..), (:<)(..), (:>)(..),
+import Darcs.Patch.Ordered ( FL(..), RL(..), (:>)(..),
hunk ./src/Darcs/SelectChanges.lhs 50
-                             spanFL, reverseFL, (+<+), mapFL )
+                             spanFL, reverseFL, (+<+), mapFL, reverseRL,
+                             unsafeCoerceP )
hunk ./src/Darcs/SelectChanges.lhs 70
-import Darcs.Sealed ( Sealed(..), seal )
+import Darcs.Sealed ( Sealed(..), FlippedSeal(..), seal, flipSeal, seal2, unseal2 )
hunk ./src/Darcs/SelectChanges.lhs 77
-type WithPatches p a =
+
+type WithPatches p a C(x y) =
hunk ./src/Darcs/SelectChanges.lhs 82
-     -> FL p                -- patches to select among
-     -> (FL p :> FL p -> IO a) -- job
+     -> FL p C(x y)         -- patches to select among
+     -> (FORALL(m n) (FL p :> FL p) C(m n) -> IO a) -- job
hunk ./src/Darcs/SelectChanges.lhs 87
-type WithPatchesToFiles p a =
+type WithPatchesToFiles p a C(x y) =
hunk ./src/Darcs/SelectChanges.lhs 92
-     -> FL p                -- patches to select among
-     -> (FL p :> FL p -> IO a) -- job
+     -> FL p C(x y)         -- patches to select among
+     -> (FORALL(m n) (FL p :> FL p) C(m n) -> IO a) -- job
hunk ./src/Darcs/SelectChanges.lhs 96
-with_selected_changes'               :: WithPatches Prim a
-with_selected_changes_to_files'      :: WithPatchesToFiles Prim a
-with_selected_last_changes_to_files' :: WithPatchesToFiles Prim a
-with_selected_last_changes_reversed' :: WithPatches Prim a
-                                     
+with_selected_changes'
+  :: WithPatches Prim a C(x y)
+with_selected_changes_to_files'
+  :: WithPatchesToFiles Prim a C(x y)
+with_selected_last_changes_to_files'
+  :: WithPatchesToFiles Prim a C(x y)
+with_selected_last_changes_reversed'
+  :: WithPatches Prim a C(x y)
+
hunk ./src/Darcs/SelectChanges.lhs 110
-with_selected_changes               :: RepoPatch p => WithPatches (PatchInfoAnd p) a
-with_selected_changes_to_files      :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a
-with_selected_changes_reversed      :: RepoPatch p => WithPatches (PatchInfoAnd p) a
-with_selected_last_changes_to_files :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a
-with_selected_last_changes_to_files_reversed :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a
-with_selected_last_changes_reversed :: RepoPatch p => WithPatches (PatchInfoAnd p) a
-                                    
+with_selected_changes               :: RepoPatch p => WithPatches (PatchInfoAnd p) a C(x y)
+with_selected_changes_to_files      :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a C(x y)
+with_selected_changes_reversed      :: RepoPatch p => WithPatches (PatchInfoAnd p) a C(x y)
+with_selected_last_changes_to_files :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a C(x y)
+with_selected_last_changes_to_files_reversed :: RepoPatch p => WithPatchesToFiles (PatchInfoAnd p) a C(x y)
+with_selected_last_changes_reversed :: RepoPatch p => WithPatches (PatchInfoAnd p) a C(x y)
+
hunk ./src/Darcs/SelectChanges.lhs 127
-wasc  :: Patchy p => WhichChanges -> WithPatches p a
+wasc  :: Patchy p => WhichChanges -> WithPatches p a C(x y)
hunk ./src/Darcs/SelectChanges.lhs 129
-wasc_ :: Patchy p => WhichChanges -> WithPatchesToFiles p a
+wasc_ :: Patchy p => WhichChanges -> WithPatchesToFiles p a C(x y)
hunk ./src/Darcs/SelectChanges.lhs 132
-wasc'  :: RepoPatch p => WhichChanges -> WithPatches (PatchInfoAnd p) a
+wasc'
+  :: RepoPatch p => WhichChanges -> WithPatches (PatchInfoAnd p) a C(x y)
hunk ./src/Darcs/SelectChanges.lhs 135
-wasc_' :: RepoPatch p => WhichChanges -> WithPatchesToFiles (PatchInfoAnd p) a
+wasc_'
+  :: RepoPatch p => WhichChanges -> WithPatchesToFiles (PatchInfoAnd p) a C(x y)
hunk ./src/Darcs/SelectChanges.lhs 139
-with_any_selected_changes :: Patchy p => WhichChanges -> WithPatchesToFiles p a
-with_any_selected_changes wch jn opts s fs =
-    with_any_selected_changes_ wch (patches_to_consider (Just wch) fs) jn opts s fs
+with_any_selected_changes :: Patchy p => WhichChanges -> WithPatchesToFiles p a C(x y)
+with_any_selected_changes Last jn opts s fs =
+    with_any_selected_changes_last (patches_to_consider_last fs) jn opts s fs
+with_any_selected_changes First jn opts s fs =
+    with_any_selected_changes_first (patches_to_consider_first fs) jn opts s fs
+with_any_selected_changes FirstReversed jn opts s fs =
+    with_any_selected_changes_first_reversed (patches_to_consider_first_reversed fs) jn opts s fs
+with_any_selected_changes LastReversed jn opts s fs =
+    with_any_selected_changes_last_reversed (patches_to_consider_last_reversed fs) jn opts s fs
hunk ./src/Darcs/SelectChanges.lhs 149
-with_any_selected_changes' :: RepoPatch p => WhichChanges -> WithPatchesToFiles (PatchInfoAnd p) a
-with_any_selected_changes' wch jn opts s fs =
-    with_any_selected_changes_ wch (patches_to_consider' (Just wch) fs opts) jn opts s fs
hunk ./src/Darcs/SelectChanges.lhs 150
-view_changes :: RepoPatch p => [DarcsFlag] -> Slurpy -> [FilePath] -> FL (PatchInfoAnd p) -> IO ()
+with_any_selected_changes'
+  :: RepoPatch p => WhichChanges -> WithPatchesToFiles (PatchInfoAnd p) a C(x y)
+with_any_selected_changes' Last jn opts s fs =
+    with_any_selected_changes_last (patches_to_consider_last' fs opts) jn opts s fs
+with_any_selected_changes' First jn opts s fs =
+    with_any_selected_changes_first (patches_to_consider_first' fs opts) jn opts s fs
+with_any_selected_changes' FirstReversed jn opts s fs =
+    with_any_selected_changes_first_reversed (patches_to_consider_first_reversed' fs opts) jn opts s fs
+with_any_selected_changes' LastReversed jn opts s fs =
+    with_any_selected_changes_last_reversed (patches_to_consider_last_reversed' fs opts) jn opts s fs
+
+view_changes :: RepoPatch p => [DarcsFlag] -> Slurpy -> [FilePath] -> FL (PatchInfoAnd p) C(x y) -> IO ()
hunk ./src/Darcs/SelectChanges.lhs 163
- without_buffering $ do text_view opts ps_len 0 NilRL init_tps init_pc
-                        return ()
- where ps_to_consider :> _ = patches_to_consider' Nothing fp opts ps
-       (init_pc, init_tps) = patch_choices_tps ps_to_consider
-       ps_len = lengthFL init_tps
+  case patches_to_consider_nothing' fp opts ps of
+  ps_to_consider :> _ -> vc ps_to_consider
+ where
+       vc :: RepoPatch p => FL (PatchInfoAnd p) C(x y) -> IO ()
+       vc p = without_buffering $ do text_view opts ps_len 0 NilRL init_tps init_pc
+                                     return ()
+        where (init_pc, init_tps) = patch_choices_tps p
+              ps_len = lengthFL init_tps
hunk ./src/Darcs/SelectChanges.lhs 193
-with_selected_patch_from_repo :: RepoPatch p => String -> Repository p -> [DarcsFlag] -> Bool
-                              -> ((PatchInfoAnd p,[PatchInfoAnd p]) -> IO ()) -> IO ()
+with_selected_patch_from_repo :: RepoPatch p => String -> Repository p C(r u t) -> [DarcsFlag] -> Bool
+                              -> (FORALL(a b) ((FL (PatchInfoAnd p) :> (PatchInfoAnd p)) C(a b)) -> IO ()) -> IO ()
hunk ./src/Darcs/SelectChanges.lhs 198
-                   then return $ seal NilFL
+                   then return $ seal (NilFL :: FL Prim C(r r))
hunk ./src/Darcs/SelectChanges.lhs 201
-                              (concatRL p_s) [n2pia $ anonymous $ fromPrims pend]
+                              (concatRL p_s) ((n2pia $ anonymous $ fromPrims pend) :>: NilFL)
hunk ./src/Darcs/SelectChanges.lhs 203
-        Just (selected, s_and_pend) ->
-          case (last s_and_pend, init s_and_pend) of
-          (pend',skipped) ->
+        Just (FlippedSeal (s_and_pend :> selected)) ->
+           case reverseFL s_and_pend of
+           pend':<:skipped ->
hunk ./src/Darcs/SelectChanges.lhs 207
-            Just (selected' :> _) -> job (selected', skipped)
+            Just (selected' :> _) -> job (reverseRL skipped :> selected')
hunk ./src/Darcs/SelectChanges.lhs 209
+           NilRL -> bug "empty selected and pending in with_selected_patch_from_repo" -- The previous version of this
+                                                                                      -- function didn't check this case.
hunk ./src/Darcs/SelectChanges.lhs 214
-wspfr :: RepoPatch p => String -> (PatchInfoAnd p -> Bool)
-      -> RL (PatchInfoAnd p) -> [PatchInfoAnd p]
-      -> IO (Maybe (PatchInfoAnd p, [PatchInfoAnd p]))
+wspfr :: RepoPatch p => String -> (FORALL(a b) (PatchInfoAnd p) C(a b) -> Bool)
+      -> RL (PatchInfoAnd p) C(x y) -> FL (PatchInfoAnd p) C(y z)
+      -> IO (Maybe (FlippedSeal (FL (PatchInfoAnd p) :> (PatchInfoAnd p)) C(z)))
hunk ./src/Darcs/SelectChanges.lhs 219
-    | not $ matches p = wspfr jn matches pps (p:skipped)
+    | not $ matches p = wspfr jn matches pps (p:>:skipped)
hunk ./src/Darcs/SelectChanges.lhs 221
-    case commute_by (skipped :< p) of
+    case commuteFL (p :> skipped) of
hunk ./src/Darcs/SelectChanges.lhs 224
-                  wspfr jn matches pps (p:skipped)
-    Just (p' :< skipped') -> do
+                  wspfr jn matches pps (p:>:skipped)
+    Just (skipped' :> p') -> do
hunk ./src/Darcs/SelectChanges.lhs 238
-        'y' -> return $ Just (p', skipped')
-        'n' -> wspfr jn matches pps (p:skipped)
+        'y' -> return $ Just $ flipSeal $ skipped' :> p'
+        'n' -> wspfr jn matches pps (p:>:skipped)
hunk ./src/Darcs/SelectChanges.lhs 249
-
-commute_by :: Patchy p => [p] :< p -> Maybe (p :< [p])
-commute_by ([] :< a) = Just (a :< [])
-commute_by (p:ps :< a) =
-    case commute (a :> p) of
-    Nothing -> Nothing
-    Just (p':>a') -> case commute_by (ps :< a') of
-                     Nothing -> Nothing
-                     Just (a'' :< ps') -> Just (a'' :< p':ps')
hunk ./src/Darcs/SelectChanges.lhs 252
-with_any_selected_changes_ :: Patchy p => WhichChanges
-                           -> (FL p -> FL p :> FL p)
-                           -> WithPatchesToFiles p a
-with_any_selected_changes_ whichch p2c
-                          jobname opts _ _ ps job =
-   if All `elem` opts || DryRun `elem` opts
-   then job $ case whichch of LastReversed -> invert other_ps :> invert ps_to_consider
-                              FirstReversed -> invert other_ps :> invert ps_to_consider
-                              _ -> ps_to_consider :> other_ps
-   else do pc <- without_buffering $
-                 tentatively_text_select "" jobname (Noun "patch") whichch
-                                        opts ps_len 0 NilRL init_tps init_pc
-           job $ selected_patches whichch rejected_ps pc
- where ps_to_consider :> other_ps = p2c ps
-       rejected_ps = if whichch == Last || whichch == FirstReversed then ps_to_consider else other_ps
-       (init_pc, init_tps) = patch_choices_tps $ case whichch of Last -> other_ps
-                                                                 FirstReversed -> other_ps
-                                                                 _ -> ps_to_consider
-       ps_len = lengthFL init_tps
+with_any_selected_changes_last :: forall p a C(x y). Patchy p
+                               => (FL p C(x y) -> (FL p :> FL p) C(x y))
+                               -> WithPatchesToFiles p a C(x y)
+with_any_selected_changes_last p2c jobname opts _ _ ps job =
+ case p2c ps of
+ ps_to_consider :> other_ps ->
+         if All `elem` opts || DryRun `elem` opts
+         then job $ ps_to_consider :> other_ps
+         else do pc <- without_buffering $
+                       tentatively_text_select "" jobname (Noun "patch") Last
+                                              opts ps_len 0 NilRL init_tps init_pc
+                 job $ selected_patches_last rejected_ps pc
+         where rejected_ps = ps_to_consider
+               ps_len = lengthFL init_tps
+               (init_pc, init_tps) = patch_choices_tps $ other_ps
+
+with_any_selected_changes_first :: forall p a C(x y). Patchy p
+                                => (FL p C(x y) -> (FL p :> FL p) C(x y))
+                                -> WithPatchesToFiles p a C(x y)
+with_any_selected_changes_first p2c jobname opts _ _ ps job =
+ case p2c ps of
+ ps_to_consider :> other_ps ->
+         if All `elem` opts || DryRun `elem` opts
+         then job $ ps_to_consider :> other_ps
+         else do pc <- without_buffering $
+                       tentatively_text_select "" jobname (Noun "patch") First
+                                              opts ps_len 0 NilRL init_tps init_pc
+                 job $ selected_patches_first rejected_ps pc
+         where rejected_ps = other_ps
+               ps_len = lengthFL init_tps
+               (init_pc, init_tps) = patch_choices_tps $ ps_to_consider
+
+with_any_selected_changes_first_reversed :: forall p a C(x y). Patchy p
+                                => (FL p C(x y) -> (FL p :> FL p) C(y x))
+                                -> WithPatchesToFiles p a C(x y)
+with_any_selected_changes_first_reversed p2c jobname opts _ _ ps job =
+ case p2c ps of
+ ps_to_consider :> other_ps ->
+         if All `elem` opts || DryRun `elem` opts
+         then job $ invert other_ps :> invert ps_to_consider
+         else do pc <- without_buffering $
+                       tentatively_text_select "" jobname (Noun "patch") FirstReversed
+                                             opts ps_len 0 NilRL init_tps init_pc
+                 job $ selected_patches_first_reversed rejected_ps pc
+         where rejected_ps = ps_to_consider
+               ps_len = lengthFL init_tps
+               (init_pc, init_tps) = patch_choices_tps other_ps
+
+with_any_selected_changes_last_reversed :: forall p a C(x y). Patchy p
+                                => (FL p C(x y) -> (FL p :> FL p) C(y x))
+                                -> WithPatchesToFiles p a C(x y)
+with_any_selected_changes_last_reversed p2c jobname opts _ _ ps job =
+ case p2c ps of
+ ps_to_consider :> other_ps ->
+         if All `elem` opts || DryRun `elem` opts
+         then job $ invert other_ps :> invert ps_to_consider
+         else do pc <- without_buffering $
+                       tentatively_text_select "" jobname (Noun "patch") LastReversed
+                                             opts ps_len 0 NilRL init_tps init_pc
+                 job $ selected_patches_last_reversed rejected_ps pc
+         where rejected_ps = other_ps
+               ps_len = lengthFL init_tps
+               (init_pc, init_tps) = patch_choices_tps ps_to_consider
+
+patches_to_consider_last :: Patchy p
+                    => [FilePath]  -- ^ files
+                    -> FL p C(x y) -- ^ patches
+                    -> (FL p :> FL p) C(x y)
+patches_to_consider_last [] ps = NilFL :> ps
+patches_to_consider_last fs ps =
+  tp_patches $ separate_middle_last_from_first $ select_not_touching fs
+             $ patch_choices $ ps
hunk ./src/Darcs/SelectChanges.lhs 325
-patches_to_consider :: Patchy p => Maybe WhichChanges
-                    -> [FilePath]  -- ^ files
-                    -> FL p     -- ^ patches
-                    -> (FL p :> FL p)
-patches_to_consider mwhichch fs ps =
-  let ps' = if mwhichch == Just LastReversed || mwhichch == Just FirstReversed then invert ps else ps
-      f = case mwhichch of Just Last -> separate_middle_last_from_first
-                           Just FirstReversed -> separate_middle_last_from_first
-                           _ -> separate_first_middle_from_last
-      deal_with_fs = case mwhichch of Just Last -> select_not_touching   fs
-                                      Just FirstReversed -> select_not_touching   fs
-                                      _ -> deselect_not_touching fs
-  in if null fs then if mwhichch == Just Last || mwhichch == Just FirstReversed then NilFL :> ps' else ps' :> NilFL
-                else tp_patches $ f $ deal_with_fs $ patch_choices ps'
+patches_to_consider_first :: Patchy p
+                    => [FilePath]  -- ^ files
+                    -> FL p C(x y) -- ^ patches
+                    -> (FL p :> FL p) C(x y)
+patches_to_consider_first [] ps = ps :> NilFL
+patches_to_consider_first fs ps =
+  tp_patches $ separate_first_middle_from_last $ deselect_not_touching fs
+             $ patch_choices $ ps
hunk ./src/Darcs/SelectChanges.lhs 334
-patches_to_consider' :: RepoPatch p => Maybe WhichChanges
-                     -> [FilePath]  -- ^ files
+patches_to_consider_first_reversed :: Patchy p
+                    => [FilePath]  -- ^ files
+                    -> FL p C(x y) -- ^ patches
+                    -> (FL p :> FL p) C(y x)
+patches_to_consider_first_reversed [] ps = NilFL :> (invert ps)
+patches_to_consider_first_reversed fs ps =
+  tp_patches $ separate_middle_last_from_first $ select_not_touching fs
+             $ patch_choices $ (invert ps)
+
+patches_to_consider_last_reversed :: Patchy p
+                    => [FilePath]  -- ^ files
+                    -> FL p C(x y) -- ^ patches
+                    -> (FL p :> FL p) C(y x)
+patches_to_consider_last_reversed [] ps = NilFL :> (invert ps)
+patches_to_consider_last_reversed fs ps =
+  tp_patches $ separate_first_middle_from_last $ deselect_not_touching fs
+             $ patch_choices $ (invert ps)
+
+patches_to_consider_first' :: RepoPatch p
+                     => [FilePath]  -- ^ files
hunk ./src/Darcs/SelectChanges.lhs 355
-                     -> FL (PatchInfoAnd p) -- ^ patches
-                     -> FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)
-patches_to_consider' mwhichch fs opts ps =
-  let ps' = if mwhichch == Just LastReversed || mwhichch == Just FirstReversed then invert ps else ps
-      f = case mwhichch of Just Last -> separate_middle_last_from_first
-                           Just FirstReversed -> separate_middle_last_from_first
-                           _ -> separate_first_middle_from_last
-      deal_with_fs = case mwhichch of Just Last -> select_not_touching   fs
-                                      Just FirstReversed -> select_not_touching   fs
-                                      _ -> deselect_not_touching fs
-      deselect_unwanted pc =
+                     -> FL (PatchInfoAnd p) C(x y) -- ^ patches
+                     -> (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) C(x y)
+patches_to_consider_first' fs opts ps =
+  let deselect_unwanted pc =
hunk ./src/Darcs/SelectChanges.lhs 360
-        then case mwhichch of
-             Just Last ->  bug "don't support patch matching with Last in wasp"
-             Just FirstReversed ->  bug "don't support patch matching with FirstReversed in wasp"
-             _ -> if DontGrabDeps `elem` opts
+        then if DontGrabDeps `elem` opts
hunk ./src/Darcs/SelectChanges.lhs 364
-      iswanted = let maybe_invert = if mwhichch == Just LastReversed || mwhichch == Just FirstReversed then invert else id
-                 in (match_a_patch opts . hopefully . maybe_invert . tp_patch)
+      iswanted = match_a_patch opts . hopefully . tp_patch
hunk ./src/Darcs/SelectChanges.lhs 366
-     then if mwhichch == Just Last || mwhichch == Just FirstReversed then NilFL :> ps' else ps' :> NilFL
-     else tp_patches $ f $ deal_with_fs $ deselect_unwanted $ patch_choices ps'
+     then ps :> NilFL
+     else tp_patches $ separate_first_middle_from_last $ deselect_not_touching fs
+                     $ deselect_unwanted $ patch_choices ps
+
+patches_to_consider_last' :: RepoPatch p
+                     => [FilePath]  -- ^ files
+                     -> [DarcsFlag] -- ^ opts
+                     -> FL (PatchInfoAnd p) C(x y) -- ^ patches
+                     -> (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) C(x y)
+patches_to_consider_last' fs opts ps =
+  let deselect_unwanted pc =
+        if have_nonrange_match opts
+        then bug "don't support patch matching with Last in wasp"
+        else pc
+  in if null fs && not (have_nonrange_match opts)
+     then NilFL :> ps
+     else tp_patches $ separate_middle_last_from_first $ select_not_touching fs
+                     $ deselect_unwanted $ patch_choices ps
+
+patches_to_consider_first_reversed' :: RepoPatch p
+                     => [FilePath]  -- ^ files
+                     -> [DarcsFlag] -- ^ opts
+                     -> FL (PatchInfoAnd p) C(x y) -- ^ patches
+                     -> (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) C(y x)
+patches_to_consider_first_reversed' fs opts ps =
+  let deselect_unwanted pc =
+        if have_nonrange_match opts
+        then bug "don't support patch matching with FirstReversed in wasp"
+        else pc
+  in if null fs && not (have_nonrange_match opts)
+     then NilFL :> (invert ps)
+     else tp_patches $ separate_middle_last_from_first $ select_not_touching fs
+                     $ deselect_unwanted $ patch_choices $ invert ps
+
+patches_to_consider_last_reversed' :: RepoPatch p
+                     => [FilePath]  -- ^ files
+                     -> [DarcsFlag] -- ^ opts
+                     -> FL (PatchInfoAnd p) C(x y) -- ^ patches
+                     -> (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) C(y x)
+patches_to_consider_last_reversed' fs opts ps =
+  let deselect_unwanted pc =
+        if have_nonrange_match opts
+        then if DontGrabDeps `elem` opts
+             then force_matching_last (not.iswanted) pc
+             else make_everything_later $ force_matching_first iswanted pc
+        else pc
+      iswanted = match_a_patch opts . hopefully . invert . tp_patch
+  in if null fs && not (have_nonrange_match opts)
+     then (invert ps) :> NilFL
+     else tp_patches $ separate_first_middle_from_last $ deselect_not_touching fs
+                     $ deselect_unwanted $ patch_choices $ invert ps
+
+patches_to_consider_nothing' :: RepoPatch p
+                     => [FilePath]  -- ^ files
+                     -> [DarcsFlag] -- ^ opts
+                     -> FL (PatchInfoAnd p) C(x y) -- ^ patches
+                     -> (FL (PatchInfoAnd p) :> FL (PatchInfoAnd p)) C(x y)
+patches_to_consider_nothing' fs opts ps =
+  let deselect_unwanted pc =
+        if have_nonrange_match opts
+        then if DontGrabDeps `elem` opts
+             then force_matching_last (not.iswanted) pc
+             else make_everything_later $ force_matching_first iswanted pc
+        else pc
+      iswanted = match_a_patch opts . hopefully . tp_patch
+  in if null fs && not (have_nonrange_match opts)
+     then ps :> NilFL
+     else tp_patches $ separate_first_middle_from_last $ deselect_not_touching fs
+                     $ deselect_unwanted $ patch_choices ps
hunk ./src/Darcs/SelectChanges.lhs 437
-selected_patches :: Patchy p => WhichChanges
-                 -> FL p -- ^ patches set aside
-                 -> PatchChoices p
-                 -> (FL p :> FL p)
-selected_patches whichch other_ps pc =
-  case whichch of
-  Last -> case separate_last_from_first_middle pc of
-          xs :> ys -> other_ps +>+ mapFL_FL tp_patch xs :> mapFL_FL tp_patch ys
-  First -> case separate_first_from_middle_last pc of
-           xs :> ys -> mapFL_FL tp_patch xs :> mapFL_FL tp_patch ys +>+ other_ps
-  LastReversed -> case separate_first_from_middle_last pc of
-                  xs :> ys -> invert (mapFL_FL tp_patch ys +>+ other_ps) :> invert (mapFL_FL tp_patch xs)
-  FirstReversed -> case separate_last_from_first_middle pc of
-                   xs :> ys -> invert (mapFL_FL tp_patch ys) :> invert (other_ps +>+ mapFL_FL tp_patch xs)
+selected_patches_last :: Patchy p => FL p C(x y) -> PatchChoices p C(y z)
+                      -> (FL p :> FL p) C(x z)
+selected_patches_last other_ps pc =
+  case separate_last_from_first_middle pc of
+  xs :> ys -> other_ps +>+ mapFL_FL tp_patch xs :> mapFL_FL tp_patch ys
+
+selected_patches_first :: Patchy p => FL p C(y z) -> PatchChoices p C(x y)
+                       -> (FL p :> FL p) C(x z)
+selected_patches_first other_ps pc =
+  case separate_first_from_middle_last pc of
+  xs :> ys -> mapFL_FL tp_patch xs :> mapFL_FL tp_patch ys +>+ other_ps
hunk ./src/Darcs/SelectChanges.lhs 449
-text_select :: Patchy p => String -> WhichChanges -> [DarcsFlag] -> Int -> Int
-            -> RL (TaggedPatch p) -> FL (TaggedPatch p) -> PatchChoices p
-            -> IO (PatchChoices p)
+selected_patches_last_reversed :: Patchy p => FL p C(y x) -> PatchChoices p C(z y)
+                               -> (FL p :> FL p) C(x z)
+selected_patches_last_reversed other_ps pc =
+  case separate_first_from_middle_last pc of
+  xs :> ys -> invert (mapFL_FL tp_patch ys +>+ other_ps) :> invert (mapFL_FL tp_patch xs)
+
+selected_patches_first_reversed :: Patchy p => FL p C(z y) -> PatchChoices p C(y x)
+                                -> (FL p :> FL p) C(x z)
+selected_patches_first_reversed other_ps pc =
+  case separate_last_from_first_middle pc of
+  xs :> ys -> invert (mapFL_FL tp_patch ys) :> invert (other_ps +>+ mapFL_FL tp_patch xs)
+
+text_select :: forall p C(x y z). Patchy p => String -> WhichChanges -> [DarcsFlag] -> Int -> Int
+            -> RL (TaggedPatch p) C(x y) -> FL (TaggedPatch p) C(y z) -> PatchChoices p C(x z)
+            -> IO ((PatchChoices p) C(x z))
hunk ./src/Darcs/SelectChanges.lhs 468
-      printFriendly opts viewp
+      (printFriendly opts) `unseal2` viewp
hunk ./src/Darcs/SelectChanges.lhs 475
-        helper :: PatchChoices p -> p
+        helper :: PatchChoices p C(a b) -> p C(a b)
hunk ./src/Darcs/SelectChanges.lhs 506
+        repeat_this :: Patchy p => IO ((PatchChoices p) C(x z))
hunk ./src/Darcs/SelectChanges.lhs 515
-            'v' -> printPatch viewp >> repeat_this
-            'p' -> printPatchPager viewp >> repeat_this
-            'x' -> do putDocLn $ prefix "    " $ summary viewp
+            'v' -> printPatch `unseal2` viewp >> repeat_this
+            'p' -> printPatchPager `unseal2` viewp >> repeat_this
+            'x' -> do (putDocLn . prefix "    " . summary) `unseal2` viewp
hunk ./src/Darcs/SelectChanges.lhs 552
-        viewp = if whichch == LastReversed || whichch == FirstReversed then invert (tp_patch tp) else tp_patch tp
+        viewp = if whichch == LastReversed || whichch == FirstReversed then seal2 $ invert (tp_patch tp) else seal2 $ tp_patch tp
hunk ./src/Darcs/SelectChanges.lhs 561
-text_view :: Patchy p => [DarcsFlag] -> Int -> Int
-            -> RL (TaggedPatch p) -> FL (TaggedPatch p) -> PatchChoices p
-            -> IO (PatchChoices p)
-
-text_view _ _ _ _ NilFL _ = return $ patch_choices NilFL --return pc
+text_view :: forall p C(x y u r s). Patchy p => [DarcsFlag] -> Int -> Int
+            -> RL (TaggedPatch p) C(x y) -> FL (TaggedPatch p) C(y u) -> PatchChoices p C(r s)
+            -> IO ((PatchChoices p) C(r s))
+text_view _ _ _ _ NilFL _ = return $ patch_choices $ unsafeCoerceP NilFL --return pc
hunk ./src/Darcs/SelectChanges.lhs 580
-                                   n tps_done tps_todo' pc
+                                   n tps_done NilFL pc
hunk ./src/Darcs/SelectChanges.lhs 601
+        repeat_this :: IO ((PatchChoices p) C(r s))
hunk ./src/Darcs/SelectChanges.lhs 620
-                        -> Int -> Int -> RL (TaggedPatch p) -> FL (TaggedPatch p)
-                        -> PatchChoices p
-                        -> IO (PatchChoices p)
+                        -> Int -> Int -> RL (TaggedPatch p) C(x y) -> FL (TaggedPatch p) C(y z)
+                        -> PatchChoices p C(x z)
+                        -> IO ((PatchChoices p) C(x z))
hunk ./src/Darcs/SelectChanges.lhs 625
-                        ps_todo pc = do
-  when (numSkipped > 0) show_skipped
-  text_select jobname whichch opts n_max (n + numSkipped)
-    (reverseFL skipped +<+ ps_done) unskipped pc
- where
-  skipped :> unskipped = spanFL (\p -> isJust $ is_patch_first p pc) ps_todo
-  numSkipped  = lengthFL skipped
-  show_skipped = do putStrLn $ _doing_ ++ _with_ ++ "."
-                    when (Verbose `elem` opts) $ showskippedpatch skipped
+                        ps_todo pc =
+  case spanFL (\p -> isJust $ is_patch_first p pc) ps_todo of
+  skipped :> unskipped -> do
+   when (numSkipped > 0) show_skipped
+   text_select jobname whichch opts n_max (n + numSkipped)
+     (reverseFL skipped +<+ ps_done) unskipped pc
+   where
+   numSkipped  = lengthFL skipped
+   show_skipped = do putStrLn $ _doing_ ++ _with_ ++ "."
+                     when (Verbose `elem` opts) $ showskippedpatch skipped
hunk ./src/Darcs/SelectChanges.lhs 640
+      showskippedpatch :: Patchy p => FL (TaggedPatch p) C(y t) -> IO ()

[refine type witnesses in SelectChanges
Jason Dagit <[EMAIL PROTECTED]>**20080813050425] hunk ./src/Darcs/SelectChanges.lhs 83
-     -> (FORALL(m n) (FL p :> FL p) C(m n) -> IO a) -- job
+     -> ((FL p :> FL p) C(x y) -> IO a) -- job
hunk ./src/Darcs/SelectChanges.lhs 93
-     -> (FORALL(m n) (FL p :> FL p) C(m n) -> IO a) -- job
+     -> ((FL p :> FL p) C(x y) -> IO a) -- job

[Potentially correct SelectChanges
Jason Dagit <[EMAIL PROTECTED]>**20080815053958] hunk ./src/Darcs/SelectChanges.lhs 48
-import Darcs.Patch.Ordered ( FL(..), RL(..), (:>)(..),
-                             (+>+), lengthFL, concatRL, mapFL_FL,
+import Darcs.Patch.Ordered ( FL(..), RL(..), (:>)(..), EqCheck(..),
+                             (+>+), lengthFL, concatRL, mapFL_FL, (=/\=),
hunk ./src/Darcs/SelectChanges.lhs 193
-with_selected_patch_from_repo :: RepoPatch p => String -> Repository p C(r u t) -> [DarcsFlag] -> Bool
-                              -> (FORALL(a b) ((FL (PatchInfoAnd p) :> (PatchInfoAnd p)) C(a b)) -> IO ()) -> IO ()
+with_selected_patch_from_repo :: forall p C(r u t). RepoPatch p => String -> Repository p C(r u t) -> [DarcsFlag] -> Bool
+                              -> (FORALL(a b) ((FL (PatchInfoAnd p)) C(a r), ((PatchInfoAnd p) C(r b))) -> IO ()) -> IO ()
hunk ./src/Darcs/SelectChanges.lhs 200
+    let pend_ = n2pia $ anonymous $ fromPrims pend
hunk ./src/Darcs/SelectChanges.lhs 202
-                              (concatRL p_s) ((n2pia $ anonymous $ fromPrims pend) :>: NilFL)
+                              (concatRL p_s) (pend_ :>: NilFL)
hunk ./src/Darcs/SelectChanges.lhs 206
-           pend':<:skipped ->
-            case commute (pend' :> selected) of
-            Just (selected' :> _) -> job (reverseRL skipped :> selected')
-            Nothing -> impossible
+           pend' :<: skipped ->
+            -- Due to the way wspfr always leaves the pending as the last patch
+            -- in the s_and_pend portion of it's return value, this test should
+            -- always be true and it tells the type system that pend_ and pend'
+            -- are equal and hence have the same contexts.
+            case pend_ `sloppyEquals` pend' of
+            IsEq ->
+              case commute (pend' :> selected) of
+                    Just (selected' :> _) -> job (reverseRL skipped, selected')
+                    Nothing -> impossible
+            _ -> impossible
hunk ./src/Darcs/SelectChanges.lhs 221
+  where
+  sloppyEquals :: (PatchInfoAnd p) C(x y) -> (PatchInfoAnd p) C(q v) -> EqCheck C(x q)
+  sloppyEquals p1 p2 = p1 =/\= (unsafeCoerceP p2)

Context:

[remove a few unsightly functions
Jason Dagit <[EMAIL PROTECTED]>**20080813061256] 
[Generalize HashRepo.clean_pristine to HashIO.clean_hashdir.
[EMAIL PROTECTED] 
[Add writeSlurpy to roll out a copy of slurpy into a filesystem.
[EMAIL PROTECTED] 
[fix breakage in URL.
David Roundy <[EMAIL PROTECTED]>**20080812141220] 
[Parametrize "pristine.hashed" in a bunch of functions.
[EMAIL PROTECTED] 
[Rework URL module for multi threading.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080811221209] 
[Add thread synchronization to URL module and resume select() if interrupted by signal in curl module.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080810092810] 
[Handle error case with empty URL in URL.waitNextUrl function.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080809221755] 
[Add --debug-http flag to enable curl and libwww debug at run-time instead of compile-time.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080809154834] 
[Print a warning when the remote end does not have darcs 2.
Eric Kow <[EMAIL PROTECTED]>**20080811100933
 
 Two reasons:
 (1) right now people get a scary warning from ssh when it can't fetch
     some non-essential files (it used to be that we would send stderr from ssh
     to /dev/null, but that has other problems...)
 (2) darcs transfer-mode more widely deployed could help a lot of people
     wrt darcs performance
] 
[Added a beware note to the unrecord command
[EMAIL PROTECTED] 
[Fixed typo
[EMAIL PROTECTED] 
[Better debug messages in URL module.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080809215247] 
[make Convert.lhs compile.
David Roundy <[EMAIL PROTECTED]>**20080810201725] 
[Refactor `darcs convert' warning at kowey's request.
Trent W. Buck <[EMAIL PROTECTED]>**20080810110014] 
[Expand formats text based in part on suggestions from darcs-users
Max Battcher <[EMAIL PROTECTED]>**20080809184043] 
[Fixes to global cache text based on darcs-users suggestions
Max Battcher <[EMAIL PROTECTED]>**20080809181424] 
[Add user-focused documentation of repository format options
Max Battcher <[EMAIL PROTECTED]>**20080807195429] 
[Highlight the global cache as a best practice
Max Battcher <[EMAIL PROTECTED]>**20080807193918] 
[Describe best practice in `darcs convert --help'.
Trent W. Buck <[EMAIL PROTECTED]>**20080810110615] 
[add type witnesses to TouchesFiles
Jason Dagit <[EMAIL PROTECTED]>**20080810063403] 
[improve type safety of Darcs.Repository.Internal.
Jason Dagit <[EMAIL PROTECTED]>**20080810051109] 
[add type witnesses to Patch/Choices.lhs
Jason Dagit <[EMAIL PROTECTED]>**20080809000237] 
[add type witnesses to Population
Jason Dagit <[EMAIL PROTECTED]>**20080808053252] 
[add type witnesses to CommandsAux
Jason Dagit <[EMAIL PROTECTED]>**20080808052738] 
[Add type witnesses to more modules, rounding out Darcs/Repository/*
Jason Dagit <[EMAIL PROTECTED]>**20080808050947] 
[UF8.lhs: remove unusued functions/imports/docs
[EMAIL PROTECTED] 
[Resolve issue974 : do not pass both -optc-g and -opta-g to GHC
Eric Kow <[EMAIL PROTECTED]>**20080807073620] 
[make this test more cross-platform
Simon Michael <[EMAIL PROTECTED]>**20080807103433] 
[document how to run unit tests
Simon Michael <[EMAIL PROTECTED]>**20080807030416] 
[move (most) failing tests to bugs for clean test output
Simon Michael <[EMAIL PROTECTED]>**20080806191336] 
[fix an old spelling error
Simon Michael <[EMAIL PROTECTED]>**20080806170432] 
[make searching for "test:" in makefile work
Simon Michael <[EMAIL PROTECTED]>**20080805222241] 
[run only normal (expected to pass) tests by default
Simon Michael <[EMAIL PROTECTED]>**20080805222108] 
[Downplay quantum mechanics link.
Eric Kow <[EMAIL PROTECTED]>**20080806124109
 Besides, darcs has far more than 3 users by now.
] 
[Make patch theory intro more inviting to math people.
Eric Kow <[EMAIL PROTECTED]>**20080806123411] 
[cleanup and slight rewrite of the test docs
Simon Michael <[EMAIL PROTECTED]>**20080806165949] 
[make order of running tests consistent
Simon Michael <[EMAIL PROTECTED]>**20080806172123] 
[fixed a bug in identity_commutes property
Jason Dagit <[EMAIL PROTECTED]>**20080808023025
 In the right identity check the patch order should have gone from
 (identity :> p) to (p2 :> i2).  I added a rigid type context too
 so that ghc 6.8 and newer would type the definition.
] 
[Make Darcs.Repository.Internal compile with type witnesses.
Jason Dagit <[EMAIL PROTECTED]>**20080808015343] 
[small makefile refactoring: allow just the normal tests to be run, without bugs/*
Simon Michael <[EMAIL PROTECTED]>**20080805203242] 
[Rectify dist help
[EMAIL PROTECTED]
 Removed the "make dist" suggestion, the manual is a better place for that.
 Instead, make clear that it operates on a clean copy of the tree, and
 mention the "predist" functionality.
] 
[website: explain that darcs 2 is required to get the darcs source.
Simon Michael <[EMAIL PROTECTED]>**20080803181216] 
[Canonize Gaetan Lehmann and Daniel Buenzli.
Eric Kow <[EMAIL PROTECTED]>**20080730104357
 (for Daniel B, avoid an accent in his name)
] 
[configure: check for packages needed with split base.
Eric Kow <[EMAIL PROTECTED]>**20080730103840
 Now that all packages must be used explicitly.
] 
[fix type witness compile errors specific to ghc 6.8
Jason Dagit <[EMAIL PROTECTED]>**20080722182729] 
[avoid import of unused function fromMaybe.
David Roundy <[EMAIL PROTECTED]>**20080729172825] 
[configure: suggest regex-compat before text
Eric Kow <[EMAIL PROTECTED]>**20080725095336] 
[configure: mention Haskell in 'try installing' suggestion
Eric Kow <[EMAIL PROTECTED]>**20080725095015] 
[Typo (Text.Regex)
Eric Kow <[EMAIL PROTECTED]>**20080715121708] 
[Use haskeline to have a readline-like behavior when asking something to the user
[EMAIL PROTECTED]
 Unlike the implementations using readline or editline packages, this code
 code doesn't break the Ctrl-C behavior.
] 
[Improve generic rules for English plurals. 
Eric Kow <[EMAIL PROTECTED]>**20080604123728] 
[add configure check for Network.URI.
David Roundy <[EMAIL PROTECTED]>**20080711011914] 
[add -hide-all-packages to default GHCFLAGS.
David Roundy <[EMAIL PROTECTED]>**20080711010952] 
[add support for outputting patch numbers in darcs changes.
David Roundy <[EMAIL PROTECTED]>**20080710011211] 
[add support for matching single patches by index.
David Roundy <[EMAIL PROTECTED]>**20080710004512] 
[add support for matching ranges of patches (counting back from present).
David Roundy <[EMAIL PROTECTED]>**20080710003225] 
[Better avoid silly manpage error.
Trent W. Buck <[EMAIL PROTECTED]>**20080704024920
 
 It turned out only initialize's help string used 'quotes', so just
 remove them.  This makes init's docstring consistent with the others.
] 
[Missing period at end of sentence.
Trent W. Buck <[EMAIL PROTECTED]>**20080704024232] 
[darcs --overview no longer works, so don't document it.
Trent W. Buck <[EMAIL PROTECTED]>**20080704030804] 
[Avoid silly manpage error.
Trent W. Buck <[EMAIL PROTECTED]>**20080703010733
 man (nroff) treats an apostrophe in the first column specially,
 resulting in a syntax error without this patch.
 
 Ideally, all cases of 'foo' in the manpage (i.e. docstrings) should
 become `foo', since man -Tps turns ` and ' into left and right single
 quotes respectively.
] 
[obliterate whitespace in Darcs.Commands.Get
[EMAIL PROTECTED]
 'twas causing lhs/haddock difficulties where a \end{code} wasn't getting recognized.
] 
[rm haddock CPP business
[EMAIL PROTECTED]
 Try as I might, I can't see any reason to special-case some Haddock CPP logic to deal with some *commented-out guards*, unless CPP magically restores and uncomments the code if Haddock isn't being run.
] 
[make pull less verbose when --verbose flag is given.
David Roundy <[EMAIL PROTECTED]>**20080624170035] 
[fix makefile to remember to regenerate version information after running configure.
David Roundy <[EMAIL PROTECTED]>**20080624170001] 
[TAG 2.0.2
David Roundy <[EMAIL PROTECTED]>**20080624012041] 
Patch bundle hash:
5390f85a56859bd1b0b64ab40cb3cdbfca042abe
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to