Skip to content

Commit 50c4fdd

Browse files
committed
refactoring wip
1 parent a4e0180 commit 50c4fdd

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

ghcjs/currency-converter/src/App/Types.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Functora.Miso.Prelude
3535
import Functora.Miso.Types as X
3636
import Functora.Money hiding (Currency, Money, Text)
3737
import qualified Functora.Prelude as Prelude
38-
import Functora.Rates
38+
import qualified Functora.Rates as Rates
3939
import qualified Functora.Web as Web
4040
import qualified Material.Snackbar as Snackbar
4141
import qualified Paths_app as Paths
@@ -46,7 +46,7 @@ data Model = Model
4646
modelMenu :: OpenedOrClosed,
4747
modelLoading :: Bool,
4848
modelState :: St Unique,
49-
modelMarket :: MVar Market,
49+
modelMarket :: MVar Rates.Market,
5050
modelFavMap :: Map MisoString Fav,
5151
modelCurrencies :: NonEmpty CurrencyInfo,
5252
modelSnackbarQueue :: Snackbar.Queue Action,

ghcjs/currency-converter/src/App/Widgets/Templates.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import App.Types
77
import qualified Functora.Aes as Aes
88
import Functora.Cfg
99
import Functora.Miso.Prelude
10-
import Functora.Rates
10+
import qualified Functora.Rates as Rates
1111
import qualified Functora.Web as Web
1212
import qualified Material.Snackbar as Snackbar
1313

@@ -25,7 +25,7 @@ newModel webOpts mSt uri = do
2525
cons <- liftIO . atomically $ dupTChan prod
2626
market <-
2727
maybe
28-
newMarket
28+
Rates.newMarket
2929
pure
3030
(mSt ^? _Just . #modelMarket)
3131
defKm <-

ghcjs/currency-converter/src/Main.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Functora.Miso.Prelude
2626
import qualified Functora.Miso.Storage as Storage
2727
import Functora.Money hiding (Money)
2828
import qualified Functora.Prelude as Prelude
29-
import Functora.Rates
29+
import qualified Functora.Rates as Rates
3030
import qualified Functora.Web as Web
3131
import Language.Javascript.JSaddle ((!), (!!))
3232
import qualified Language.Javascript.JSaddle as JS
@@ -287,20 +287,20 @@ evalModel raw = do
287287
new <-
288288
Syb.everywhereM
289289
( Syb.mkM $ \cur ->
290-
withMarket (raw ^. #modelWebOpts) (raw ^. #modelMarket)
290+
Rates.withMarket (raw ^. #modelWebOpts) (raw ^. #modelMarket)
291291
. fmap (fromRight cur)
292-
. tryMarket
293-
. getCurrencyInfo (raw ^. #modelWebOpts)
292+
. Rates.tryMarket
293+
. Rates.getCurrencyInfo (raw ^. #modelWebOpts)
294294
$ currencyInfoCode cur
295295
)
296296
( raw ^. #modelState
297297
)
298298
curs <-
299-
withMarket (raw ^. #modelWebOpts) (raw ^. #modelMarket)
299+
Rates.withMarket (raw ^. #modelWebOpts) (raw ^. #modelMarket)
300300
. fmap (fromRight $ raw ^. #modelCurrencies)
301-
. tryMarket
301+
. Rates.tryMarket
302302
. fmap (^. #currenciesList)
303-
$ getCurrencies (raw ^. #modelWebOpts)
303+
$ Rates.getCurrencies (raw ^. #modelWebOpts)
304304
km <-
305305
if (new ^. #stKm . #kmIkm . #unIkm == mempty)
306306
&& (new ^. #stIkm . #fieldOutput == mempty)
@@ -335,7 +335,7 @@ evalModel raw = do
335335
case baseAmtResult of
336336
Left {} -> pure st
337337
Right baseAmt ->
338-
withMarket (st ^. #modelWebOpts) (st ^. #modelMarket) $ do
338+
Rates.withMarket (st ^. #modelWebOpts) (st ^. #modelMarket) $ do
339339
let funds =
340340
Funds
341341
baseAmt
@@ -345,13 +345,13 @@ evalModel raw = do
345345
. #currencyOutput
346346
. #currencyInfoCode
347347
quote <-
348-
getQuote (st ^. #modelWebOpts) funds
348+
Rates.getQuote (st ^. #modelWebOpts) funds
349349
$ st
350350
^. cloneLens quoteLens
351351
. #moneyCurrency
352352
. #currencyOutput
353353
. #currencyInfoCode
354-
let quoteAmt = quoteMoneyAmount quote
354+
let quoteAmt = quote ^. #quoteMoneyAmount
355355
ct <- getCurrentTime
356356
pure
357357
$ st
@@ -376,7 +376,7 @@ evalModel raw = do
376376
& #modelState
377377
. #stDoc
378378
. #stDocCreatedAt
379-
.~ quoteCreatedAt quote
379+
.~ (quote ^. #quoteCreatedAt)
380380
& #modelOnlineAt
381381
.~ ct
382382

0 commit comments

Comments
 (0)