[英]Formatting GHC core?
When running GHC with -ddump-simpl
, I get .dump-simpl
files which are formatted in a way that's pretty hard to read.当使用-ddump-simpl
运行 GHC 时,我得到.dump-simpl
文件,这些文件的格式很难阅读。
Example snippet:示例片段:
{ (# ipv_aAYC, ipv1_aAYD #) ->
(# ipv_aAYC
`cast` ((GHC.Prim.State#
(Lamdu.Calc.Infer.R:WorldSTInfer[0]
<GHC.Prim.RealWorld>_N ; (Control.Monad.ST.Class.D:R:Worldt[0]
<ReaderT
(InferEnv
(STVar GHC.Prim.RealWorld),
STRef
GHC.Prim.RealWorld
Lamdu.Calc.Infer.QVarGen)>_N
<MaybeT
(GHC.ST.ST
GHC.Prim.RealWorld)>_N ; (Control.Monad.ST.Class.D:R:Worldt[0]
<MaybeT>_N
<GHC.ST.ST
GHC.Prim.RealWorld>_N ; Control.Monad.ST.Class.D:R:WorldST[0]
(Nth:0
(Nth:2
(Nth:3
(Nth:3
(<(InferEnv
(STVar
GHC.Prim.RealWorld),
STRef
GHC.Prim.RealWorld
Lamdu.Calc.Infer.QVarGen)>_R
->_R Sym (GHC.ST.N:ST[0]
<GHC.Prim.RealWorld>_N
<Maybe
(STVar
(World
(STInfer
GHC.Prim.RealWorld))
('Knot
T.Type))>_R) ; Sym (Control.Monad.Trans.Maybe.N:MaybeT[0]
<GHC.ST.ST
GHC.Prim.RealWorld>_R
(Lamdu.Calc.Infer.D:R:UVarSTInfer[0]
(Sym (Control.Monad.ST.Class.D:R:WorldST[0]
<GHC.Prim.RealWorld>_N) ; (Sym (Control.Monad.ST.Class.D:R:Worldt[0]
<MaybeT>_N
<GHC.ST.ST
GHC.Prim.RealWorld>_N) ; (Sym (Control.Monad.ST.Class.D:R:Worldt[0]
<ReaderT
(InferEnv
(STVar
GHC.Prim.RealWorld),
STRef
GHC.Prim.RealWorld
Lamdu.Calc.Infer.QVarGen)>_N
<MaybeT
(GHC.ST.ST
GHC.Prim.RealWorld)>_N) ; Sym (Lamdu.Calc.Infer.R:WorldSTInfer[0]
<GHC.Prim.RealWorld>_N)))) <'Knot
T.Type>_N))) ; (Control.Monad.Trans.Maybe.N:MaybeT[0]
<GHC.ST.ST
GHC.Prim.RealWorld>_R
<Tree
(UVar
(STInfer
GHC.Prim.RealWorld))
T.Type>_N ; GHC.ST.N:ST[0]
<GHC.Prim.RealWorld>_N
<Maybe
(Tree
(UVar
(STInfer
GHC.Prim.RealWorld))
T.Type)>_R)))))))))_R
:: GHC.Prim.State# (World (STInfer GHC.Prim.RealWorld))
~R# GHC.Prim.State# GHC.Prim.RealWorld),
Where is the code?代码在哪里? Mostly requires scrolling a lot to the right to see, and it is mostly type annotations with one word per line.大多数情况下需要向右滚动很多才能看到,并且主要是每行一个单词的类型注释。 Quite difficult to follow and I wonder if things could be better.很难遵循,我想知道事情是否会更好。
I tried using hindent
, brittany
, and stylish-haskell
to format the file (it's basically a variant of Haskell, isn't it?) but none of those support it..我尝试使用hindent
、 brittany
和hindent
stylish-haskell
来格式化文件(它基本上是 Haskell 的一个变体,不是吗?)但没有一个支持它..
I also saw the ghc-core
tool which should produce readable output but I've failed to figure out how to use it in a stack-based project (it wraps the system GHC?).我还看到了应该产生可读输出的ghc-core
工具,但我没有弄清楚如何在基于堆栈的项目中使用它(它包装了系统 GHC?)。
Any advice for how to make the core more readable?关于如何使核心更具可读性的任何建议?
You are looking for these options .您正在寻找这些选项。 Specifically, you need -dsuppress-coercions
, which should shrink that huge `cast` ...
into something like `cast` <Co:5>
.具体来说,您需要-dsuppress-coercions
,它应该将巨大的`cast` ...
缩小为类似`cast` <Co:5>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.