Hacker News new | ask | show | jobs
by fakedrake 3876 days ago
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.

1 comments

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.