summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-08-31 10:38:04 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-08-31 22:18:45 +0200
commit5cc8be366056baa29048acc11f4b5e14d5dbd652 (patch)
treef5a688907dbee33c9faf152a7b4a1d1652df90b4
parentb2efb9e969ef992612e81afa26d65478c060233c (diff)
Update erebos dependency to 0.2HEADmaster
-rw-r--r--erebos-webapp.cabal2
-rw-r--r--src/Main.hs34
2 files changed, 18 insertions, 18 deletions
diff --git a/erebos-webapp.cabal b/erebos-webapp.cabal
index 703a583..057b7d4 100644
--- a/erebos-webapp.cabal
+++ b/erebos-webapp.cabal
@@ -57,7 +57,7 @@ executable erebos-webapp
base ^>= { 4.21 },
blaze-html ^>= { 0.9 },
bytestring ^>= { 0.12 },
- erebos ^>= { 0.1.8 },
+ erebos ^>= { 0.2 },
ghc-experimental ^>= { 9.1201, 9.1202 },
http-types ^>= { 0.12.4 },
mtl ^>= { 2.3 },
diff --git a/src/Main.hs b/src/Main.hs
index 9c8d552..644b2d3 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -60,13 +60,14 @@ data CurrentConversation
initGlobalState :: IO GlobalState
initGlobalState = do
globalStorage <- memoryStorage
- identity <- createIdentity globalStorage Nothing Nothing
- globalHead <- storeHead globalStorage $ LocalState
- { lsPrev = Nothing, lsIdentity = idExtData identity, lsShared = [], lsOther = [] }
- peerListVar <- newMVar []
- currentConversationVar <- newMVar NoCurrentConversation
- conversationsVar <- newMVar []
- return GlobalState {..}
+ (either (fail . showErebosError) return =<<) $ runExceptT $ flip runReaderT globalStorage $ do
+ identity <- createIdentity Nothing Nothing
+ globalHead <- storeHead globalStorage $ LocalState
+ { lsPrev = Nothing, lsIdentity = idExtData identity, lsShared = [], lsOther = [] }
+ peerListVar <- liftIO $ newMVar []
+ currentConversationVar <- liftIO $ newMVar NoCurrentConversation
+ conversationsVar <- liftIO $ newMVar []
+ return GlobalState {..}
foreign export javascript setup :: IO ()
setup :: IO ()
@@ -112,16 +113,15 @@ setup = do
watchConversations gs
let devName = T.pack "WebApp"
- let st = globalStorage
- owner <- createIdentity st Nothing Nothing
- identity <- createIdentity st (Just devName) (Just owner)
-
- shared <- wrappedStore st $ SharedState
- { ssPrev = []
- , ssType = Just $ sharedTypeID @(Maybe ComposedIdentity) Proxy
- , ssValue = [ storedRef $ idExtData owner ]
- }
- flip runReaderT globalHead $ do
+ (either (fail . showErebosError) return =<<) $ runExceptT $ flip runReaderT globalHead $ do
+ owner <- createIdentity Nothing Nothing
+ identity <- createIdentity (Just devName) (Just owner)
+
+ shared <- mstore SharedState
+ { ssPrev = []
+ , ssType = Just $ sharedTypeID @(Maybe ComposedIdentity) Proxy
+ , ssValue = [ storedRef $ idExtData owner ]
+ }
updateLocalState_ $ \_ -> do
mstore $ LocalState
{ lsPrev = Nothing