From 40a5249cadf5bb505baed90b77661430921e2b39 Mon Sep 17 00:00:00 2001 From: timmy Date: Wed, 17 Apr 2024 13:51:53 -0400 Subject: [PATCH] full editor code --- benchmarks/CRDTs/DocumentEditor.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/benchmarks/CRDTs/DocumentEditor.hs b/benchmarks/CRDTs/DocumentEditor.hs index 6bc0b570..52b0707c 100644 --- a/benchmarks/CRDTs/DocumentEditor.hs +++ b/benchmarks/CRDTs/DocumentEditor.hs @@ -16,6 +16,8 @@ data Transaction = SetAttr Int String | Insert T.Timestamp T.Timestamp RichText | Del T.Timestamp +-- attrs +-- 1="name" render_opening :: IntOrMap String -> String render_closing :: IntOrMap String -> String @@ -52,3 +54,13 @@ edit uid doc up = case up of DelAttr key -> Block (M.remove uid key attrs) els Insert l r val -> Block attrs (L.insert uid l r val els) Del t -> Block attrs (L.del uid t els) + +listen :: Int -> RichText -> RichText +listen for doc = + let uid, up = -- This should be the network primitive + ndoc = edit uid doc upd + in if for > 0 then listen (for-1) ndoc + else ndoc + +gibbon_main = + render (listen 10 (Block (M.init 0 1 "document") (L.singleton 0 (Text " ")))) \ No newline at end of file