|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
how to see operators precedence in GHCiHello ,
from http://community.livejournal.com/ru_declarative/54566.html Q: how to see operators precedence in GHCi? A: Prelude> let showParen = (undefined::[[[[()]]]]->()) Prelude> showParen $ 2+3*4 <interactive>:1:12: No instance for (Num [[[[()]]]]) arising from use of `+' at <interactive>:1:12 Probable fix: add an instance declaration for (Num [[[[()]]]]) In the second argument of `($)', namely `2 + (3 * 4)' In the definition of `it': it = showParen $ (2 + (3 * 4)) Prelude> -- Best regards, Bulat mailto:Bulat.Ziganshin@... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: how to see operators precedence in GHCiBulat Ziganshin <bulat.ziganshin@...> writes:
> Hello , > > from http://community.livejournal.com/ru_declarative/54566.html > > Q: how to see operators precedence in GHCi? > A: > Prelude> let showParen = (undefined::[[[[()]]]]->()) > Prelude> showParen $ 2+3*4 > <interactive>:1:12: > No instance for (Num [[[[()]]]]) > arising from use of `+' at <interactive>:1:12 > Probable fix: add an instance declaration for (Num [[[[()]]]]) > In the second argument of `($)', namely `2 + (3 * 4)' > In the definition of `it': it = showParen $ (2 + (3 * 4)) Hmm, OK, but not that much quicker than going Prelude> :info (*) class (Eq a, Show a) => Num a where ... (*) :: a -> a -> a ... -- Defined in GHC.Num infixl 7 * Prelude> :info (+) class (Eq a, Show a) => Num a where (+) :: a -> a -> a ... -- Defined in GHC.Num infixl 6 + Prelude> -- Jón Fairbairn Jon.Fairbairn@... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Re: how to see operators precedence in GHCiHello 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 :) -- Best regards, Bulat mailto:Bulat.Ziganshin@... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Re: how to see operators precedence in GHCiOn 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 :) stefan@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> Stefan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Re: how to see operators precedence in GHCiOn 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@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> Not quite as nice: stefan@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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
RE: Re: how to see operators precedence in GHCi| Uhm... that didn't work :) | | Not quite as nice: | | stefan@stefans:~$ ghci -ddump-rn-trace You probably wanted -ddump-rn Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
Re: Re: how to see operators precedence in GHCiOn Thu, Jul 26, 2007 at 12:42:52AM +0100, Simon Peyton-Jones wrote:
> > | Uhm... that didn't work :) > | > | Not quite as nice: > | > | stefan@stefans:~$ ghci -ddump-rn-trace > > You probably wanted -ddump-rn Seemed so, but that option has no effect (bug?): stefan@stefans:~$ ghci -ddump-rn GHCi, version 6.7.20070712: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> 2 + 2 4 Prelude> Stefan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
|
|
RE: Re: how to see operators precedence in GHCiHmm. Good point. Fixed.
Smion | -----Original Message----- | From: Stefan O'Rear [mailto:stefanor@...] | Sent: 26 July 2007 01:01 | To: Simon Peyton-Jones | Cc: Bulat Ziganshin; haskell-cafe@...; Jon Fairbairn | Subject: Re: [Haskell-cafe] Re: how to see operators precedence in GHCi | | On Thu, Jul 26, 2007 at 12:42:52AM +0100, Simon Peyton-Jones wrote: | > | > | Uhm... that didn't work :) | > | | > | Not quite as nice: | > | | > | stefan@stefans:~$ ghci -ddump-rn-trace | > | > You probably wanted -ddump-rn | | Seemed so, but that option has no effect (bug?): | | stefan@stefans:~$ ghci -ddump-rn | GHCi, version 6.7.20070712: http://www.haskell.org/ghc/ :? for help | Loading package base ... linking ... done. | Prelude> 2 + 2 | 4 | Prelude> | | Stefan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@... http://www.haskell.org/mailman/listinfo/haskell-cafe |
| Free embeddable forum powered by Nabble | Forum Help |