{-# OPTIONS_GHC -Wno-orphans #-}
module GHC.Debugger.Utils.Orphans () where

import GHC.Debugger.View.Class
import GHC.Data.FastString
import GHC.Unit.Module
import GHC.Debugger.Utils (showModule)

instance DebugView FastString where
  debugValue :: FastString -> VarValue
debugValue  FastString
t = String -> Bool -> VarValue
simpleValue (FastString -> String
unpackFS FastString
t) Bool
False
  debugFields :: FastString -> Program VarFields
debugFields FastString
_ = VarFields -> Program VarFields
forall a. a -> Program a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(String, VarFieldValue)] -> VarFields
VarFields [])

instance DebugView Module where
  debugValue :: Module -> VarValue
debugValue  Module
t = String -> Bool -> VarValue
simpleValue (Module -> String
showModule Module
t) Bool
False
  debugFields :: Module -> Program VarFields
debugFields Module
_ = VarFields -> Program VarFields
forall a. a -> Program a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(String, VarFieldValue)] -> VarFields
VarFields [])

instance DebugView (ModuleEnv a) where
  debugValue :: ModuleEnv a -> VarValue
debugValue ModuleEnv a
m = String -> Bool -> VarValue
simpleValue String
"ModuleEnv" (Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ModuleEnv a -> Bool
forall a. ModuleEnv a -> Bool
isEmptyModuleEnv ModuleEnv a
m)
  debugFields :: ModuleEnv a -> Program VarFields
debugFields ModuleEnv a
m = VarFields -> Program VarFields
forall a. a -> Program a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VarFields -> Program VarFields) -> VarFields -> Program VarFields
forall a b. (a -> b) -> a -> b
$ [(String, VarFieldValue)] -> VarFields
VarFields
    [ (Module -> String
showModule Module
k, a -> VarFieldValue
forall a. a -> VarFieldValue
VarFieldValue a
v)
    | (Module
k, a
v) <- ModuleEnv a -> [(Module, a)]
forall a. ModuleEnv a -> [(Module, a)]
moduleEnvToList ModuleEnv a
m
    ]

instance DebugView ModuleName where
  debugValue :: ModuleName -> VarValue
debugValue  ModuleName
t = String -> Bool -> VarValue
simpleValue (ModuleName -> String
moduleNameString ModuleName
t) Bool
False
  debugFields :: ModuleName -> Program VarFields
debugFields ModuleName
_ = VarFields -> Program VarFields
forall a. a -> Program a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(String, VarFieldValue)] -> VarFields
VarFields [])

instance DebugView UnitId where
  debugValue :: UnitId -> VarValue
debugValue  UnitId
t = String -> Bool -> VarValue
simpleValue (UnitId -> String
unitIdString UnitId
t) Bool
False
  debugFields :: UnitId -> Program VarFields
debugFields UnitId
_ = VarFields -> Program VarFields
forall a. a -> Program a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(String, VarFieldValue)] -> VarFields
VarFields [])