{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Haxl.Core.Util
( atomicallyOnBlocking
, compose
, textShow
, trace_
) where
import Data.Text (Text)
import Debug.Trace (trace)
import qualified Data.Text as Text
import Control.Concurrent.STM
import Control.Exception
atomicallyOnBlocking :: Exception e => e -> STM a -> IO a
atomicallyOnBlocking e stm =
catch (atomically stm)
(\BlockedIndefinitelyOnSTM -> throw e)
compose :: [a -> a] -> a -> a
compose = foldr (.) id
textShow :: (Show a) => a -> Text
textShow = Text.pack . show
trace_ :: String -> a -> a
trace_ _ = id