summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-02-10 18:04:12 -0500
committerBen Sima <ben@bsima.me>2021-02-17 20:27:39 -0500
commitad3102e108562aa7c12e89991eb387cd3aa359ae (patch)
tree542407f91c0a2d78f529eccc1d0ee58df10156aa /Biz
parent81dc733f5138aa0720eb2f6382bb91b33e1661cc (diff)
Add boolean and logging pipeline operators
Diffstat (limited to 'Biz')
-rw-r--r--Biz/Log.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Biz/Log.hs b/Biz/Log.hs
index a4d6253..8c7b043 100644
--- a/Biz/Log.hs
+++ b/Biz/Log.hs
@@ -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