| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
GHC.Debugger.View.Class
Description
The home of customizability for visualizing variables and values with haskell-debugger
Synopsis
- class DebugView a where
- debugValue :: a -> VarValue
- debugFields :: a -> VarFields
- data VarValue = VarValue {
- varValue :: String
- varExpandable :: Bool
- newtype VarFields = VarFields {
- varFields :: [(String, VarFieldValue)]
- data VarFieldValue = VarFieldValue a
- newtype BoringTy a = BoringTy a
- data VarValueIO = VarValueIO {}
- debugValueIOWrapper :: DebugView a => a -> IO [VarValueIO]
- newtype VarFieldsIO = VarFieldsIO {
- varFieldsIO :: [(IO String, VarFieldValue)]
- debugFieldsIOWrapper :: DebugView a => a -> IO [VarFieldsIO]
Writing custom debug visualizations
The entry point for custom visualizations is DebugView.
There are two axis of configuration:
- What to display inline in front of the variable name and whether it is expandable
- 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 -> 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
has VarValue.varExpandable = True
Instances
| DebugView ByteString Source # | |
Defined in GHC.Debugger.View.ByteString | |
| DebugView Text Source # | |
Defined in GHC.Debugger.View.Text | |
| DebugView String Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Integer Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Char Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Double Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Float Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Int Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView Word Source # | |
Defined in GHC.Debugger.View.Class | |
| DebugView (IntMap a) Source # | |
Defined in GHC.Debugger.View.Containers | |
| Show a => DebugView (BoringTy a) Source # | |
Defined in GHC.Debugger.View.Class | |
| Show k => DebugView (Map k a) Source # | |
Defined in GHC.Debugger.View.Containers | |
| DebugView (a, b) Source # | |
Defined in GHC.Debugger.View.Class | |
The representation of the value for some variable on the debugger
Constructors
| VarValue | |
Fields
| |
The representation for fields of a value which is expandable in the debugger
Constructors
| VarFields | |
Fields
| |
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 instance for the
existential DebugViewa (the instance is found at runtime), or the generic runtime
term inspection mechanisms otherwise.
Constructors
| VarFieldValue a |
Utilities
These can make it easier to write your own custom instances. We also use them for the built-in custom instances.
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 |
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 | |
Fields
| |
debugValueIOWrapper :: DebugView a => a -> IO [VarValueIO] Source #
newtype VarFieldsIO Source #
Constructors
| VarFieldsIO | |
Fields
| |
debugFieldsIOWrapper :: DebugView a => a -> IO [VarFieldsIO] Source #