Haskell Language Common GHC Language Extensions TupleSections


A syntactic extension that allows applying the tuple constructor (which is an operator) in a section way:

(a,b) == (,) a b

-- With TupleSections
(a,b) == (,) a b == (a,) b == (,b) a


It also works for tuples with arity greater than two

(,2,) 1 3 == (1,2,3)


This can be useful in other places where sections are used:

map (,"tag") [1,2,3] == [(1,"tag"), (2, "tag"), (3, "tag")]

The above example without this extension would look like this:

map (\a -> (a, "tag")) [1,2,3]