From ad3102e108562aa7c12e89991eb387cd3aa359ae Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 10 Feb 2021 18:04:12 -0500 Subject: Add boolean and logging pipeline operators --- Biz/Log.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Biz/Log.hs') 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 -- cgit v1.2.3