Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grave accent in Haskell

I am new in Haskell programming. I am trying to understand syntax and semantics of this language. I am a bit curious about the semantics of grave accent . Why does this code work when we use grave accent?

elem' :: (Eq a) => a -> [a] -> Bool  
elem' a [] = False  
elem' a (x:xs)  
    | a == x    = True  
    | otherwise = a `elem'` xs {-grave accent used in this line -}
like image 715
MIRMIX Avatar asked Mar 09 '14 15:03

MIRMIX


1 Answers

The backquotes are used to treat any binary function as an infix operator.

a `elem'` xs

is identical to

elem' a xs

It is the complement to the use of (+) to use a binary operator as a function:

(+) 3 5

is identical to

3 + 5
like image 124
chepner Avatar answered Sep 28 '22 03:09

chepner