{-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} module Protolude.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) {-# WARNING trace "'trace' remains in code" #-} trace :: Print b => b -> a -> a trace :: forall b a. Print b => b -> a -> a trace b string a expr = forall a. IO a -> a unsafePerformIO (do forall a (m :: * -> *). (Print a, MonadIO m) => Handle -> a -> m () hPutStrLn Handle stderr b string forall (m :: * -> *) a. Monad m => a -> m a return a expr) {-# WARNING traceIO "'traceIO' remains in code" #-} traceIO :: Print b => b -> a -> P.IO a traceIO :: forall b a. Print b => b -> a -> IO a traceIO b string a expr = do forall a (m :: * -> *). (Print a, MonadIO m) => Handle -> a -> m () hPutStrLn Handle stderr b string forall (m :: * -> *) a. Monad m => a -> m a return a expr {-# WARNING traceShow "'traceShow' remains in code" #-} traceShow :: P.Show a => a -> b -> b traceShow :: forall a b. Show a => a -> b -> b traceShow a a b b = forall b a. Print b => b -> a -> a trace (forall a. Show a => a -> String P.show a a) b b {-# WARNING traceShowId "'traceShowId' remains in code" #-} traceShowId :: P.Show a => a -> a traceShowId :: forall a. Show a => a -> a traceShowId a a = forall b a. Print b => b -> a -> a trace (forall a. Show a => a -> String P.show a a) a a {-# WARNING traceShowM "'traceShowM' remains in code" #-} traceShowM :: (P.Show a, Monad m) => a -> m () traceShowM :: forall a (m :: * -> *). (Show a, Monad m) => a -> m () traceShowM a a = forall b a. Print b => b -> a -> a trace (forall a. Show a => a -> String P.show a a) (forall (m :: * -> *) a. Monad m => a -> m a return ()) {-# WARNING traceM "'traceM' remains in code" #-} traceM :: (Monad m) => Text -> m () traceM :: forall (m :: * -> *). Monad m => Text -> m () traceM Text s = forall b a. Print b => b -> a -> a trace (Text -> String unpack Text s) (forall (m :: * -> *) a. Monad m => a -> m a return ()) {-# WARNING traceId "'traceId' remains in code" #-} traceId :: Text -> Text traceId :: Text -> Text traceId Text s = forall b a. Print b => b -> a -> a trace Text s Text s {-# WARNING notImplemented "'notImplemented' remains in code" #-} notImplemented :: a notImplemented :: forall a. a notImplemented = forall a. HasCallStack => Text -> a error Text "Not implemented" {-# WARNING undefined "'undefined' remains in code" #-} undefined :: a undefined :: forall a. a undefined = forall a. HasCallStack => Text -> a error Text "Prelude.undefined" witness :: a witness :: forall a. a witness = forall a. HasCallStack => Text -> a error Text "Type witness should not be evaluated"