Hello,<br><br>My question:<br>~~~~~~~~~~<br>Is there anyone around who remembers the purpose of the Darcs.IO module and/or history? I'd like to learn more about the why and how before I dive in and make changes.<br><br>
<br>Background on my question:<br>~~~~~~~~~~~~~~~~~~~~~~~<br>I modified some of the basic darcs types like this:<br><br>\begin{code}<br>data Prim C(x y) where<br> Move :: !FileName -> !FileName -> Prim C(x y)<br>
DP :: !FileName -> !(DirPatchType C(x y)) -> Prim C(x y)<br> FP :: !FileName -> !(FilePatchType C(x y)) -> Prim C(x y)<br> Split :: FL Prim C(x y) -> Prim C(x y)<br> Identity :: Prim C(x x)<br>
ChangePref :: !String -> !String -> !String -> Prim C(x y)<br><br>data FilePatchType C(x y) = RmFile | AddFile<br> | Hunk !Int !HunkHandle<br> | TokReplace !String !String !String<br>
| Binary !HunkHandle<br> deriving (Eq,Ord)<br><br>data DirPatchType C(x y) = RmDir | AddDir<br> deriving (Eq,Ord)<br><br>data HunkHandle = HH { hhFile :: !FileName<br>
, hhOffset :: !Int<br> , hhOldLength :: !Int<br> , hhNewLength :: !Int<br> }<br> deriving (Eq, Ord)<br><br>data HunkContent = HC { hcOffset :: !Int<br>
, hcOld :: ![B.ByteString]<br> , hcNew :: ![B.ByteString]<br> }<br>\end{code}<br><br>This means that when you have a list of Prims you are holding only enough information to go retrieve the HunkContent from the patch file (which presumably has been scanned once to calculate the hunk handles).<br>
<br>That leads to a function like this:<br>\begin{code}<br>readHunkHandle :: HunkHandle -> IO HunkContent<br>\end{code}<br><br>I've made this change all throughout the code base and inserted comments and undefined everywhere that I didn't know how to make an immediate fix. I'm going through and trying to fix those less obvious places. In the Apply class we use WriteableDirectory m instead of directly using IO in the types. This makes me think that readHunkHandle should have type:<br>
\begin{code}<br>readHunkHandle :: WriteableDirectory m => HunkHandle -> m HunkContent<br>\end{code}<br><br>Does this look right to anyone else? Since WriteableDirectory has an instance for IO, I think the first type would work but maybe if I use IO directly I'm violating some design principle here?<br>
<br>Thanks,<br>Jason<br>