diff --git a/apps/simplex-chat/Simplex/Demo.hs b/apps/simplex-chat/Demo.hs similarity index 99% rename from apps/simplex-chat/Simplex/Demo.hs rename to apps/simplex-chat/Demo.hs index 4bc5cb9e69..2fff0b0a32 100644 --- a/apps/simplex-chat/Simplex/Demo.hs +++ b/apps/simplex-chat/Demo.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Simplex.Demo where +module Demo where import Simplex.Chat.Styled import System.Console.ANSI.Types diff --git a/apps/simplex-chat/Main.hs b/apps/simplex-chat/Main.hs index 8d24c0d4d2..fd788bf5d4 100644 --- a/apps/simplex-chat/Main.hs +++ b/apps/simplex-chat/Main.hs @@ -5,20 +5,20 @@ module Main where -import ChatOptions -import Control.Concurrent.STM +import Control.Concurrent.STM (atomically) import Control.Logger.Simple import Control.Monad.IO.Unlift import Control.Monad.Reader import Simplex.Chat import Simplex.Chat.Controller -import Simplex.Input +import Simplex.Chat.Input +import Simplex.Chat.Notification +import Simplex.Chat.Options +import Simplex.Chat.Store (createStore) +import Simplex.Chat.Terminal import Simplex.Messaging.Agent (getSMPAgentClient) import Simplex.Messaging.Agent.Env.SQLite import Simplex.Messaging.Client (smpDefaultConfig) -import Simplex.Notification -import Simplex.Store (createStore) -import Simplex.Terminal import System.Directory (getAppUserDataDirectory) import UnliftIO.Async (race_) diff --git a/package.yaml b/package.yaml index 2f42705dbf..1dc6b766d7 100644 --- a/package.yaml +++ b/package.yaml @@ -18,11 +18,19 @@ dependencies: - base >= 4.7 && < 5 - bytestring == 0.10.* - containers == 0.6.* + - directory == 1.3.* + - file-embed == 0.0.14.* + - filepath == 1.4.* - mtl == 2.2.* + - optparse-applicative == 0.15.* + - process == 1.6.* - simplexmq == 0.3.* - sqlite-simple == 0.4.* + - terminal == 0.2.* - text == 1.2.* - time == 1.9.* + - unliftio == 0.2.* + - unliftio-core == 0.2.* library: source-dirs: src @@ -33,24 +41,10 @@ executables: main: Main.hs dependencies: - simplex-chat - - aeson == 1.5.* - async == 2.2.* - - bytestring == 0.10.* - - composition == 1.0.* - - directory == 1.3.* - - file-embed == 0.0.14.* - - filepath == 1.4.* - - mtl == 2.2.* - - optparse-applicative == 0.15.* - - process == 1.6.* - simple-logger == 0.1.* - simplexmq == 0.3.* - - sqlite-simple == 0.4.* - stm == 2.5.* - - terminal == 0.2.* - - time == 1.9.* - - unliftio == 0.2.* - - unliftio-core == 0.2.* ghc-options: - -threaded diff --git a/apps/simplex-chat/Simplex/Chat.hs b/src/Simplex/Chat.hs similarity index 98% rename from apps/simplex-chat/Simplex/Chat.hs rename to src/Simplex/Chat.hs index 25a3b340d8..a025e46caf 100644 --- a/apps/simplex-chat/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -27,18 +27,18 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import Simplex.Chat.Controller +import Simplex.Chat.Help +import Simplex.Chat.Notification import Simplex.Chat.Protocol +import Simplex.Chat.Store import Simplex.Chat.Styled (plain) +import Simplex.Chat.Terminal import Simplex.Chat.Types -import Simplex.Help +import Simplex.Chat.View import Simplex.Messaging.Agent import Simplex.Messaging.Agent.Protocol import Simplex.Messaging.Parsers (parseAll) import Simplex.Messaging.Util (bshow, raceAny_) -import Simplex.Notification -import Simplex.Store -import Simplex.Terminal -import Simplex.View import System.Exit (exitFailure) import System.IO (hFlush, stdout) import Text.Read (readMaybe) @@ -207,7 +207,7 @@ getCreateActiveUser st = do liftIO $ setActiveUser st (userId user) pure user selectUser users = do - putStrLn "Select user profile: " + putStrLn "Select user profile:" forM_ (zip [1 ..] users) $ \(n :: Int, user) -> putStrLn $ show n <> " - " <> userStr user loop where diff --git a/apps/simplex-chat/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs similarity index 95% rename from apps/simplex-chat/Simplex/Chat/Controller.hs rename to src/Simplex/Chat/Controller.hs index ddd0850bc3..4aba3cdb9e 100644 --- a/apps/simplex-chat/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -12,14 +12,14 @@ import Control.Monad.Except import Control.Monad.IO.Unlift import Control.Monad.Reader import Numeric.Natural +import Simplex.Chat.Notification import Simplex.Chat.Protocol +import Simplex.Chat.Store (StoreError) +import Simplex.Chat.Terminal import Simplex.Chat.Types import Simplex.Messaging.Agent (AgentClient) import Simplex.Messaging.Agent.Protocol (AgentErrorType) import Simplex.Messaging.Agent.Store.SQLite (SQLiteStore) -import Simplex.Notification -import Simplex.Store (StoreError) -import Simplex.Terminal import UnliftIO.STM data ChatController = ChatController diff --git a/apps/simplex-chat/Simplex/Help.hs b/src/Simplex/Chat/Help.hs similarity index 98% rename from apps/simplex-chat/Simplex/Help.hs rename to src/Simplex/Chat/Help.hs index a508b1a76f..d3dbd9606b 100644 --- a/apps/simplex-chat/Simplex/Help.hs +++ b/src/Simplex/Chat/Help.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Simplex.Help where +module Simplex.Chat.Help where import Data.List (intersperse) import Simplex.Chat.Markdown diff --git a/apps/simplex-chat/Simplex/Input.hs b/src/Simplex/Chat/Input.hs similarity index 98% rename from apps/simplex-chat/Simplex/Input.hs rename to src/Simplex/Chat/Input.hs index 9984597179..8da7c679f8 100644 --- a/apps/simplex-chat/Simplex/Input.hs +++ b/src/Simplex/Chat/Input.hs @@ -2,14 +2,14 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} -module Simplex.Input where +module Simplex.Chat.Input where import Control.Monad.IO.Unlift import Control.Monad.Reader import Data.List (dropWhileEnd) import qualified Data.Text as T import Simplex.Chat.Controller -import Simplex.Terminal +import Simplex.Chat.Terminal import System.Exit (exitSuccess) import System.Terminal hiding (insertChars) import UnliftIO.STM diff --git a/apps/simplex-chat/Simplex/Notification.hs b/src/Simplex/Chat/Notification.hs similarity index 97% rename from apps/simplex-chat/Simplex/Notification.hs rename to src/Simplex/Chat/Notification.hs index 6d96eb0d89..718d3c18f5 100644 --- a/apps/simplex-chat/Simplex/Notification.hs +++ b/src/Simplex/Chat/Notification.hs @@ -2,7 +2,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} -module Simplex.Notification (Notification (..), initializeNotifications) where +module Simplex.Chat.Notification (Notification (..), initializeNotifications) where import Control.Monad (void) import Data.Char (toLower) diff --git a/apps/simplex-chat/ChatOptions.hs b/src/Simplex/Chat/Options.hs similarity index 96% rename from apps/simplex-chat/ChatOptions.hs rename to src/Simplex/Chat/Options.hs index b646d66d02..73538aa113 100644 --- a/apps/simplex-chat/ChatOptions.hs +++ b/src/Simplex/Chat/Options.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module ChatOptions (getChatOpts, ChatOpts (..)) where +module Simplex.Chat.Options (getChatOpts, ChatOpts (..)) where import qualified Data.Attoparsec.ByteString.Char8 as A import qualified Data.ByteString.Char8 as B diff --git a/apps/simplex-chat/Simplex/Store.hs b/src/Simplex/Chat/Store.hs similarity index 99% rename from apps/simplex-chat/Simplex/Store.hs rename to src/Simplex/Chat/Store.hs index 16ee8a874e..0c80bd4a5f 100644 --- a/apps/simplex-chat/Simplex/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -9,7 +9,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} -module Simplex.Store +module Simplex.Chat.Store ( SQLiteStore, StoreError (..), createStore, diff --git a/apps/simplex-chat/Simplex/Terminal.hs b/src/Simplex/Chat/Terminal.hs similarity index 99% rename from apps/simplex-chat/Simplex/Terminal.hs rename to src/Simplex/Chat/Terminal.hs index b8e77ea9c7..5451846665 100644 --- a/apps/simplex-chat/Simplex/Terminal.hs +++ b/src/Simplex/Chat/Terminal.hs @@ -2,7 +2,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} -module Simplex.Terminal where +module Simplex.Chat.Terminal where import Simplex.Chat.Styled import Simplex.Chat.Types diff --git a/apps/simplex-chat/Simplex/Util.hs b/src/Simplex/Chat/Util.hs similarity index 87% rename from apps/simplex-chat/Simplex/Util.hs rename to src/Simplex/Chat/Util.hs index 29c7a1568c..d2fe0c3d40 100644 --- a/apps/simplex-chat/Simplex/Util.hs +++ b/src/Simplex/Chat/Util.hs @@ -1,4 +1,4 @@ -module Simplex.Util where +module Simplex.Chat.Util where import Data.ByteString.Char8 (ByteString) import Data.Text (Text) diff --git a/apps/simplex-chat/Simplex/View.hs b/src/Simplex/Chat/View.hs similarity index 98% rename from apps/simplex-chat/Simplex/View.hs rename to src/Simplex/Chat/View.hs index 26579c7be7..e305e09902 100644 --- a/apps/simplex-chat/Simplex/View.hs +++ b/src/Simplex/Chat/View.hs @@ -3,7 +3,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Simplex.View +module Simplex.Chat.View ( printToView, showInvitation, showChatError, @@ -27,10 +27,10 @@ import Data.Time.LocalTime (TimeZone, ZonedTime, getCurrentTimeZone, getZonedTim import Simplex.Chat.Controller import Simplex.Chat.Markdown import Simplex.Chat.Styled +import Simplex.Chat.Terminal (printToTerminal) import Simplex.Chat.Types +import Simplex.Chat.Util (safeDecodeUtf8) import Simplex.Messaging.Agent.Protocol -import Simplex.Terminal (printToTerminal) -import Simplex.Util (safeDecodeUtf8) import System.Console.ANSI.Types type ChatReader m = (MonadUnliftIO m, MonadReader ChatController m)