Hello Darcs users and developers,

To familiarize myself with Darcs' source, I've taken it upon myself to
try and take care of some of the ProbablyEasy issues.  The one current
on the top of my list is http://bugs.darcs.net/issue291 (darcs record
interactive option: "e" is for "edit").  I've made some progress on it,
but I'm at a crossroads when it comes to getting the line number for a
a hunk.  Basically, at this moment, I have this:

tp :: (Patchy p) => (TaggedPatch p)

There's no way I've found to get the line number for a patch, since it
only really makes sense for hunks.  So I had two ideas on how to get
this information to tentatively_text_select in Darcs.SelectChanges:

1. Thread a function of type (Patchy p) => p C(x y) -> Maybe Int
through to tentatively_text_select.  It should return Nothing if the
argument is not a hunk, or Just lineNumber if it is.  Here's my sample
implementation:

-- Provide this for most selections
not_actual_line_no :: p C(x y) -> Maybe Int
not_actual_line_no _ = Nothing

-- Provide this for selections that use Prims
-- Defined in Darcs.Patch.Prim
get_hunk_line_no :: Prim p C(x y) -> Maybe Int
get_hunk_line_no (FP _ (Hunk line_no _ _)) = Just line_no
get_hunk_line_no _ = Nothing

2. Define a get_line_number operation for Patchy or one of its
superclasses. (it should have a similar type and behavior to the example
given above)

Which implementation would you other developers prefer?  I don't care
for #1 much, mainly because we have to thread that extra function
through.  However, #2 isn't very good either, because we're defining a
class operation that doesn't make sense for most instances.  What do
you all think?

Thanks,
Rob Hoelz
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to