Coder Social home page Coder Social logo

coredump's Introduction

CoreDump

This is a GHC plugin for dumping GHC's internal Core data structures(CoreProgram, CoreSyn etc.) in a readable yet completely exposed way.

When studying GHC's internals most of the time I want to see generated Core for an expression, or how a particular type/data constructor etc. is used internally. GHC provides no easy for this. Outputable.pprTrace and other functions in Outputable module help, but they don't solve the problem because

  1. they use Outputable instances, which hide lots of details 2) we have to modify GHC and recompile it to print things we're interested in, which takes a lot of time.

This library derives orphan Show instances for GHC internals as much as possible. When not possible(because of a hidden constructor), it tries hard to print something as similar to the original type as possible.

Currently these types are only printed as "<TypeName>":

  • Class.Class
  • CoreSyn.RuleFun (which is a function type)
  • UniqFM.UniqFM
  • Coercion.Coercion

Show instances of these types are same as Outputable instances:

  • Name.Name
  • OccName.OccName

Other than these, Show instances for pretty much every Core-level data structure are implemented.

Usage

After installing as usual:

$ ghc --make -fplugin=CoreDump -fplugin-opt=CoreDump:both Hello.hs

-fplugin-opt=CoreDump:both part is for telling the plugin when to dump Core. Valid arguments are: (to be used in place of both)

  • before: Print before Core-to-Core passes.
  • after: Print after Core-to-Core passes.
  • both: Print before and after Core-to-Core passes.

If you want to follow some other plugin's transformations, make sure to pass other plugin after passing CoreDump, in command line. Example:

$ ghc --make -fplugin=CoreDump -fplugin-opt=CoreDump:both -fplugin=Test Hello.hs

This will dump the Core, run the plugin named Test, and then dump the Core again.

If you move -fplugin=Test part before -fplugin=CoreDump, then GHC installs Test after installing CoreDump, so depending on how Test plugin installs itself, you may not be able to dump Core output before or after Test runs.

coredump's People

Contributors

osa1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

coredump's Issues

Printer loops with -O2

The printer is looping when -O or -O2 used.

As far as I understand, when -O is used some internal data structures are having cycles, which is then leading to loops when using Show instances. I don't know which type is responsible for this yet.

It works fine with -O0(default).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.