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

[ bsd3, debugging, library ] [ Propose Tags ] [ Report a vulnerability ]

The main function in this package is classify, which looks at the GHC heap to recover type information about arbitrary values. This makes it possible for example to show any value (function anythingToString) without having any Show instance in scope, though there are other use cases as well. For example, you could use it to define an anythingToJSON function.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.4.2, 0.4.3, 0.5.0 (info)
Change log CHANGELOG.md
Dependencies aeson (>=1.4 && <2.3), base (>=4.13 && <4.21), bytestring (>=0.10 && <0.13), containers (>=0.6 && <0.8), data-array-byte (>=0.1 && <0.2), ghc-heap (>=8.8 && <9.11), ghc-internal, ghc-prim (>=0.5 && <0.12), mtl (>=2.2 && <2.3 || >=2.3.1 && <2.4), primitive (>=0.7 && <0.10), sop-core (>=0.5 && <0.6), stm (>=2.5 && <2.6), text (>=1.2 && <2.2), unordered-containers (>=0.2.12 && <0.3), vector (>=0.12.1.2 && <0.14) [details]
Tested with ghc ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.2 || ==9.8.2 || ==9.10.1
License BSD-3-Clause
Copyright Juspay Technologies Pvt Ltd, Well-Typed LLP
Author Edsko de Vries
Maintainer edsko@well-typed.com
Category Debugging
Bug tracker https://github.com/well-typed/recover-rtti/issues
Source repo head: git clone https://github.com/well-typed/recover-rtti
Uploaded by EdskoDeVries at 2024-06-12T15:45:07Z
Distributions NixOS:0.5.0
Reverse Dependencies 4 direct, 0 indirect [details]
Downloads 1566 total (39 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
All reported builds failed as of 2024-06-12 [all 1 reports]

Readme for recover-rtti-0.5.0

[back to package description]

recover-rtti

Recover run-time type information from the GHC heap. The key function in this library is

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

which recovers type information about values about which we know nothing (in particular, no type class constraints). One example use case is the following anythingToString function:

anythingToString :: a -> String

We test that the result of anythingToString is equal to the result of regular show for a large range of data types (including user-defined ones that the library is not aware of). There are also other possible use cases; for example, it should be possible to define an anythingToJSON function.

Obviously there are limitations; the most important ones are:

There may be other gotchas as well; this library is primarily intended for debugging.