haskell-debugger-view
Safe HaskellNone
LanguageGHC2021

GHC.Debugger.View.Class

Description

The home of customizability for visualizing variables and values with haskell-debugger

Synopsis

Writing custom debug visualizations

The entry point for custom visualizations is DebugView. There are two axis of configuration:

  1. What to display inline in front of the variable name and whether it is expandable
  2. What fields are displayed when the value is expanded and what are their corresponding values

The former is answered by debugValue / VarValue and the latter by debugFields / VarFields.

class DebugView a where Source #

Custom handling of debug terms (e.g. in the variables pane, or when inspecting a lazy variable)

Methods

debugValue :: a -> VarValue Source #

Compute the representation of a variable with the given value.

INVARIANT: this method should only called on values which are already in WHNF, never thunks.

That said, this method is responsible for determining how much it is forced when displaying it inline as a variable.

For instance, for String, a will be fully forced to display the entire string in one go rather than as a linked list of Char.

debugFields :: a -> Program VarFields Source #

Compute the fields to display when expanding a value of type a.

This method should only be called to get the fields if the corresponding VarValue has varExpandable = True.

Instances

Instances details
DebugView ByteString Source # 
Instance details

Defined in GHC.Debugger.View.ByteString

DebugView Int16 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Int32 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Int64 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Int8 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Word16 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Word32 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Word64 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Word8 Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Text Source # 
Instance details

Defined in GHC.Debugger.View.Text

DebugView String Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Integer Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Char Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Double Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Float Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Int Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView Word Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView (IntMap a) Source # 
Instance details

Defined in GHC.Debugger.View.Containers

Show a => DebugView (BoringTy a) Source # 
Instance details

Defined in GHC.Debugger.View.Class

DebugView [a] Source #

This instance will display up to the first 50 forced elements of a list.

Instance details

Defined in GHC.Debugger.View.Class

Show k => DebugView (Map k a) Source # 
Instance details

Defined in GHC.Debugger.View.Containers

DebugView (a, b) Source # 
Instance details

Defined in GHC.Debugger.View.Class

Methods

debugValue :: (a, b) -> VarValue Source #

debugFields :: (a, b) -> Program VarFields Source #

data VarValue Source #

The representation of the value for some variable on the debugger

Constructors

VarValue 

Fields

newtype VarFields Source #

The representation for fields of a value which is expandable in the debugger

Constructors

VarFields 

data VarFieldValue Source #

A box for subfields of a value.

Used to construct the debug-view list of fields one gets from expanding a datatype. See, for instance, the DebugView (a, b) instance for an example of how it is used.

The boxed value is returned as is and can be further forced or expanded by the debugger, using either the existing DebugView instance for the existential a (the instance is found at runtime), or the generic runtime term inspection mechanisms otherwise.

Constructors

VarFieldValue a 

simpleValue :: String -> Bool -> VarValue Source #

Construct a VarValue which doesn't require a Program.

A Program can describe a more complicated visualisation method which

data Program a where Source #

The Program abstraction allows more complicated DebugView instances to be constructed. The debugger will interpreter a Program lazily when determining how to display a variable.

At the moment the only interesting query when constructing a program is determining if a value is already evaluated or not. This can be used to only display the evaluated prefix of a list for example.

Constructors

PureProgram :: forall a. a -> Program a

Lift a value to a program

ProgramAp :: forall a1 a. Program (a1 -> a) -> Program a1 -> Program a

Program application

ProgramBranch :: forall a. Program Bool -> Program a -> Program a -> Program a

Evaluate the conditional, and branch on the result

ProgramAskThunk :: forall a1. a1 -> Program Bool

Is the value a thunk or evaluated?

Instances

Instances details
Applicative Program Source # 
Instance details

Defined in GHC.Debugger.View.Class

Methods

pure :: a -> Program a #

(<*>) :: Program (a -> b) -> Program a -> Program b #

liftA2 :: (a -> b -> c) -> Program a -> Program b -> Program c #

(*>) :: Program a -> Program b -> Program b #

(<*) :: Program a -> Program b -> Program a #

Functor Program Source # 
Instance details

Defined in GHC.Debugger.View.Class

Methods

fmap :: (a -> b) -> Program a -> Program b #

(<$) :: a -> Program b -> Program a #

isThunk :: a -> Program Bool Source #

Construct a Program which determines if a is a thunk or not.

ifP :: Program Bool -> Program a -> Program a -> Program a Source #

Construct a program which branches

Utilities

These can make it easier to write your own custom instances. We also use them for the built-in custom instances.

newtype BoringTy a Source #

Boring types scaffolding.

Meant to be used like:

deriving via (BoringTy Int) instance (DebugView Int)

to derive a DebugView for a type whose terms should always be fully forced and displayed whole rather than as parts.

A boring type is one for which we don't care about the structure and would rather see "whole" when being inspected. Strings and literals are a good example, because it's more useful to see the string value than it is to see a linked list of characters where each has to be forced individually.

Constructors

BoringTy a 

Instances

Instances details
Show a => DebugView (BoringTy a) Source # 
Instance details

Defined in GHC.Debugger.View.Class

The internals

These are used by haskell-debugger when invoking these instances at runtime and reconstructing the result from the heap.

They should never be used by a user looking to write custom visualizations.

data VarValueIO Source #

Wrapper to make evaluating from debugger easier

Constructors

VarValueIO