module Plutarch.Internal.Trace (
  ptraceInfo,
  ptraceDebug,
  ptrace',
  ptrace,
) where

import Data.Kind (Type)
import Plutarch.Builtin.String (PString, ptrace', ptraceInfo)
import Plutarch.Internal.Term (Config (Tracing), LogLevel (LogDebug), S, Term, pdelay, pforce, pgetConfig, (#))

{- | Backward compatibility synonym for 'ptraceInfo'.

@since 1.6.0
-}
ptrace ::
  forall (a :: S -> Type) (s :: S).
  Term s PString ->
  Term s a ->
  Term s a
ptrace :: forall (a :: S -> Type) (s :: S).
Term s PString -> Term s a -> Term s a
ptrace = Term s PString -> Term s a -> Term s a
forall (a :: S -> Type) (s :: S).
Term s PString -> Term s a -> Term s a
ptraceInfo
{-# DEPRECATED ptrace "Use ptraceInfo" #-}

{- | Trace the given message at the debug level before evaluating the given
argument.

@since 1.6.0
-}
ptraceDebug ::
  forall (a :: S -> Type) (s :: S).
  Term s PString ->
  Term s a ->
  Term s a
ptraceDebug :: forall (a :: S -> Type) (s :: S).
Term s PString -> Term s a -> Term s a
ptraceDebug Term s PString
msg Term s a
x = (Config -> Term s a) -> Term s a
forall (s :: S) (a :: S -> Type). (Config -> Term s a) -> Term s a
pgetConfig ((Config -> Term s a) -> Term s a)
-> (Config -> Term s a) -> Term s a
forall a b. (a -> b) -> a -> b
$ \case
  Tracing LogLevel
LogDebug TracingMode
_ -> Term s (PDelayed a) -> Term s a
forall (s :: S) (a :: S -> Type). Term s (PDelayed a) -> Term s a
pforce (Term s (PDelayed a) -> Term s a)
-> Term s (PDelayed a) -> Term s a
forall a b. (a -> b) -> a -> b
$ Term s (PString :--> (PDelayed a :--> PDelayed a))
forall (s :: S) (a :: S -> Type). Term s (PString :--> (a :--> a))
ptrace' Term s (PString :--> (PDelayed a :--> PDelayed a))
-> Term s PString -> Term s (PDelayed a :--> PDelayed a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PString
msg Term s (PDelayed a :--> PDelayed a)
-> Term s (PDelayed a) -> Term s (PDelayed a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a -> Term s (PDelayed a)
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PDelayed a)
pdelay Term s a
x
  Config
_ -> Term s a
x