Browse Source

Bump lts & libatrade versions

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

2
atrade-brick.cabal

@ -19,6 +19,7 @@ executable atrade-brick @@ -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
@ -34,3 +35,4 @@ executable atrade-brick @@ -34,3 +35,4 @@ executable atrade-brick
, aeson
, text
, bytestring
, co-log

33
src/Main.hs

@ -7,16 +7,17 @@ import Brick.Main @@ -7,16 +7,17 @@ import Brick.Main
import Brick.Types
import Brick.Widgets.Border
import Brick.Widgets.Core
import Colog
import Control.Concurrent
import qualified Control.Concurrent.BoundedChan as BC
import Control.Concurrent.BoundedChan qualified as BC
import Control.Exception
import Control.Monad
import Data.Aeson
import qualified Data.ByteString.Lazy as B
import Data.ByteString.Lazy qualified 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 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
@ -27,13 +28,14 @@ import ATrade.Types @@ -27,13 +28,14 @@ import ATrade.Types
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
@ -41,13 +43,20 @@ makeLenses ''AppState @@ -41,13 +43,20 @@ 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 @@ -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]

4
stack.yaml

@ -17,7 +17,7 @@ @@ -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: @@ -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: {}

22
stack.yaml.lock

@ -18,9 +18,23 @@ packages: @@ -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

Loading…
Cancel
Save