Giter VIP home page Giter VIP logo

patches-vector's Introduction

https://travis-ci.org/liamoc/patches-vector.svg https://img.shields.io/hackage/v/patches-vector.svg https://img.shields.io/hackage-deps/v/patches-vector.svg https://img.shields.io/badge/language-Haskell-blue.svg http://img.shields.io/badge/license-BSD3-brightgreen.svg

Patches for Vectors

A patch is a collection of modifications (edits) to be made to a sequence of elements. Commonly found in version control systems, patches are also a simple example of a groupoid, supporting (partial) composition and inversion.

This library provides a pleasant interface for working with patches to vectors with any type of element. It includes patch composition, inversion, and application, as well as a way to compute a patch between two vectors using the Wagner-Fischer algorithm.

It also includes a simple implementation of the operational transformation (OT) function to resolve diverging patches from the same document. This allows for reasonably painless implementation of merge functions, as well as many applications in distributed editing of documents. This operation also has an interpretation in terms of groupoids, where the transform function is the pushout of two diverging patches.

This library is extensively covered by a comprehensive suite of QuickCheck properties, which are written into the documentation and run with doctest.

The actual package only depends on base, microlens, vector and a small library for doing Wagner-Fischer, thsutton/edit-distance-vector.

It is released under the BSD3 license.

Building, Installing

patches-vector is released on Hackage and is available in the usual way:

$ cabal update
$ cabal install patches-vector

You can also use stack if you prefer:

$ stack install patches-vector

A variety of stack-*.yaml files are provided in this repository for various LTS snapshots.

Using

The full Haddock documentation is available on Hackage. Mostly, construct patches using fromList or diff, compose them with the Monoid instance, invert them with inverse, and apply them to a vector with apply.

The transform function can be used to resolve diverging patches, and transformWith lets you select a merging strategy, such as ours or theirs, rather than the default mappend. See the Haddock documentation for more information.

The hunks function can be used with a patch and a vector to provide a list of change hunks, that are convenient for other tools or for displaying to the user.

Future work

  • More elaborate merge strategies that allow you to emulate insert/delete style patches.

Other notes

This library is designed to be used with my composition-tree library, which, along with this library gives you a basic version control system for vectors. Pretty neat!

patches-vector's People

Contributors

liamoc avatar stepcut avatar mikeplus64 avatar phadej avatar puffnfresh avatar soenkehahn avatar

Watchers

 avatar Clifford Beshers avatar James Cloos avatar David Fox avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.