[Haskell-cafe] Operator precedence

David Menendez dave at zednenem.com
Mon Sep 6 13:50:16 EDT 2010


On Mon, Sep 6, 2010 at 1:37 PM, michael rice <nowgate at yahoo.com> wrote:
>
> A "concrete" library?
>
> I'm playing around with Data.Bits. It has .&. and .|. which I assume are functions
> (rather than operators) because I don't see and infix statement for them. Correct?

.|. and .&. are operators because they are made from symbol
characters. Operators default to infixl 9 unless specified otherwise,
so no infix declaration is needed.
However, Data.Bits does have infix declarations for .&. and .|. :

infixl 8 `shift`, `rotate`, `shiftL`, `shiftR`, `rotateL`, `rotateR`
infixl 7 .&.
infixl 6 `xor`
infixl 5 .|.

If you want to check the fixity of an operator, use :info in GHCi.
Prelude Data.Bits> :i .|.
class (Num a) => Bits a where
  ...
  (.|.) :: a -> a -> a
  ...
   -- Defined in Data.Bits
infixl 5 .|.

--
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list