由于缩进而调试显式字符

Mat*_*ner 6 syntax haskell indentation ghc

由于缩进,Haskell会自动插入分号和括号.在这个答案中,类型错误用于ghci打印带有分号和大括号的代码.如何在没有错误的情况下查看这些插入后的代码?我希望应该有像标志一样gcc的东西-E,它在宏预处理之后显示代码.

lef*_*out 2

$ cat >> Hello.hs
main = do
    putStr "Hello, "
    putStrLn "World!"

$ ghc -ddump-ds Hello.hs   # ds for "desugar"
[1 of 1] Compiling Main             ( Hello.hs, Hello.o )

==================== Desugar (after optimization) ====================
Result size of Desugar (after optimization)
  = {terms: 18, types: 9, coercions: 0, joins: 0/0}

-- RHS size: {terms: 8, types: 3, coercions: 0, joins: 0/0}
main :: IO ()
[LclIdX]
main
  = >>
      @ IO
      GHC.Base.$fMonadIO
      @ ()
      @ ()
      (putStr (GHC.CString.unpackCString# "Hello, "#))
      (putStrLn (GHC.CString.unpackCString# "World!"#))

-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
:Main.main :: IO ()
[LclIdX]
:Main.main = GHC.TopHandler.runMainIO @ () main

-- RHS size: {terms: 5, types: 0, coercions: 0, joins: 0/0}
Main.$trModule :: GHC.Types.Module
[LclIdX]
Main.$trModule
  = GHC.Types.Module
      (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "Main"#)
Run Code Online (Sandbox Code Playgroud)

我怀疑这对你来说有点太大了,但它肯定不再有块缩进了。