Browse Source

Bump lts & libatrade versions

master
Denis Tereshkin 4 years ago
parent
commit
bbd25d4f46
  1. 4
      atrade-brick.cabal
  2. 71
      src/Main.hs
  3. 4
      stack.yaml
  4. 22
      stack.yaml.lock

4
atrade-brick.cabal

@ -19,6 +19,7 @@ executable atrade-brick
ghc-options: -threaded -rtsopts -with-rtsopts=-N ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010 default-language: Haskell2010
default-extensions: OverloadedStrings default-extensions: OverloadedStrings
, ImportQualifiedPost
other-modules: QuoteTable other-modules: QuoteTable
, Config , Config
build-depends: base >= 4.7 && < 5 build-depends: base >= 4.7 && < 5
@ -33,4 +34,5 @@ executable atrade-brick
, zeromq4-haskell-zap , zeromq4-haskell-zap
, aeson , aeson
, text , text
, bytestring , bytestring
, co-log

71
src/Main.hs

@ -1,53 +1,62 @@
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
module Main where module Main where
import Brick.AttrMap import Brick.AttrMap
import Brick.BChan import Brick.BChan
import Brick.Main import Brick.Main
import Brick.Types import Brick.Types
import Brick.Widgets.Border import Brick.Widgets.Border
import Brick.Widgets.Core import Brick.Widgets.Core
import Control.Concurrent import Colog
import qualified Control.Concurrent.BoundedChan as BC import Control.Concurrent
import Control.Exception import Control.Concurrent.BoundedChan qualified as BC
import Control.Monad import Control.Exception
import Data.Aeson import Control.Monad
import qualified Data.ByteString.Lazy as B import Data.Aeson
import Data.IORef import Data.ByteString.Lazy qualified as B
import qualified Data.List as L import Data.IORef
import qualified Data.Map.Strict as M import Data.List qualified as L
import qualified Graphics.Vty as Vty import Data.Map.Strict qualified as M
import Lens.Micro.Platform import Graphics.Vty qualified as Vty
import Lens.Micro.TH import Lens.Micro.Platform
import System.ZMQ4 import Lens.Micro.TH
import System.ZMQ4
import ATrade.QuoteSource.Client import ATrade.QuoteSource.Client
import ATrade.Types import ATrade.Types
import Config import Config
import QuoteTable import QuoteTable
data Name = Viewport1 data Name = Viewport1 deriving (Eq, Ord, Show)
deriving (Show, Eq, Ord)
data AppEvent = QuoteTableUpdate QuoteTable data AppEvent
= QuoteTableUpdate QuoteTable
data AppState = AppState { data AppState
_quotes :: QuoteTable = AppState
} { _quotes :: QuoteTable
}
makeLenses ''AppState makeLenses ''AppState
qsThread :: IORef QuoteTable -> AppConfig -> IO () qsThread :: IORef QuoteTable -> AppConfig -> IO ()
qsThread quotetable config = withContext $ \ctx -> do qsThread quotetable config = withContext $ \ctx -> do
qschan <- BC.newBoundedChan 1000 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 qsdata <- BC.readChan qschan
case qsdata of case qsdata of
QDTick tick -> handleNewTick quotetable tick QDTick tick -> handleNewTick quotetable tick
_ -> return () _ -> return ()
where where
handleNewTick s t = atomicModifyIORef s $ \table -> (updateTable table t, ()) handleNewTick s t = atomicModifyIORef s $ \table -> (updateTable table t, ())
emptyLogAction = LogAction (\_ -> return ())
quoteTableWriterThread :: IORef QuoteTable -> BChan AppEvent -> IO () quoteTableWriterThread :: IORef QuoteTable -> BChan AppEvent -> IO ()
quoteTableWriterThread qtRef chan = forever $ do quoteTableWriterThread qtRef chan = forever $ do
@ -75,7 +84,7 @@ main = do
initialVty <- buildVty initialVty <- buildVty
qsThreadId <- forkIO $ qsThread quoteTableRef config qsThreadId <- forkIO $ qsThread quoteTableRef config
qtwThreadId <- forkIO $ quoteTableWriterThread quoteTableRef eventChan 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 where
initialState ref = AppState ref initialState ref = AppState ref
draw :: AppState -> [Widget Name] draw :: AppState -> [Widget Name]

4
stack.yaml

@ -17,7 +17,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-12.9 resolver: lts-18.18
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.
@ -45,6 +45,8 @@ packages:
extra-deps: extra-deps:
- datetime-0.3.1 - datetime-0.3.1
- text-format-0.3.2 - 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 # Override default flag values for local packages and extra-deps
# flags: {} # flags: {}

22
stack.yaml.lock

@ -18,9 +18,23 @@ packages:
sha256: 8eab17d8e2ddcd878e7899f470bc23b9343b2a58a2e253a1a571ff09017799af sha256: 8eab17d8e2ddcd878e7899f470bc23b9343b2a58a2e253a1a571ff09017799af
original: original:
hackage: text-format-0.3.2 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: snapshots:
- completed: - completed:
size: 502604 size: 586296
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/9.yaml url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/18.yaml
sha256: 2b315ae05e003ce72e96e54849e8f8479959c45f750a814a018ff88bdaeaeff9 sha256: 63539429076b7ebbab6daa7656cfb079393bf644971156dc349d7c0453694ac2
original: lts-12.9 original: lts-18.18

Loading…
Cancel
Save