[input-output-hk/cardano-sl] [CBR-243] improve wallet worker start-up and exception handling (#3330)

k0001 commented on this pull request.

> — where
— tick :: StateT (WalletWorkerState b) IO ()
— tick = lift (readChan chan) >>= \case
— Shutdown -> return ()
— msg -> interp ops msg >> tick
+— | Connect a wallet action interpreter to a source actions. This function
+— returns as soon as the given action returns ‘Shutdown’.
+walletWorker
+ :: Ex.MonadMask m
+ => WalletActionInterp m b
+ -> m (WalletAction b)
+ -> m ()
+walletWorker wai getWA = Ex.bracket_
+ (emit wai «Starting wallet worker.»)
+ (evalStateT
+ (fix $ \next -> lift getWA >>= \case

Hmm, no, there’s no memory efficiency reason involved. Just normal recursive monadic code.

Добавить комментарий