{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Debug.Trace.Linear
(
trace
, traceShow
, traceId
, traceStack
, traceIO
, traceM
, traceShowM
, traceEvent
, traceEventIO
, traceMarker
, traceMarkerIO
) where
import qualified Debug.Trace as NonLinear
import qualified Unsafe.Linear as Unsafe
import System.IO.Linear
import Data.Functor.Linear
import Data.Unrestricted.Linear
import Prelude (String, Show(..))
import Prelude.Linear.Internal
trace :: String %1-> a %1-> a
trace :: forall a. String %1 -> a %1 -> a
trace = (String -> a -> a) %1 -> String %1 -> a %1 -> a
forall a b c (p :: Multiplicity) (q :: Multiplicity).
(a %p -> b %q -> c) %1 -> a %1 -> b %1 -> c
Unsafe.toLinear2 String -> a -> a
forall a. String -> a -> a
NonLinear.trace
traceShow :: Show a => a -> b %1-> b
traceShow :: forall a b. Show a => a -> b %1 -> b
traceShow a
a = (b -> b) %1 -> b %1 -> b
forall a b (p :: Multiplicity). (a %p -> b) %1 -> a %1 -> b
Unsafe.toLinear (a -> b -> b
forall a b. Show a => a -> b -> b
NonLinear.traceShow a
a)
traceId :: String %1-> String
traceId :: String %1 -> String
traceId String
s = String %1 -> (String, String)
forall a. Dupable a => a %1 -> (a, a)
dup String
s (String, String) %1 -> ((String, String) %1 -> String) %1 -> String
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \(String
s', String
s'') -> String %1 -> String %1 -> String
forall a. String %1 -> a %1 -> a
trace String
s' String
s''
traceStack :: String %1-> a %1-> a
traceStack :: forall a. String %1 -> a %1 -> a
traceStack = (String -> a -> a) %1 -> String %1 -> a %1 -> a
forall a b c (p :: Multiplicity) (q :: Multiplicity).
(a %p -> b %q -> c) %1 -> a %1 -> b %1 -> c
Unsafe.toLinear2 String -> a -> a
forall a. String -> a -> a
NonLinear.traceStack
traceIO :: String %1-> IO ()
traceIO :: String %1 -> IO ()
traceIO String
s = IO () %1 -> IO ()
forall a. IO a %1 -> IO a
fromSystemIO ((String -> IO ()) %1 -> String %1 -> IO ()
forall a b (p :: Multiplicity). (a %p -> b) %1 -> a %1 -> b
Unsafe.toLinear String -> IO ()
NonLinear.traceIO String
s)
traceM :: Applicative f => String %1-> f ()
traceM :: forall (f :: * -> *). Applicative f => String %1 -> f ()
traceM String
s = String %1 -> f () %1 -> f ()
forall a. String %1 -> a %1 -> a
trace String
s (f () %1 -> f ()) %1 -> f () %1 -> f ()
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ () -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
traceShowM :: (Show a, Applicative f) => a -> f ()
traceShowM :: forall a (f :: * -> *). (Show a, Applicative f) => a -> f ()
traceShowM a
a = String %1 -> f ()
forall (f :: * -> *). Applicative f => String %1 -> f ()
traceM (a -> String
forall a. Show a => a -> String
show a
a)
traceEvent :: String %1-> a %1-> a
traceEvent :: forall a. String %1 -> a %1 -> a
traceEvent = (String -> a -> a) %1 -> String %1 -> a %1 -> a
forall a b c (p :: Multiplicity) (q :: Multiplicity).
(a %p -> b %q -> c) %1 -> a %1 -> b %1 -> c
Unsafe.toLinear2 String -> a -> a
forall a. String -> a -> a
NonLinear.traceEvent
traceEventIO :: String %1-> IO ()
traceEventIO :: String %1 -> IO ()
traceEventIO String
s = IO () %1 -> IO ()
forall a. IO a %1 -> IO a
fromSystemIO ((String -> IO ()) %1 -> String %1 -> IO ()
forall a b (p :: Multiplicity). (a %p -> b) %1 -> a %1 -> b
Unsafe.toLinear String -> IO ()
NonLinear.traceEventIO String
s)
traceMarker :: String %1-> a %1-> a
traceMarker :: forall a. String %1 -> a %1 -> a
traceMarker = (String -> a -> a) %1 -> String %1 -> a %1 -> a
forall a b c (p :: Multiplicity) (q :: Multiplicity).
(a %p -> b %q -> c) %1 -> a %1 -> b %1 -> c
Unsafe.toLinear2 String -> a -> a
forall a. String -> a -> a
NonLinear.traceMarker
traceMarkerIO :: String %1-> IO ()
traceMarkerIO :: String %1 -> IO ()
traceMarkerIO String
s = IO () %1 -> IO ()
forall a. IO a %1 -> IO a
fromSystemIO ((String -> IO ()) %1 -> String %1 -> IO ()
forall a b (p :: Multiplicity). (a %p -> b) %1 -> a %1 -> b
Unsafe.toLinear String -> IO ()
NonLinear.traceMarkerIO String
s)