
Is there a handy list of operators and their precedence somewhere? Michael

Take a look to the Haskell Report: http://www.haskell.org/onlinereport/haskell2010/haskellch9.html#x16-1710009 -- Daniel Díaz

Thanks, Daniel.
This be all of them?
Michael
infixr 9 .
infixr 8 ^, ^^, ⋆⋆
infixl 7 ⋆, /, ‘quot‘, ‘rem‘, ‘div‘, ‘mod‘
infixl 6 +, -
-- The (:) operator is built-in syntax, and cannot legally be given
-- a fixity declaration; but its fixity is given by:
-- infixr 5 :
infix 4 ==, /=, <, <=, >=, >
infixr 3 &&
infixr 2 ||
infixl 1 >>, >>=
infixr 1 =<<
infixr 0 $, $!, ‘seq‘
--- On Mon, 9/6/10, Daniel Díaz

Those are all operators in Prelude. See a concrete library for their operator precedences. -- Daniel Díaz

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?
Michael
--- On Mon, 9/6/10, Daniel Díaz

On Mon, Sep 6, 2010 at 1:37 PM, michael rice
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

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.
Michael
--- On Mon, 9/6/10, David Menendez
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

On Mon, Sep 6, 2010 at 2:21 PM, Daniel Díaz
El Lun, 6 de Septiembre de 2010, 7:50 pm, David Menendez escribió:
Operators default to infixl 9 unless specified otherwise, so no infix declaration is needed.
Why there is a default infix? Why it is 9?
That's what the Haskell Report says: "Any operator lacking a fixity
declaration is assumed to be infixl 9" (section 4.4.2).
Any function with at least two arguments can be used as an operator,
so there has to be a default. Presumably, infixl 9 was considered the
least surprising.
--
Dave Menendez

Hello michael, Monday, September 6, 2010, 9:00:32 PM, you wrote:
Is there a handy list of operators and their precedence somewhere?
unlike most languages, operators are user-definable in haskell. so there is no comprehensive list any function with two arguments van be used as operator: a `min` b any operator may be defined or used as a function: (&&) a b = ... main = print ((&&) True False) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (5)
-
Bulat Ziganshin
-
Daniel Díaz
-
Daniel Díaz
-
David Menendez
-
michael rice