[Haskell-cafe] Operator precedence

michael rice nowgate at yahoo.com
Mon Sep 6 14:06:50 EDT 2010

Hi David,

You're right, I keep forgetting to look at the source code.

And I wasn't aware of the info (:i) command. Should come in handy in the future.


--- On Mon, 9/6/10, David Menendez <dave at zednenem.com> wrote:

From: David Menendez <dave at zednenem.com>
Subject: Re: [Haskell-cafe] Operator precedence
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org, "Daniel Díaz" <lazy.ddiaz at gmail.com>
Date: Monday, September 6, 2010, 1:50 PM

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>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100906/3ff0e48b/attachment.html

More information about the Haskell-Cafe mailing list