From 5cc8be366056baa29048acc11f4b5e14d5dbd652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 31 Aug 2025 10:38:04 +0200 Subject: Update erebos dependency to 0.2 --- src/Main.hs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') 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 -- cgit v1.2.3