[GHC] #15646: ghci takes super long time to find the type of large fractional number
GHC
ghc-devs at haskell.org
Sun Sep 16 13:54:31 UTC 2018
#15646: ghci takes super long time to find the type of large fractional number
-------------------------------------+-------------------------------------
Reporter: Johannkokos | Owner:
| JulianLeviston
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: GHCi | Version: 8.4.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by JulianLeviston):
Took me a very long time to realise I could use `ghc -e ':t 1e100000000'
-ddump-parsed` to spit out the parsed file.
First I dug into the generated source for the parser trying to wrap my
head around how it's built. Then I tried to write a program to spit out
the parse result, but that was ultimately fruitless:
{{{#!hs
module Blah () where
import Parser
import Lexer
import GHC
import DynFlags
import StringBuffer (stringToStringBuffer)
import FastString
import SrcLoc
import Outputable
main :: IO ()
main = do
dynFlags <- getProgramDynFlags
let x = runParser dynFlags "putStrLn \"Hey\"" parseStatement
case x of
POk pstate res -> putStrLn $ ppr res
_ -> putStrLn "Fail"
runParser :: DynFlags -> String -> P a -> ParseResult a
runParser flags str parser = unP parser parseState
where
filename = "<interactive>"
location = mkRealSrcLoc (mkFastString filename) 1 1
buffer = stringToStringBuffer str
parseState = mkPState flags buffer location
}}}
That was pretty silly... anyway, I subsequently realised I could use flags
to spit out stage output. I should have read the docs on hacking on GHC
more! That yielded this:
{{{#!shell
➜ ghc git:(master) ✗ ./inplace/bin/ghc-stage2 blah2.hs -ddump-rn -dppr-
debug
[1 of 1] Compiling Blah2 ( blah2.hs, blah2.o )
blah2.hs:1:1:
==================== Renamer ====================
nonrec {blah2.hs:3:1-24}
main:Blah2.largevalue{v rpX}
main:Blah2.largevalue{v rpX}
= {blah2.hs:3:14-24}
1e100000000 (base:GHC.Real.fromRational{v 02C})
<>
}}}
So I'll dig into GHC.Real.fromRational next and see if I can't work out
what's going.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15646#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list