{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 902
{-# OPTIONS_GHC -Wno-operator-whitespace #-}
#endif
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
#if ( __GLASGOW_HASKELL__ < 906 )
{-# LANGUAGE TypeInType #-}
#endif
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Relude.Debug
(
trace
, traceShow
, traceShowId
, traceShowWith
, traceId
, traceM
, traceShowM
, error
, Undefined (..)
, undefined
) where
import Data.Data (Data)
#if __GLASGOW_HASKELL__ >= 904
import Data.Type.Equality (type (~))
#endif
import GHC.Exts (RuntimeRep, TYPE)
import GHC.TypeLits (ErrorMessage (..), TypeError)
import Relude.Applicative (Applicative)
import Relude.Base (Char, Constraint, Eq, Generic, HasCallStack, Ord, Show, Type, Typeable)
import Relude.Enum (Bounded, Enum)
import Relude.String (Read, String, Text, toString)
import qualified Debug.Trace as Debug
import qualified Prelude
trace :: String -> a -> a
trace :: forall a. String -> a -> a
trace = String -> a -> a
forall a. String -> a -> a
Debug.trace
{-# WARNING trace "'trace' remains in code" #-}
traceShow :: Show a => a -> b -> b
traceShow :: forall a b. Show a => a -> b -> b
traceShow = a -> b -> b
forall a b. Show a => a -> b -> b
Debug.traceShow
{-# WARNING traceShow "'traceShow' remains in code" #-}
traceShowId :: Show a => a -> a
traceShowId :: forall a. Show a => a -> a
traceShowId = a -> a
forall a. Show a => a -> a
Debug.traceShowId
{-# WARNING traceShowId "'traceShowId' remains in code" #-}
traceShowWith :: Show b => (a -> b) -> a -> a
traceShowWith :: forall b a. Show b => (a -> b) -> a -> a
traceShowWith a -> b
f a
v = b -> a -> a
forall a b. Show a => a -> b -> b
Debug.traceShow (a -> b
f a
v) a
v
{-# WARNING traceShowWith "'traceShowWith remains in code" #-}
traceM :: (Applicative f) => String -> f ()
traceM :: forall (f :: * -> *). Applicative f => String -> f ()
traceM = String -> f ()
forall (f :: * -> *). Applicative f => String -> f ()
Debug.traceM
{-# WARNING traceM "'traceM' remains in code" #-}
traceShowM :: (Show a, Applicative f) => a -> f ()
traceShowM :: forall a (f :: * -> *). (Show a, Applicative f) => a -> f ()
traceShowM = a -> f ()
forall a (f :: * -> *). (Show a, Applicative f) => a -> f ()
Debug.traceShowM
{-# WARNING traceShowM "'traceShowM' remains in code" #-}
traceId :: String -> String
traceId :: String -> String
traceId = String -> String
Debug.traceId
{-# WARNING traceId "'traceId' remains in code" #-}
error
:: forall (r :: RuntimeRep) (a :: TYPE r) (t :: Type) .
(HasCallStack, IsText t)
=> t
-> a
error :: forall a t. (HasCallStack, IsText t) => t -> a
error t
e = String -> a
forall a. HasCallStack => String -> a
Prelude.error (t -> String
forall a. ToString a => a -> String
toString t
e)
type IsText (t :: Type) = (t ~ Text, CheckIsText t)
type family CheckIsText (t :: Type) :: Constraint where
CheckIsText Text = ()
CheckIsText [Char] = TypeError
( 'Text "'error' expects 'Text' but was given 'String'."
':$$: 'Text "Possible fixes:"
':$$: 'Text " * Make sure OverloadedStrings extension is enabled"
':$$: 'Text " * Use 'error (toText msg)' instead of 'error msg'"
)
CheckIsText a = TypeError
( 'Text "'error' works with 'Text'"
':$$: 'Text "But given: " ':<>: 'ShowType a
)
data Undefined = Undefined
deriving stock (Undefined -> Undefined -> Bool
(Undefined -> Undefined -> Bool)
-> (Undefined -> Undefined -> Bool) -> Eq Undefined
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Undefined -> Undefined -> Bool
== :: Undefined -> Undefined -> Bool
$c/= :: Undefined -> Undefined -> Bool
/= :: Undefined -> Undefined -> Bool
Eq, Eq Undefined
Eq Undefined =>
(Undefined -> Undefined -> Ordering)
-> (Undefined -> Undefined -> Bool)
-> (Undefined -> Undefined -> Bool)
-> (Undefined -> Undefined -> Bool)
-> (Undefined -> Undefined -> Bool)
-> (Undefined -> Undefined -> Undefined)
-> (Undefined -> Undefined -> Undefined)
-> Ord Undefined
Undefined -> Undefined -> Bool
Undefined -> Undefined -> Ordering
Undefined -> Undefined -> Undefined
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Undefined -> Undefined -> Ordering
compare :: Undefined -> Undefined -> Ordering
$c< :: Undefined -> Undefined -> Bool
< :: Undefined -> Undefined -> Bool
$c<= :: Undefined -> Undefined -> Bool
<= :: Undefined -> Undefined -> Bool
$c> :: Undefined -> Undefined -> Bool
> :: Undefined -> Undefined -> Bool
$c>= :: Undefined -> Undefined -> Bool
>= :: Undefined -> Undefined -> Bool
$cmax :: Undefined -> Undefined -> Undefined
max :: Undefined -> Undefined -> Undefined
$cmin :: Undefined -> Undefined -> Undefined
min :: Undefined -> Undefined -> Undefined
Ord, Int -> Undefined -> String -> String
[Undefined] -> String -> String
Undefined -> String
(Int -> Undefined -> String -> String)
-> (Undefined -> String)
-> ([Undefined] -> String -> String)
-> Show Undefined
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> Undefined -> String -> String
showsPrec :: Int -> Undefined -> String -> String
$cshow :: Undefined -> String
show :: Undefined -> String
$cshowList :: [Undefined] -> String -> String
showList :: [Undefined] -> String -> String
Show, ReadPrec [Undefined]
ReadPrec Undefined
Int -> ReadS Undefined
ReadS [Undefined]
(Int -> ReadS Undefined)
-> ReadS [Undefined]
-> ReadPrec Undefined
-> ReadPrec [Undefined]
-> Read Undefined
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Undefined
readsPrec :: Int -> ReadS Undefined
$creadList :: ReadS [Undefined]
readList :: ReadS [Undefined]
$creadPrec :: ReadPrec Undefined
readPrec :: ReadPrec Undefined
$creadListPrec :: ReadPrec [Undefined]
readListPrec :: ReadPrec [Undefined]
Read, Int -> Undefined
Undefined -> Int
Undefined -> [Undefined]
Undefined -> Undefined
Undefined -> Undefined -> [Undefined]
Undefined -> Undefined -> Undefined -> [Undefined]
(Undefined -> Undefined)
-> (Undefined -> Undefined)
-> (Int -> Undefined)
-> (Undefined -> Int)
-> (Undefined -> [Undefined])
-> (Undefined -> Undefined -> [Undefined])
-> (Undefined -> Undefined -> [Undefined])
-> (Undefined -> Undefined -> Undefined -> [Undefined])
-> Enum Undefined
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Undefined -> Undefined
succ :: Undefined -> Undefined
$cpred :: Undefined -> Undefined
pred :: Undefined -> Undefined
$ctoEnum :: Int -> Undefined
toEnum :: Int -> Undefined
$cfromEnum :: Undefined -> Int
fromEnum :: Undefined -> Int
$cenumFrom :: Undefined -> [Undefined]
enumFrom :: Undefined -> [Undefined]
$cenumFromThen :: Undefined -> Undefined -> [Undefined]
enumFromThen :: Undefined -> Undefined -> [Undefined]
$cenumFromTo :: Undefined -> Undefined -> [Undefined]
enumFromTo :: Undefined -> Undefined -> [Undefined]
$cenumFromThenTo :: Undefined -> Undefined -> Undefined -> [Undefined]
enumFromThenTo :: Undefined -> Undefined -> Undefined -> [Undefined]
Enum, Undefined
Undefined -> Undefined -> Bounded Undefined
forall a. a -> a -> Bounded a
$cminBound :: Undefined
minBound :: Undefined
$cmaxBound :: Undefined
maxBound :: Undefined
Bounded, Typeable Undefined
Typeable Undefined =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Undefined -> c Undefined)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Undefined)
-> (Undefined -> Constr)
-> (Undefined -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Undefined))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Undefined))
-> ((forall b. Data b => b -> b) -> Undefined -> Undefined)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r)
-> (forall u. (forall d. Data d => d -> u) -> Undefined -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Undefined -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined)
-> Data Undefined
Undefined -> Constr
Undefined -> DataType
(forall b. Data b => b -> b) -> Undefined -> Undefined
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Undefined -> u
forall u. (forall d. Data d => d -> u) -> Undefined -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Undefined
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Undefined -> c Undefined
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Undefined)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Undefined)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Undefined -> c Undefined
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Undefined -> c Undefined
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Undefined
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Undefined
$ctoConstr :: Undefined -> Constr
toConstr :: Undefined -> Constr
$cdataTypeOf :: Undefined -> DataType
dataTypeOf :: Undefined -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Undefined)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Undefined)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Undefined)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Undefined)
$cgmapT :: (forall b. Data b => b -> b) -> Undefined -> Undefined
gmapT :: (forall b. Data b => b -> b) -> Undefined -> Undefined
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Undefined -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Undefined -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Undefined -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Undefined -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Undefined -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Undefined -> m Undefined
Data, Typeable, (forall x. Undefined -> Rep Undefined x)
-> (forall x. Rep Undefined x -> Undefined) -> Generic Undefined
forall x. Rep Undefined x -> Undefined
forall x. Undefined -> Rep Undefined x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Undefined -> Rep Undefined x
from :: forall x. Undefined -> Rep Undefined x
$cto :: forall x. Rep Undefined x -> Undefined
to :: forall x. Rep Undefined x -> Undefined
Generic)
{-# WARNING Undefined "'Undefined' type remains in code" #-}
undefined :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => a
undefined :: forall a. HasCallStack => a
undefined = a
forall a. HasCallStack => a
Prelude.undefined
{-# WARNING undefined "'undefined' function remains in code" #-}