id is:exact package:base set:included-with-ghc

Identity function.
id x = x
This function might seem useless at first glance, but it can be very useful in a higher order context.

Examples

>>> length $ filter id [True, True, False, True]
3
>>> Just (Just 3) >>= id
Just 3
>>> foldr id 0 [(^3), (*5), (+2)]
1000
The identity morphism. Implementations should satisfy two laws:
  • Right identity f . id = f
  • Left identity id . f = f
These essentially state that id should "do nothing".