
Hi, I'm trying to profile my haskell code (see thread "profiling in haskell") and to get more insight I made GHC produce the haskell Core code. However, I'm not quite sure how to interpret it, is there a definition (quick search didn't reveal one)? Also, how do I demangle the names? It seems that, for example, 'base:GHC.Base.ZC' is a (:) function on strings, but where how am I supposed to figure that out? Thanks! -- Vlad Skvortsov, vss@73rus.com, http://vss.73rus.com

Vlad Skvortsov wrote:
Also, how do I demangle the names? It seems that, for example, 'base:GHC.Base.ZC' is a (:) function on strings, but where how am I supposed to figure that out?
#!/usr/bin/perl # Written by Ashley Yakeley 2003 # All rights to the public while (<>) { s/_/ /g; s/\w+/decode($&)/eg; print; } sub commas { local($i) = @_; if ($i == 0) { return ""; } elsif ($i == 1) { return " "; } else { return "," x ($i - 1); } } sub decode { local($s) = @_; my $a=""; while ($s =~/([^zZ]*)([zZ].*)/) { $a.=$1; if ($2 =~/([zZ][A-Za-z])(.*)/) { { $a.="(",last if $1 =~/ZL/; $a.=")",last if $1 =~/ZR/; $a.="[",last if $1 =~/ZM/; $a.="]",last if $1 =~/ZN/; $a.=":",last if $1 =~/ZC/; $a.="Z",last if $1 =~/ZZ/; $a.="z",last if $1 =~/zz/; $a.="&",last if $1 =~/za/; $a.="|",last if $1 =~/zb/; $a.="^",last if $1 =~/zc/; $a.='$',last if $1 =~/zd/; $a.="=",last if $1 =~/ze/; $a.=">",last if $1 =~/zg/; $a.="#",last if $1 =~/zh/; $a.=".",last if $1 =~/zi/; $a.="<",last if $1 =~/zl/; $a.="-",last if $1 =~/zm/; $a.="!",last if $1 =~/zn/; $a.="+",last if $1 =~/zp/; $a.="'",last if $1 =~/zq/; $a.="\\",last if $1 =~/zr/; $a.="/",last if $1 =~/zs/; $a.="*",last if $1 =~/zt/; $a.="_",last if $1 =~/zu/; $a.="%",last if $1 =~/zv/; $a.="???"; } $s = $2; } elsif ($2 =~/Z([0-9]+)T(.*)/) { $a.="(".commas($1).")"; $s = $2; } elsif ($2 =~/Z([0-9]+)H(.*)/) { $a.="(#".commas($1)."#)"; $s = $2; } elsif ($2 =~/Z([0-9]+)U(.*)/) { $a.=chr($1); $s = $2; } else { $a.="???".$2; $s = ""; } }; return $a.$s; };

This paper is a bit old but still very relevant: An External Representation for the GHC Core Language http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.25.1755 Click "view or download" at the bottom to see the paper. Also, I haven't used this utility myself yet but it pages and colorizes GHC core for you: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ghc-core Justin

Justin Bailey wrote:
This paper is a bit old but still very relevant:
An External Representation for the GHC Core Language http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.25.1755
Click "view or download" at the bottom to see the paper. Also, I haven't used this utility myself yet but it pages and colorizes GHC core for you:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ghc-core
IIRC, wasn't there a plan a while back to make GHC compile *from* Core as well as just outputting it? Did this ever go anywhere?

On Tue, Sep 9, 2008 at 8:34 AM, Justin Bailey
This paper is a bit old but still very relevant:
An External Representation for the GHC Core Language http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.25.1755
Or: http://www.haskell.org/ghc/docs/papers/core.ps.gz Note that External Core, as specified in this paper, is similar to but not entirely the same as the version of Core that GHC prints out for debugging purposes. GHC 6.10 will be able to produce External Core with a flag again, and at that point Section 5.15 of the users' guide will point to a new version of the documentation -- so if you upgrade to 6.10 when it is released and are still poring over Core code then, be sure to get the new documentation. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt Just enough: Obama/Biden '08.
participants (5)
-
Andrew Coppin
-
Ashley Yakeley
-
Justin Bailey
-
Tim Chevalier
-
Vlad Skvortsov