{-# 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 a -> IO a
atomicallyOnBlocking e
e STM a
stm =
IO a -> (BlockedIndefinitelyOnSTM -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
catch (STM a -> IO a
forall a. STM a -> IO a
atomically STM a
stm)
(\BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM -> e -> IO a
forall a e. Exception e => e -> a
throw e
e)
compose :: [a -> a] -> a -> a
compose :: [a -> a] -> a -> a
compose = ((a -> a) -> (a -> a) -> a -> a) -> (a -> a) -> [a -> a] -> a -> a
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (a -> a) -> (a -> a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) a -> a
forall a. a -> a
id
textShow :: (Show a) => a -> Text
textShow :: a -> Text
textShow = String -> Text
Text.pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show
trace_ :: String -> a -> a
trace_ :: String -> a -> a
trace_ String
_ = a -> a
forall a. a -> a
id