Debug explicit characters due to indentation

Haskell automatically inserts semicolons and curly braces due to indentation. This answer uses an error like ghci to print code with semicolons and brackets explicitly shown. How can I view the code after these inserts without errors? I expect that there should be something like the gcc -E flag, which shows the code after macro preprocessing.

+5
source share
1 answer
 $ 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"#) 

I suspect the bit is too wide for your taste, but of course it no longer has indented blocks.

+2
source

Source: https://habr.com/ru/post/1275672/


All Articles