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

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Wed Jul 25 12:07:57 EDT 2007


Bulat Ziganshin <bulat.ziganshin at gmail.com> 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 at cl.cam.ac.uk



More information about the Haskell-Cafe mailing list