Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Associativity of ->

Tags:

haskell

For monad bind operator, I can find that it's associativity is left from ghci using:

λ> :i (>>=)
class Monad (m :: * -> *) where
  (>>=) :: m a -> (a -> m b) -> m b
  ...
    -- Defined in ‘GHC.Base’
infixl 1 >>=

But the same doesn't work for ->:

λ> :i (->)
data (->) a b   -- Defined in ‘GHC.Prim’
instance Monad ((->) r) -- Defined in ‘GHC.Base’
instance Functor ((->) r) -- Defined in ‘GHC.Base’

Where exactly it's associativity is documented (Link to Haskell report is welcome, but I was not able to find there in my attempt) ?

like image 616
Sibi Avatar asked Jan 28 '26 03:01

Sibi


1 Answers

From the Haskell 2010 Language Report at §4.1.2 (Syntax of Types), page 38:

A function type has the form t1 -> t2, which is equivalent to the type (->) t1 t2. Function arrows associate to the right. For example, Int -> Int -> Float means Int -> (Int -> Float).

Here you can find the context in the report:

Image showing the context in which the quote above was taken

like image 92
Shoe Avatar answered Jan 30 '26 16:01

Shoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!