From bbd25d4f46a405b599e62839a7cc8e40eea035a5 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Thu, 9 Dec 2021 15:02:56 +0700 Subject: [PATCH] Bump lts & libatrade versions --- atrade-brick.cabal | 4 ++- src/Main.hs | 71 ++++++++++++++++++++++++++-------------------- stack.yaml | 4 ++- stack.yaml.lock | 22 +++++++++++--- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/atrade-brick.cabal b/atrade-brick.cabal index 42ba956..ac907bf 100644 --- a/atrade-brick.cabal +++ b/atrade-brick.cabal @@ -19,6 +19,7 @@ executable atrade-brick ghc-options: -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010 default-extensions: OverloadedStrings + , ImportQualifiedPost other-modules: QuoteTable , Config build-depends: base >= 4.7 && < 5 @@ -33,4 +34,5 @@ executable atrade-brick , zeromq4-haskell-zap , aeson , text - , bytestring \ No newline at end of file + , bytestring + , co-log \ No newline at end of file diff --git a/src/Main.hs b/src/Main.hs index 262cd33..2c45bf4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,53 +1,62 @@ {-# LANGUAGE TemplateHaskell #-} module Main where -import Brick.AttrMap -import Brick.BChan -import Brick.Main -import Brick.Types -import Brick.Widgets.Border -import Brick.Widgets.Core -import Control.Concurrent -import qualified Control.Concurrent.BoundedChan as BC -import Control.Exception -import Control.Monad -import Data.Aeson -import qualified Data.ByteString.Lazy as B -import Data.IORef -import qualified Data.List as L -import qualified Data.Map.Strict as M -import qualified Graphics.Vty as Vty -import Lens.Micro.Platform -import Lens.Micro.TH -import System.ZMQ4 +import Brick.AttrMap +import Brick.BChan +import Brick.Main +import Brick.Types +import Brick.Widgets.Border +import Brick.Widgets.Core +import Colog +import Control.Concurrent +import Control.Concurrent.BoundedChan qualified as BC +import Control.Exception +import Control.Monad +import Data.Aeson +import Data.ByteString.Lazy qualified as B +import Data.IORef +import Data.List qualified as L +import Data.Map.Strict qualified as M +import Graphics.Vty qualified as Vty +import Lens.Micro.Platform +import Lens.Micro.TH +import System.ZMQ4 -import ATrade.QuoteSource.Client -import ATrade.Types +import ATrade.QuoteSource.Client +import ATrade.Types -import Config -import QuoteTable +import Config +import QuoteTable -data Name = Viewport1 - deriving (Show, Eq, Ord) +data Name = Viewport1 deriving (Eq, Ord, Show) -data AppEvent = QuoteTableUpdate QuoteTable +data AppEvent + = QuoteTableUpdate QuoteTable -data AppState = AppState { - _quotes :: QuoteTable -} +data AppState + = AppState + { _quotes :: QuoteTable + } makeLenses ''AppState qsThread :: IORef QuoteTable -> AppConfig -> IO () qsThread quotetable config = withContext $ \ctx -> do qschan <- BC.newBoundedChan 1000 - bracket (startQuoteSourceClient qschan (config ^. tickers) ctx (config ^. quoteSourceEndpoint) defaultClientSecurityParams) stopQuoteSourceClient $ \_ -> forever $ do + bracket (startQuoteSourceClient + qschan + (config ^. tickers) + ctx + (config ^. quoteSourceEndpoint) + defaultClientSecurityParams + emptyLogAction) stopQuoteSourceClient $ \_ -> forever $ do qsdata <- BC.readChan qschan case qsdata of QDTick tick -> handleNewTick quotetable tick _ -> return () where handleNewTick s t = atomicModifyIORef s $ \table -> (updateTable table t, ()) + emptyLogAction = LogAction (\_ -> return ()) quoteTableWriterThread :: IORef QuoteTable -> BChan AppEvent -> IO () quoteTableWriterThread qtRef chan = forever $ do @@ -75,7 +84,7 @@ main = do initialVty <- buildVty qsThreadId <- forkIO $ qsThread quoteTableRef config qtwThreadId <- forkIO $ quoteTableWriterThread quoteTableRef eventChan - void $ customMain buildVty (Just eventChan) app (initialState M.empty) + void $ customMain initialVty buildVty (Just eventChan) app (initialState M.empty) where initialState ref = AppState ref draw :: AppState -> [Widget Name] diff --git a/stack.yaml b/stack.yaml index 1ba97ff..59a6ef6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-12.9 +resolver: lts-18.18 # User packages to be built. # Various formats can be used as shown in the example below. @@ -45,6 +45,8 @@ packages: extra-deps: - datetime-0.3.1 - text-format-0.3.2 +- co-log-0.4.0.1@sha256:3d4c17f37693c80d1aa2c41669bc3438fac3e89dc5f479e57d79bc3ddc4dfcc5,5087 +- ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226 # Override default flag values for local packages and extra-deps # flags: {} diff --git a/stack.yaml.lock b/stack.yaml.lock index 4fb1a22..d737dc4 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -18,9 +18,23 @@ packages: sha256: 8eab17d8e2ddcd878e7899f470bc23b9343b2a58a2e253a1a571ff09017799af original: hackage: text-format-0.3.2 +- completed: + hackage: co-log-0.4.0.1@sha256:3d4c17f37693c80d1aa2c41669bc3438fac3e89dc5f479e57d79bc3ddc4dfcc5,5087 + pantry-tree: + size: 1126 + sha256: e73165ff8f744709428e2e87984c9d60ca1cec43d8455c413181c7c466e7497c + original: + hackage: co-log-0.4.0.1@sha256:3d4c17f37693c80d1aa2c41669bc3438fac3e89dc5f479e57d79bc3ddc4dfcc5,5087 +- completed: + hackage: ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226 + pantry-tree: + size: 1461 + sha256: 02f05d52be3ffcf36c78876629cbab80b63420672685371aea4fd10e1c4aabb6 + original: + hackage: ansi-terminal-0.10.3@sha256:e2fbcef5f980dc234c7ad8e2fa433b0e8109132c9e643bc40ea5608cd5697797,3226 snapshots: - completed: - size: 502604 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/9.yaml - sha256: 2b315ae05e003ce72e96e54849e8f8479959c45f750a814a018ff88bdaeaeff9 - original: lts-12.9 + size: 586296 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/18.yaml + sha256: 63539429076b7ebbab6daa7656cfb079393bf644971156dc349d7c0453694ac2 + original: lts-18.18