In Haskell language function id
defined to be unit of composition:
id :: a -> a
id x = x
Is there a way to define haskell' id
function using point-free notation?
I mean not to directly referencing it like:
same :: a -> a
same = id
The pointfree version of id
is... well, id
. id
is often taken as a fundamental operator in pointfree constructions, a sort of a primitive upon which more combinators are constructed.
If you really want, you can reconstruct id
from other more complex operators, e.g. exploiting the Monad ((->) a)
instance:
id = join const
or the Applicative ((->) a)
instance
id = const <*> const
(in combinatory logic, this is I = S K K
since <*>
is S
and const
is K
)
Nothing can be simpler than id
itself, though.