core-of-name: Print the Core representation of a binding with a GHC plugin.

[ bsd3, development, library, program ] [ Propose Tags ] [ Report a vulnerability ]

GHC plugin that prints the Core representation of a given binding, either to the console or to a file. Useful for debugging and learning about GHC's Core language.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), core-of-name, ghc (>=9.8 && <9.14), template-haskell (>=2.15 && <2.23) [details]
Tested with ghc ==9.10.3
License BSD-3-Clause
Copyright 2026 Marco Zocca
Author Marco Zocca
Maintainer ocramz
Uploaded by ocramz at 2026-03-16T19:18:31Z
Category Development
Home page https://github.com/ocramz/ghc-plugin-core-of-name
Source repo head: git clone https://github.com/ocramz/ghc-plugin-core-of-name
Distributions
Executables core-of-name
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-03-16 [all 1 reports]

Readme for core-of-name-0.1.0.0

[back to package description]

core-of-name

CI

GHC plugin that prints the Core intermediate representation of annotated Haskell bindings during compilation.

Based on the technique described in Finding the Core of an expression using Template Haskell and a custom GHC Core plugin, which in turn was inspired by inspection-testing

Usage

In the module whose bindings you want to inspect, enable TemplateHaskell and the plugin, then call coreOf or coreOfWith after the binding:

coreOf — print Core to stdout

{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fplugin=CoreOfName.Plugin #-}
module MyModule where

import CoreOfName.Types (coreOf)

f :: Double -> Double -> Double
f = \x y -> sqrt x + y

coreOf 'f

The Core representation of f will be printed interleaved with the normal compiler output during stack build / cabal build.

coreOfWith — write Core to a file

Use coreOfWith to direct the output to a file instead of stdout with this shorthand:

{-# LANGUAGE TemplateHaskell #-}
{-# language OverloadedStrings #-}
{-# OPTIONS_GHC -fplugin=CoreOfName.Plugin #-}
module MyModule where

import CoreOfName.Types (coreOfWith)

f :: Double -> Double -> Double
f = \x y -> sqrt x + y

coreOfWith "output.core" 'f

NB if two or more declarations use the same output file, the file will be overwritten. It is best to assign one Core output file per function.

The string literal is an Options value via the IsString instance and is equivalent to OToFile "output.core".

Explicit Options

You can also pass Options values directly:

import CoreOfName.Types (coreOfWith, Options(..))

-- print to stdout (same as coreOf)
coreOfWith OPrintCore 'f

-- write to a file
coreOfWith (OToFile "output.core") 'f

Building

stack clean && stack build