Safe Haskell | None |
---|---|
Language | Haskell2010 |
Debug.RecoverRTTI.Classify
Synopsis
- classify :: a -> Either Closure (Classifier a)
- data Classified a = Classified (Classifier a) a
- fromUserDefined :: UserDefined -> (String, [Some Classified])
- anythingToString :: forall a. a -> String
- canShowPrim :: PrimClassifier a -> Dict Show a
- canShowClassified :: Classifier a -> Dict Show a
- canShowClassified_ :: forall o. (forall a. o a -> Dict Show a) -> forall a. Classifier_ o a -> Dict Show a
- pattern ElemK :: Classifier_ o a -> Elems o '[a]
- pattern ElemU :: Elems o '[Void]
- pattern ElemKK :: Classifier_ o a -> Classifier_ o b -> Elems o '[a, b]
- pattern ElemUU :: Elems o '[Void, Void]
- pattern ElemKU :: Classifier_ o a -> Elems o '[a, Void]
- pattern ElemUK :: Classifier_ o b -> Elems o '[Void, b]
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
Show (Classified a) Source # | |
Defined in Debug.RecoverRTTI.Classify Methods showsPrec :: Int -> Classified a -> ShowS # show :: Classified a -> String # showList :: [Classified a] -> ShowS # | |
Show (Some Classified) Source # | |
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.
canShowPrim :: PrimClassifier a -> Dict Show a Source #
canShowClassified :: Classifier a -> Dict Show a Source #
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 ElemKK :: Classifier_ o a -> Classifier_ o b -> Elems o '[a, b] Source #
Orphan instances
Show UserDefined Source # | |
Methods showsPrec :: Int -> UserDefined -> ShowS # show :: UserDefined -> String # showList :: [UserDefined] -> ShowS # |