traceShow and traceShowId for #16
This commit is contained in:
@@ -29,3 +29,4 @@ Welcome to project documentation.
|
|||||||
- [Tuples](Tuples.md)
|
- [Tuples](Tuples.md)
|
||||||
- [Generics](Generics.md)
|
- [Generics](Generics.md)
|
||||||
- [Type Level Programming](TypeLevel.md)
|
- [Type Level Programming](TypeLevel.md)
|
||||||
|
- [Unsafe](Unsafe.md)
|
||||||
|
|||||||
+27
-11
@@ -6,8 +6,10 @@ module Debug (
|
|||||||
error,
|
error,
|
||||||
trace,
|
trace,
|
||||||
traceM,
|
traceM,
|
||||||
|
traceId,
|
||||||
traceIO,
|
traceIO,
|
||||||
traceShow,
|
traceShow,
|
||||||
|
traceShowId,
|
||||||
traceShowM,
|
traceShowM,
|
||||||
notImplemented,
|
notImplemented,
|
||||||
) where
|
) where
|
||||||
@@ -16,31 +18,45 @@ import Data.Text (Text, unpack)
|
|||||||
import Control.Monad (Monad, return)
|
import Control.Monad (Monad, return)
|
||||||
|
|
||||||
import qualified Base as P
|
import qualified Base as P
|
||||||
import qualified Debug.Trace as T
|
import Show (Print, putStrLn)
|
||||||
|
|
||||||
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
|
|
||||||
|
{-# WARNING trace "'trace' remains in code" #-}
|
||||||
|
trace :: Print b => b -> a -> a
|
||||||
|
trace string expr = unsafePerformIO (do
|
||||||
|
putStrLn string
|
||||||
|
return expr)
|
||||||
|
|
||||||
|
{-# WARNING traceIO "'traceIO' remains in code" #-}
|
||||||
|
traceIO :: Print b => b -> a -> P.IO a
|
||||||
|
traceIO string expr = do
|
||||||
|
putStrLn string
|
||||||
|
return expr
|
||||||
|
|
||||||
{-# WARNING error "'error' remains in code" #-}
|
{-# WARNING error "'error' remains in code" #-}
|
||||||
error :: Text -> a
|
error :: Text -> a
|
||||||
error s = P.error (unpack s)
|
error s = P.error (unpack s)
|
||||||
|
|
||||||
{-# WARNING trace "'trace' remains in code" #-}
|
|
||||||
trace :: Text -> a -> a
|
|
||||||
trace s = T.trace (unpack s)
|
|
||||||
|
|
||||||
{-# WARNING traceShow "'traceShow' remains in code" #-}
|
{-# WARNING traceShow "'traceShow' remains in code" #-}
|
||||||
traceShow :: P.Show a => a -> b -> b
|
traceShow :: P.Show a => a -> b -> b
|
||||||
traceShow a b = T.trace (P.show a) b
|
traceShow a b = trace (P.show a) b
|
||||||
|
|
||||||
|
{-# WARNING traceShowId "'traceShowId' remains in code" #-}
|
||||||
|
traceShowId :: P.Show a => a -> a
|
||||||
|
traceShowId a = trace (P.show a) a
|
||||||
|
|
||||||
{-# WARNING traceShowM "'traceShowM' remains in code" #-}
|
{-# WARNING traceShowM "'traceShowM' remains in code" #-}
|
||||||
traceShowM :: (P.Show a, Monad m) => a -> m ()
|
traceShowM :: (P.Show a, Monad m) => a -> m ()
|
||||||
traceShowM a = T.trace (P.show a) (return ())
|
traceShowM a = trace (P.show a) (return ())
|
||||||
|
|
||||||
{-# WARNING traceM "'traceM' remains in code" #-}
|
{-# WARNING traceM "'traceM' remains in code" #-}
|
||||||
traceM :: (Monad m) => Text -> m ()
|
traceM :: (Monad m) => Text -> m ()
|
||||||
traceM s = T.trace (unpack s) (return ())
|
traceM s = trace (unpack s) (return ())
|
||||||
|
|
||||||
{-# WARNING traceIO "'traceIO' remains in code" #-}
|
{-# WARNING traceId "'traceM' remains in code" #-}
|
||||||
traceIO :: Text -> P.IO ()
|
traceId :: Text -> Text
|
||||||
traceIO s = T.traceIO (unpack s)
|
traceId s = trace s s
|
||||||
|
|
||||||
notImplemented :: a
|
notImplemented :: a
|
||||||
notImplemented = P.error "Not implemented"
|
notImplemented = P.error "Not implemented"
|
||||||
|
|||||||
Reference in New Issue
Block a user