recover-rtti-0.6.1: Recover run-time type information from the GHC heap
Safe HaskellNone
LanguageGHC2021

Debug.RecoverRTTI.Classify

Synopsis

Classification

classify :: a -> Either Closure (Classifier a) Source #

Classify a value

Given a value of some unknown type a and a classifier Classifier a, it should be sound to coerce the value to the type indicated by the classifier.

This is also the reason not all values can be classified; in particular, we cannot classify values of unlifted types, as for these types coercion does not work (this would result in a ghc runtime crash).

User-defined types

data Classified a Source #

Bundle a value with its classifier

Constructors

Classified (Classifier a) a 

Instances

Instances details
Show (Classified a) Source # 
Instance details

Defined in Debug.RecoverRTTI.Classify

Show (Some Classified) Source # 
Instance details

Defined in Debug.RecoverRTTI.Classify

fromUserDefined :: UserDefined -> (String, [Some Classified]) Source #

Classify the arguments to the constructor

Additionally returns the constructor name itself.

Showing values

anythingToString :: a -> String Source #

Show any value

This shows any value, as long as it's not unlifted. The result should be equal to show instances, with the following caveats:

  • User-defined types (types not explicitly known to this library) with a custom Show instance will still be showable, but the result will be what the derived show instance would have done.
  • Record field names are not known at runtime, so they are not shown.
  • UNPACKed data is not visible to this library (if you compile with -O0 ghc will not unpack data, so that might be a workaround if necessary).

If classification fails, we show the actual closure.

anythingToShowS :: Int -> a -> ShowS Source #

Generalization of anythingToString with user-specified precedence

canShowClassified_ :: (forall a. o a -> Dict Show a) -> forall a. Classifier_ o a -> Dict Show a Source #

Orphan instances

Show Deferred Source # 
Instance details

Show UserDefined Source # 
Instance details