approximate log stack in handleLogDiscard
This commit is contained in:
parent
567176e076
commit
7a0bc73d25
6 changed files with 33 additions and 12 deletions
|
@ -289,3 +289,16 @@ handleLogDiscardIO : HasIO m => MonadRec m => IORef Nat ->
|
|||
LogL tag a -> m a
|
||||
handleLogDiscardIO ref act =
|
||||
runEff (handleLogDiscard_ act) [handleStateIORef ref]
|
||||
|
||||
|
||||
||| approximate the push/pop effects in a discarded log by trimming a stack or
|
||||
||| repeating its most recent element
|
||||
export %inline
|
||||
fixupDiscardedLog : Nat -> LevelStack -> LevelStack
|
||||
fixupDiscardedLog want lvls =
|
||||
let len = length lvls in
|
||||
case compare len want of
|
||||
EQ => lvls
|
||||
GT => drop (len `minus` want) lvls
|
||||
LT => let new = fromMaybe defaultLogLevels $ head' lvls in
|
||||
replicate (want `minus` len) new ++ lvls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue