Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.3.0.0 - 2024-07-19

- Support ghc 9.6

## 0.2.1.0 - 2015-10-13

- Added new QuickCheck properties
15 changes: 8 additions & 7 deletions ot.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: ot
Version: 0.2.1.0
Version: 0.3.0.0
Synopsis: Real-time collaborative editing with Operational Transformation
Description: OT is a technique to handle changes to a document in a setting where users are editing concurrently. This package implements operational transformation for simple plain text documents as well as server and client modules.
Homepage: https://github.com/operational-transformation/ot.hs
Expand All @@ -23,17 +23,18 @@ Library
Hs-source-dirs: src
Exposed-modules: Control.OperationalTransformation, Control.OperationalTransformation.List, Control.OperationalTransformation.Text, Control.OperationalTransformation.Selection, Control.OperationalTransformation.Properties, Control.OperationalTransformation.Client, Control.OperationalTransformation.Server
Build-depends: base >= 4 && < 5,
text >= 1.0 && < 1.3,
aeson >= 0.7 && < 0.11,
text >= 1.0 && < 3,
aeson >= 0.7 && < 3,
attoparsec >= 0.10.1.1 && < 1,
QuickCheck >= 2.7 && < 2.9,
binary >= 0.5.1.1 && < 0.8,
either >= 4.1.2 && < 5,
QuickCheck >= 2.7 && < 3,
binary >= 0.5.1.1 && < 2,
either >= 4.1.2 && < 6,
mtl >= 2.1.3.1 && < 3,
transformers,
ghc

-- Modules not exported by this package.
-- Other-modules:
-- Other-modules:

Test-suite tests
Ghc-options: -Wall -rtsopts
Expand Down
2 changes: 1 addition & 1 deletion src/Control/OperationalTransformation/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ genOp :: (OTSystem doc op, ArbitraryFor doc op) => doc -> Gen (op, doc)
genOp doc = do
op <- arbitraryFor doc
case apply op doc of
Left err -> fail err
Left err -> error err
Right doc' -> return (op, doc')


Expand Down
4 changes: 1 addition & 3 deletions src/Control/OperationalTransformation/Selection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module Control.OperationalTransformation.Selection
import Control.OperationalTransformation
import Control.OperationalTransformation.Text
import Data.Aeson
import Control.Applicative
import Data.Monoid
import Data.List (sort)
import qualified Data.Text as T
#if MIN_VERSION_ghc(7,8,0)
Expand Down Expand Up @@ -55,7 +53,7 @@ instance OTCursor Range TextOperation where
-- | A selection consists of a list of ranges. Each range may represent a
-- selected part of the document or a cursor in the document.
newtype Selection = Selection { ranges :: [Range] }
deriving (Monoid, Show, Read)
deriving (Semigroup, Monoid, Show, Read)

instance OTCursor Selection TextOperation where
updateCursor op = Selection . updateCursor op . ranges
Expand Down
11 changes: 6 additions & 5 deletions src/Control/OperationalTransformation/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ module Control.OperationalTransformation.Server
) where

import Control.OperationalTransformation
import Control.Monad.Trans.Either
import Control.Monad.Trans.Except
import Control.Monad.Identity
import Control.Monad (foldM)

type Revision = Integer

Expand All @@ -34,16 +35,16 @@ applyOperation :: (OTSystem doc op, OTCursor cursor op)
-- operation; that client must be sent an acknowledgement) and
-- the new state (or an error).
applyOperation (ServerState rev doc ops) oprev op cursor =
runIdentity $ runEitherT $ do
runIdentity $ runExceptT $ do
concurrentOps <- if oprev > rev || rev - oprev > fromIntegral (length ops)
then fail "unknown revision number"
then throwE "unknown revision number"
else return $ take (fromInteger $ rev - oprev) ops
(op', cursor') <- foldM transformFst (op, cursor) (reverse concurrentOps)
doc' <- case apply op' doc of
Left err -> fail $ "apply failed: " ++ err
Left err -> throwE $ "apply failed: " ++ err
Right d -> return d
return $ (op', cursor', ServerState (rev+1) doc' (op':ops))
where
transformFst (a, curs) b = case transform a b of
Left err -> fail $ "transform failed: " ++ err
Left err -> throwE $ "transform failed: " ++ err
Right (a', _) -> return (a', updateCursor op curs)
3 changes: 1 addition & 2 deletions test/Control/OperationalTransformation/Text/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import Test.Framework.Providers.QuickCheck2 (testProperty)

import qualified Data.Text as T
import Data.Binary (encode, decode)
import Control.Applicative ((<$>), (<*>))
import Data.Aeson.Types hiding (Result)
import Data.Aeson.Types hiding (Result, One)

deltaLength :: TextOperation -> Int
deltaLength (TextOperation ops) = sum (map len ops)
Expand Down