Skip to content

Instantly share code, notes, and snippets.

@cblp
Last active October 17, 2018 16:32
Show Gist options
  • Save cblp/c80a0882d0984a9845500967beded61e to your computer and use it in GitHub Desktop.
Save cblp/c80a0882d0984a9845500967beded61e to your computer and use it in GitHub Desktop.
Haskell RON RGA example
:{
Right note4 = runNetworkSim $ do
Right note1 <-
runReplicaSim (applicationSpecific 1) $
runExceptT $
newObject Note
{ note_end = Nothing
, note_start = fromGregorian 2018 10 17
, note_status = TaskStatus Active
, note_text = "пример"
, note_track = Nothing
}
Right note2 <-
runReplicaSim (applicationSpecific 2) $
runExceptT $
(`execStateT` note1) $
zoom_note_text $
RON.Data.RGA.editText "привет"
Right note3 <-
runReplicaSim (applicationSpecific 3) $
runExceptT $
(`execStateT` note1) $
zoom_note_text $
RON.Data.RGA.editText "придел"
pure $ reduceObject' note2 note3
:}
Data.ByteString.Lazy.Char8.putStrLn $ serializeStateFrame $ objectFrame note4
Right note4' = getObject note4
putStrLn $ note_text note4'
λ> :{
|Right note4 = runNetworkSim $ do
| Right note1 <-
| runReplicaSim (applicationSpecific 1) $
| runExceptT $
| newObject Note
| { note_end = Nothing
| , note_start = fromGregorian 2018 10 17
| , note_status = TaskStatus Active
| , note_text = "пример"
| , note_track = Nothing
| }
| Right note2 <-
| runReplicaSim (applicationSpecific 2) $
| runExceptT $
| (`execStateT` note1) $
| zoom_note_text $
| RON.Data.RGA.editText "привет"
| Right note3 <-
| runReplicaSim (applicationSpecific 3) $
| runExceptT $
| (`execStateT` note1) $
| zoom_note_text $
| RON.Data.RGA.editText "придел"
| pure $ reduceObject' note2 note3
|:}
note4 :: Object Note
λ> Data.ByteString.Lazy.Char8.putStrLn $ serializeStateFrame $ objectFrame note4
*lww #B/)8+)1 @` !
:end ,
:start =2018 =10 =17 ,
:status >Active ,
:text >)7 ,
:track ,
*rga #)7 @)A+)3 :0 !
@`)1 'п' ,
@)2 'р' ,
@)3 'и' ,
@)4 :`)7+)3 'м' ,
@)8+)3 :0 'д' ,
@+)2 'в' ,
@`)5 'е' ,
@)6 :`)9+)3 'р' ,
@)A+)3 :0 'л' ,
@+)2 'т' ,
.
it :: ()
λ> Right note4' = getObject note4
note4' :: Note
λ> putStrLn $ note_text note4'
придвелт
it :: ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment