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




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


Classified (Classifier a) a 


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 :: forall a. 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.

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

Patterns for common shapes of Elems (exported for the tests)

pattern ElemK :: Classifier_ o a -> Elems o '[a] Source #

pattern ElemU :: Elems o '[Void] Source #

pattern ElemKK :: Classifier_ o a -> Classifier_ o b -> Elems o '[a, b] Source #

pattern ElemUU :: Elems o '[Void, Void] Source #

pattern ElemKU :: Classifier_ o a -> Elems o '[a, Void] Source #

pattern ElemUK :: Classifier_ o b -> Elems o '[Void, b] Source #

Orphan instances