News for hackers. Stuff that matters.
Re:The Theory of patches-vector by gosub on Wednesday November 11, 2015 @03:11AM (#10545386)
Would it not be sufficient to define Edit a minimally as:

    data Edit a = Insert  Int a
                | Delete  Int
given that a Delete only needs the place of deletion and a Replace is a Delete followed by an Insert?
Re:The Theory of patches-vector by fakedrake on Wednesday November 11, 2015 @04:43AM (#10545699)
I assumed that `Int` was the sequence index of the Edit, not the line number. The line position, which is not necessarily the line number, it might be contextual, is encoded in `a`. In fact the way I read the article was that `a` was a file, so you can have operations:

- Insert Int File == "create file"

- Delete Int File == "delete file"

- Replace Int File == "patch file"

Removing and Inserting a file each time it changes, while technically correct is probably not what you want.

The nice thing about what Liam proposes (and type classes in general) is that it doesn't matter what we each interpret `a` to be.

Re:The Theory of patches-vector by gosub on Wednesday November 11, 2015 @09:45AM (#10546876)
Well, a patch is defined as Patch [Edit a], so I presume the sequence of the edit is implicit in the list position. The article says that an edit is the modification of an element of a Vector. I think the parameter a is the type of the elements of the Vector. In your example, a Patch File would be something to apply to a Vector File, and the Int in the edit should be the index of the file in the vector.