[Haskell-cafe] Re: how to see operators precedence in GHCi

Stefan O'Rear stefanor at cox.net
Wed Jul 25 14:01:02 EDT 2007


On Wed, Jul 25, 2007 at 10:55:56AM -0700, Stefan O'Rear wrote:
> On Wed, Jul 25, 2007 at 09:35:38PM +0400, Bulat Ziganshin wrote:
> > Hello Jon,
> > 
> > Wednesday, July 25, 2007, 8:07:57 PM, you wrote:
> > >> Q: how to see operators precedence in GHCi?
> > >>     In the definition of `it': it = showParen $ (2 + (3 * 4))
> > 
> > > Hmm, OK, but not that much quicker than going
> > >    Prelude> :info (*)
> > 
> > it just my poor english :)  i mean - "how to see how Haskell will
> > parse some expression?". it will be too slow to look up each
> > precedence and parse expression by hand :)
> 
> Much easier:
> 
> stefan at stefans:~$ ghci
> GHCi, version 6.7.20070712: http://www.haskell.org/ghc/  :? for help
> Loading package base ... linking ... done.
> Prelude> :set -ddump-parsed
> Prelude> 2 + 3 * 4
> 
> ==================== Parser ====================
> Just (2 + 3) * 4
> 
> 
> 14
> Prelude> 

Uhm...  that didn't work :)

Not quite as nice:

stefan at stefans:~$ ghci -ddump-rn-trace
GHCi, version 6.7.20070712: http://www.haskell.org/ghc/  :? for help
Top level:
    tcRnStmt let __cmCompileExpr = System.IO.stdout
	     let __cmCompileExpr = GHC.Handle.stdout
	     [(rw, GHC.Handle.stdout)]
Loading package base ... linking ... done.
Top level:
    tcRnStmt let __cmCompileExpr = System.IO.stderr
	     let __cmCompileExpr = GHC.Handle.stderr
	     [(rjJ, GHC.Handle.stderr)]
Top level:
    tcRnStmt let __cmCompileExpr = System.IO.stdin
	     let __cmCompileExpr = GHC.Handle.stdin
	     [(rq, GHC.Handle.stdin)]
Prelude> 2 + 3 * 4
Top level:
    tcRnStmt (2 + 3) * 4
	     2 + (3 * 4)
	   [(rqz, +), (rqA, *)]
14
Prelude> 

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070725/bf71827a/attachment.bin


More information about the Haskell-Cafe mailing list