module Debug (
undefined,
trace,
traceM,
traceId,
traceIO,
traceShow,
traceShowId,
traceShowM,
notImplemented,
witness,
) where
import Data.Text (Text, unpack)
import Control.Monad (Monad, return)
import qualified Protolude.Base as P
import Protolude.Error (error)
import Protolude.Show (Print, hPutStrLn)
import System.IO(stderr)
import System.IO.Unsafe (unsafePerformIO)
trace :: Print b => b -> a -> a
trace string expr = unsafePerformIO (do
hPutStrLn stderr string
return expr)
traceIO :: Print b => b -> a -> P.IO a
traceIO string expr = do
hPutStrLn stderr string
return expr
traceShow :: P.Show a => a -> b -> b
traceShow a b = trace (P.show a) b
traceShowId :: P.Show a => a -> a
traceShowId a = trace (P.show a) a
traceShowM :: (P.Show a, Monad m) => a -> m ()
traceShowM a = trace (P.show a) (return ())
traceM :: (Monad m) => Text -> m ()
traceM s = trace (unpack s) (return ())
traceId :: Text -> Text
traceId s = trace s s
notImplemented :: a
notImplemented = error "Not implemented"
undefined :: a
undefined = error "Prelude.undefined"
witness :: a
witness = error "Type witness should not be evaluated"