Because infixes are so common in Haskell, you will regularly need to look up their signature etc.. Fortunately, this is just as easy as for any other function:
The Haskell search engines Hayoo and Hoogle can be used for infix operators, like for anything else that's defined in some library.
In GHCi or IHaskell, you can use the :i
and :t
(info and type) directives to learn the basic properties of an operator. For example,
Prelude> :i +
class Num a where
(+) :: a -> a -> a
...
-- Defined in ‘GHC.Num’
infixl 6 +
Prelude> :i ^^
(^^) :: (Fractional a, Integral b) => a -> b -> a
-- Defined in ‘GHC.Real’
infixr 8 ^^
This tells me that ^^
binds more tightly than +
, both take numerical types as their elements, but ^^
requires the exponent to be integral and the base to be fractional.
The less verbose :t
requires the operator in parentheses, like
Prelude> :t (==)
(==) :: Eq a => a -> a -> Bool