diff options
author | Ben Sima <ben@bsima.me> | 2021-02-10 18:04:12 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-02-17 20:27:39 -0500 |
commit | ad3102e108562aa7c12e89991eb387cd3aa359ae (patch) | |
tree | 542407f91c0a2d78f529eccc1d0ee58df10156aa /Biz/Log.hs | |
parent | 81dc733f5138aa0720eb2f6382bb91b33e1661cc (diff) |
Add boolean and logging pipeline operators
Diffstat (limited to 'Biz/Log.hs')
-rw-r--r-- | Biz/Log.hs | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -11,6 +11,9 @@ module Biz.Log fail, -- Debugging mark, + -- Operators + (~&), + (~?), -- | Low-level msg, br, @@ -56,3 +59,15 @@ mark label val = unsafePerformIO <| do msg Mark [label, tshow val] pure val + +-- | Pipelined version of 'mark'. +-- +-- @ +-- mark label val = val ~| label +-- @ +(~&) :: Show a => a -> Text -> a +(~&) val label = mark label val + +-- | Conditional mark. +(~?) :: Show a => a -> (a -> Bool) -> Text -> a +(~?) val test label = if test val then mark label val else val |