From daa7dc081389dab4f567b5b75121743c0a67c93a Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 19 Jul 2024 23:21:35 -0400 Subject: [PATCH] Support GHC 9.6 --- Changelog.md | 4 ++++ ot.cabal | 15 ++++++++------- .../OperationalTransformation/Properties.hs | 2 +- .../OperationalTransformation/Selection.hs | 4 +--- src/Control/OperationalTransformation/Server.hs | 11 ++++++----- .../OperationalTransformation/Text/Tests.hs | 3 +-- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Changelog.md b/Changelog.md index e1dd217..abcc83a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/ot.cabal b/ot.cabal index ced87ef..d659343 100644 --- a/ot.cabal +++ b/ot.cabal @@ -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 @@ -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 diff --git a/src/Control/OperationalTransformation/Properties.hs b/src/Control/OperationalTransformation/Properties.hs index 9a9d209..9f2e27c 100644 --- a/src/Control/OperationalTransformation/Properties.hs +++ b/src/Control/OperationalTransformation/Properties.hs @@ -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') diff --git a/src/Control/OperationalTransformation/Selection.hs b/src/Control/OperationalTransformation/Selection.hs index 879037c..8a2b6d2 100644 --- a/src/Control/OperationalTransformation/Selection.hs +++ b/src/Control/OperationalTransformation/Selection.hs @@ -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) @@ -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 diff --git a/src/Control/OperationalTransformation/Server.hs b/src/Control/OperationalTransformation/Server.hs index 5147e50..f0b2f0a 100644 --- a/src/Control/OperationalTransformation/Server.hs +++ b/src/Control/OperationalTransformation/Server.hs @@ -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 @@ -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) diff --git a/test/Control/OperationalTransformation/Text/Tests.hs b/test/Control/OperationalTransformation/Text/Tests.hs index 37a19ee..7c9da64 100644 --- a/test/Control/OperationalTransformation/Text/Tests.hs +++ b/test/Control/OperationalTransformation/Text/Tests.hs @@ -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)