module Unison.Runtime.Debug ( traceComb, traceCombs, tracePretty, tracePrettyGroup, module Debug.Trace, ) where import Data.Word import Debug.Trace import Unison.PrettyPrintEnv (PrettyPrintEnv) import Unison.Runtime.ANF import Unison.Runtime.MCode import Unison.Syntax.TermPrinter (pretty) import Unison.Term qualified as Tm import Unison.Util.EnumContainers import Unison.Util.Pretty (toANSI) import Unison.Var (Var) type Term v = Tm.Term v () traceComb :: (Show clos, Show comb) => Bool -> Word64 -> GComb clos comb -> Bool traceComb :: forall clos comb. (Show clos, Show comb) => Bool -> Word64 -> GComb clos comb -> Bool traceComb Bool False Word64 _ GComb clos comb _ = Bool True traceComb Bool True Word64 w GComb clos comb c = String -> Bool -> Bool forall a. String -> a -> a trace (Word64 -> Word64 -> GComb clos comb -> ShowS forall val comb. (Show val, Show comb) => Word64 -> Word64 -> GComb val comb -> ShowS prettyComb Word64 w Word64 0 GComb clos comb c String "\n") Bool True traceCombs :: Word64 -> Bool -> EnumMap Word64 Comb -> EnumMap Word64 Comb traceCombs :: Word64 -> Bool -> EnumMap Word64 Comb -> EnumMap Word64 Comb traceCombs Word64 _ Bool False EnumMap Word64 Comb c = EnumMap Word64 Comb c traceCombs Word64 w Bool True EnumMap Word64 Comb c = String -> EnumMap Word64 Comb -> EnumMap Word64 Comb forall a. String -> a -> a trace (Word64 -> EnumMap Word64 Comb -> ShowS prettyCombs Word64 w EnumMap Word64 Comb c String "") EnumMap Word64 Comb c tracePretty :: (Var v) => PrettyPrintEnv -> Bool -> Term v -> Term v tracePretty :: forall v. Var v => PrettyPrintEnv -> Bool -> Term v -> Term v tracePretty PrettyPrintEnv _ Bool False Term v tm = Term v tm tracePretty PrettyPrintEnv ppe Bool True Term v tm = String -> Term v -> Term v forall a. String -> a -> a trace (Width -> Pretty ColorText -> String toANSI Width 50 (Pretty ColorText -> String) -> Pretty ColorText -> String forall a b. (a -> b) -> a -> b $ PrettyPrintEnv -> Term v -> Pretty ColorText forall v a. Var v => PrettyPrintEnv -> Term v a -> Pretty ColorText pretty PrettyPrintEnv ppe Term v tm) Term v tm tracePrettyGroup :: (Var v) => Word64 -> Bool -> SuperGroup v -> SuperGroup v tracePrettyGroup :: forall v. Var v => Word64 -> Bool -> SuperGroup v -> SuperGroup v tracePrettyGroup Word64 _ Bool False SuperGroup v g = SuperGroup v g tracePrettyGroup Word64 w Bool True SuperGroup v g = String -> SuperGroup v -> SuperGroup v forall a. String -> a -> a trace (String -> SuperGroup v -> ShowS forall v. Var v => String -> SuperGroup v -> ShowS prettyGroup (Word64 -> String forall a. Show a => a -> String show Word64 w) SuperGroup v g String "") SuperGroup v g